tensorflow / models

Models and examples built with TensorFlow
Other
77.01k stars 45.78k forks source link

Deeplab does not produce correct segmentation mask. #6565

Closed ajinkya933 closed 5 years ago

ajinkya933 commented 5 years ago

System information

Describe the problem

I am training my own model to segment squares in images using Deeplab. For that I have annotated the training data, Heres an example of training image(on left) and segmentation mask image(on right).

Screenshot 2019-04-12 at 12 29 17 PM

I am converting this training data to record file using: Deeplab-> build_voc2012_data.py

I have further made following changes to the scripts described as below, These changes are such that I can train my own dataset.

deeplab -> datasets -> datagenerator.py

TESTSET_INFORMATION = DatasetDescriptor( splits_to_sizes={ 'train': 800, # num of samples in images/training 'val': 200, # num of samples in images/validation }, num_classes=2, ignore_label=255, # When setting ignore_label = 0 predictions come back as a red or green image; and when setting ignore_label = 255 predictions come back as a black image ) _DATASETS_INFORMATION = { 'cityscapes': _CITYSCAPES_INFORMATION, 'pascal_voc_seg': _PASCAL_VOC_SEG_INFORMATION, 'ade20k': _ADE20K_INFORMATION, 'testset': _TESTSET_INFORMATION, }

utils > train_utils.py

exclude_list = ['global_step', 'logits']

not_ignore_mask = tf.to_float(tf.equal(scaled_labels, 0)) 1 + tf.to_float(tf .equal(scaled_labels, 1)) 2 + tf.to_float(tf.equal(scaled_labels, ignore_label )) * 0

Please note batch size=12. And training number of steps = 1000. I get following predictions

Screenshot 2019-04-12 at 12 37 56 PM

I am not sure what is it I am doing wrong ? To further debug the problem I observed that during training the loss dosen't change it keeps on oscillating.

example loss is:

Total loss is :[0.0697127208] INFO:tensorflow:global_step/sec: 0.715997 Total loss is :[0.0697126836] INFO:tensorflow:global_step/sec: 0.835336 Total loss is :[0.0697126538] INFO:tensorflow:global_step/sec: 0.83706 Total loss is :[0.0697126389] INFO:tensorflow:global_step/sec: 0.833028 Total loss is :[0.069712624] INFO:tensorflow:global_step/sec: 0.836747 Total loss is :[0.069712624] INFO:tensorflow:global_step/sec: 0.831312 Total loss is :[0.069712624] INFO:tensorflow:global_step/sec: 0.832811 Total loss is :[0.069712624] INFO:tensorflow:global_step/sec: 0.83014 Total loss is :[0.069712624] INFO:tensorflow:global_step/sec: 0.830697

What should I do so that the loss is reduced and the model gives a proper square as a segmentation output ?

@bleedingfight @aquariusjay @Citygity could you shed some light and help me bring one step closer to the solution ?

vijay1131 commented 5 years ago

@ajinkya933 How did you solved your issue?

hakS07 commented 5 years ago

@ajinkya933 did you solved the problem??

ajinkya933 commented 5 years ago

My input images which I used for training were not used properly, Make sure that your object has pixel value of RGB(1,1,1) and your background has pixel value(0,0,0)

hakS07 commented 5 years ago

@ajinkya933 ok, thank you