deeplab doesn't predict correctly the segmentation masks
Everything seems to be working properly training/evaluation etc. except from the fact that deeplab doesn't predict the segmentation masks.
Example:


The original images in the dataset are either colored like the above one or black and white, but all the masks are black and white.
same with me Did you freeze your model?
@Raj-08 nope. Just trained normally for 25000 steps and then did validation and that's what I get.
check your data that you are visualizing , it should be with 0-1 and type should be uint8 . Divide it by np.max i.e data/np.max(data) convert to uint8 and then visualize , you should get it right then
@Raj-08 thanks for the response. I'm a bit confused though.
Divide it by np.max i.e data/np.max(data)
That's scaling the data in the range [0-1]. i.e. float. Then making it uint8 makes them int. I dunno how that's gonna help.
Question 1: Should the data be in float in range[0-1] or should it be uint8 in range [0-255]? Question 2: Should we do the same for the masks? Quesiton 3: Does deeplab also require bounding boxes for the masks or it can work without that? Question 4: Does it matter if the data are of different sizes, .e.g. img1.size = 256x320x3, img2.size=520x320x3, ..., etc.? Or should we make them all fixed size?
Thanks!
@kirk86 I met the same problem! did you change the last logits layer from 21 to 2? If so , I think maybe I can solve the problem.
@Raj-08 how to freez part of my model? Thanks!
@meteorshowers Yes I did change the class number from 21 to 2.
@kirk86 Hi have you figured out the solution? I had exactly the same issue...
@khcy82dyc No TBH, I haven't, my 2 cents after spending a week chasing bugs not only on the deeplab model but on faster-rcnn as well is get as far away as you can. Most of the models have additional complexity in terms of trying to understand them since they use slim. In my experience most models break once you change a bit the configuration settings. For instance for faster-rcnn once you change to multi-gpu training things again break.
@kirk86 @Raj-08 @meteorshowers I may have found a solution, it's to do with the number of class value and for some reason it should not include background as one class. otherwise it will produce a blank segmentation. So for this case kirk86 might need to change it to 1 instead of 2.
other funny behaviours I have encountered: for my case I had 1500 500*500 images with 7 classes including background: I'm using initialize_last_layer=False, last_layers_contain_logits_only=True, fine_tune_batch_norm=False and Deeplabv3_xception as the initial checkpoint
if i set my background to any other values instead of 0, training produce constant loss value
if I set my background to 0 and number of class I set 7, I get blank prediction
If I set fine_tune_batch_norm=true the loss will become 6 digit at 50000 steps,
if I set fine_tune_batch_norm=false I get "Loss is inf or nan. : Tensor had NaN values" even with a learning rate 0.00001
Do you guys mind share you training parameter here please?
(would be nice if the @aquariusjay can provide some suggestions the reason for these strange issues)
@khcy82dyc TBH with you I think I've tried it even with 1 class and still had the same results plus all the models under tensorflow/research are so convoluted with unnecessary code that makes it hard for me to understand what they are actually doing. As I said after spending, cough, wasting some time I decided to look elsewhere. It's been like a month since I last touched them, so I can't even remember the settings that I had. But let me say something last. From my understanding you've spend some time debugging and tried multiple configurations from what you're saying, if none of those configurations is working then maybe ............................. cough!
@khcy82dyc I'm trying to train the model on a different dataset. After 3-4k iterations, the loss stops to decrease and starts to oscillate (20k iterations). Did you experiment something similar?
@kirk86 @khcy82dyc , I just can't seem to make it work on my custom dataset, working with mobilenet_v2 version, getting the same complete black output. Running inference on pre-trained model works fine for me. Tried most of the things @khcy82dyc mentioned, its the same result.
Any suggestions?
I'm having the same problem with the black output. Probably it is something related to the number or order of classes.
@meteorshowers ,hi, I also want to use own data which has the different class number but meet the problem, I only change the dataset settings in train.py and segmentation_dataset.py from the manual. I want to ask where I can change the last logits layer from 21 to 2. Thank you!
got the same issue. i used deeplab to do lane line segmentation. But unfortunately i got a constant loss between 0.2 and 0.3 and black output predicted images.
@khcy82dyc Hello,have you have a good solution about the 1 class training?I also meet the problems.
@kirk86 do you have imbalanced data distribution like 1:100? i encountered your problem before, after setting different weight_loss, i got non-black masks.
@shanyucha it is imbalanced but not at that level more of 40:60.
@meteorshowers Do you mean freeze the weights before training or generate frozen graph from trained model ?