yingkaisha/keras-unet-collection

How to use the exemple given using Unet3p on Oxford Pet dataset with a dataset containing gray images

hubsilon opened this issue · 1 comments

Dear all,

I hope you're going well.

I would like to use the given exemple using Unet3p on Oxford Pet dataset with a dataset containing gray images as input (masks have 3 labels, namely 1 2 3).

I tried without changing anything, as if the gray image were rgb images, Here is the error:
ValueError: Dimensions must be equal, but are 1048576 and 1572864 for '{{node hybrid_loss/mul}} = Mul[T=DT_FLOAT](hybrid_loss/Reshape, hybrid_loss/Reshape_1)' with input shapes: [1048576], [1572864].

The error lies in the line:
# train on batch
loss_ = unet3plus.train_on_batch([train_input,],
[train_target, train_target, train_target, train_target, train_target,])

Then I tried by changing the input_size from (128, 128, 3) to (128, 128, 1) and changing as well channel=3 to channel=1 but it did not work as well. Same Error, same line.

I would appreciate your help on this matter and/or the best way to use this script on gray images.

best regards

Try to have a look at this example (lines 8-10):
https://github.com/yingkaisha/keras-vision-transformer/blob/main/examples/Swin_UNET_oxford_iiit.ipynb

I think you have used n_labels equals for input and output layers. If so, you need to have hot-encoded mask.