Open thepate94227 opened 5 years ago
same problem as yours
@thepate94227 hi...so do you know how to solve the issue of feeding data using flow_from_directory when the mask is of size (384x384x5)? the model train for several epochs and then threw "incompatible shape error". Appreciate if anyone have any idea!
@blaxe05 Hi, I am sorry, but because of this problem and other problems i didn't use Deeplab. In my case i used Mask R-CNN. So unfortunately i don't know the solution for this problem...
I also ran into this issue, maybe we make a mistake at a point during training/inference.
@blaxe05 Hi, I am sorry, but because of this problem and other problems i didn't use Deeplab. In my case i used Mask R-CNN. So unfortunately i don't know the solution for this problem...
So you didn't manage to use DeepLabV3 Plus eventually...
I had a similar problem. Reducing the batch size to one solved the problem for me, but I don't understand why.
I was training on a 1080ti with mobilenet v2 as backbone.
I first explain my task: I have nearly 3000 images with the shape (300,200) from two different ropes. They contain rope 1, rope 2 and the background. My Labels/Masks are images, where for example the pixel value 0 represents the background, 1 represents the first rope and 2 represents the second rope. For DeepLab i converted my ground truth to an image, where each class is stacked into the image. In my case i have 3 classes: rope red, rope blue and the background. So I created one label for my background with the shape (300,200), one for the red rope with the shape (300,200) and one for the blue rope with the same shape. Then i stacked the 3 images into one image, therfore the final label for my NN hast the shape (300,200,3).
You can see the input picture and the 3 labels below. Notice that my ground truth is as i described it above, all the three labels stacked into one image, the values are either 0 or 1.
Now i created a DeepLab model and simply trained my model like in the Keras Tutorial:
So I simply loaded the DeepLab Model, created two generators for my input and my labels by using Keras flow_from_directory function and then used the model.fit_generator function.
My result is a model with over 80% accuracy:
After saving my model, in another Python File i loaded my model to use it for prediction like bonlime showed, but because i have another shape (300,200), i customized it a bit:
My problem is: the label i received as a prediction result is an image full of zeros. I tried it with many images, but the result is still the same. That means that either my prediction code is wrong or my train code. Keras showed that my accuracy is over 80%. Can this be wrong? Or is my customized prediction code wrong?
One problem is that if you have for example 21 classes, DeepLab expect a label with the shape (width,height,21). But Keras flow_from_directory can only read grayscale(width,height,1), RGB (width,height,3) and RGBA(width,height,4), see my post here: https://github.com/bonlime/keras-deeplab-v3-plus/issues/70 Right now i have 3 classes and i pretend that the labels are RGB images, so i got no errors, but maybe this is the problem why i get a high accuracy, but it isn't working...