zizhaozhang / unet-tensorflow-keras

A concise code for training and evaluating Unet using tensorflow+keras
MIT License
186 stars 72 forks source link

Evaluation dataset - format/path ? #9

Closed nanodust closed 6 years ago

nanodust commented 6 years ago

Hello,

Thanks for sharing your code !

I was able to use cityscapes dataset and train (just doing 2 classes for start).

However, during evaluation - on any jpg (either a jpg of training data, or new image)

python eval.py --data_path ./eval --load_from_checkpoint ./checkpoints/unet_example/model-146 --batch_size 1

I always get the exact same error:

ValueError: Input 0 of layer conv1_1 is incompatible with the layer: expected ndim=4, found ndim=3. Full shape received: [None, 256, 256]

(full trace here - https://pastebin.com/Rjzt5N7V )

it seems as if nothing I do can avoid that error.

I'll keep at it - but if anything comes to mind, appreciate any tips or ideas meanwhile.

Thanks again !

nanodust commented 6 years ago

aha - as suspected, this is a rather cryptic 'image not found' error... i get it even when there are no images in the folder :)

We know that the train/test format is :

per  loader.py:  If you have multiple labels.
You can organize the img and gt in this way. The following examples has 3 labels.
    Use the Keras data generators to load train and test
    Image and label are in structure:
        train/
            img/
                0/
                1/
                2/
            gt/
                0/
                1/
                2/
        test/
            img/
                0/
                1/
                2/
            gt/
                0/
                1/
                2/

yet - what of evaluate organization? we can see from loader that:

    im_path = os.path.join(data_path, 'img/0/')   
    gt_path = os.path.join(data_path, 'gt/0/')       
    im_list = glob.glob(im_path + '*.jpg')

evaluation images are in /img/0/*.jpg

yet even when images are there, I get the same 'zero' / null input0 loader error, above.

nanodust commented 6 years ago

i'm giving up, i can't get evaluation to work. moving to other implementation.

zizhaozhang commented 6 years ago

Sorry for the confusion. I have updated the code to solve the issue. Now it has unique dataLoader and better support multiclass segmentation.

nanodust commented 6 years ago

that is an impressive update ! I quick re-trained and evaluated - fact is, I fear you've made it harder for single-class inference (if you care) - I had gone down to one class when I couldn't get N>1 to work, but I had to go back to N=2 for training to work after this update. Furthermore, I got errors in utils.py - meanIU_per_class was not iterable, it's a (numpy float?) - np.ndenumerate(meanIU_per_class) worked for line 62 ,but then the for loop won't work...

This may all be a result of my own data setup at this point - I thought I was doing the right thing by putting per-class masks/image/gt (0 = car, 1=people) but I may have just not done so correctly. So I am not giving a DIFF as i don't know what my problems are, vs how your code is supposed to work.

but thanks again for sharing the code - very clean model.py , and at this point I have a nice intro to online image transformation w/ keras :)

zizhaozhang commented 6 years ago

@nanodust Hi I realized that you made a mistake on separating the class of masks. That is not necessary. The only case you need to separate image or mask to different folder, 0/ , 1/, is if your image has an image label and you want that information. Otherwise, put all image/mask in 0/.

nanodust commented 6 years ago

interesting ! ok I'll give it another shot....