MrGiovanni / UNetPlusPlus

[IEEE TMI] Official Implementation for UNet++
Other
2.26k stars 538 forks source link

getting an error #19

Closed alimsvn closed 5 years ago

alimsvn commented 5 years ago

after running the training model.fit ... I'v got this error : ValueError: Error when checking target: expected sigmoid to have shape (None, None, 1) but got array with shape (256, 256, 3)

mahfuzmohammad commented 5 years ago

You have configured your model to have 1 class as output but your ground truth has 3 channels which are considered as 3 classes. Please use classes parameter to set the correct number of classes.

Or maybe your ground truth has only one class but your ground truth is in RGB. In that case, you need to change it to grayscale.

Hope it helps!

alimsvn commented 5 years ago

Thank you for your prompt reply; My training data and its ground truth are both grayscale and the output is 1 class. When I insert grayscale images and classes parameter is 1 , I receive this error : ValueError: Error when checking input: expected data to have shape (None, None, 3) but got array with shape (128, 128, 1) and when I Convert images to RGB I get the first one. Would you please give me an example of simple loader which loads grayscale png pictures and masks as x_train and y_train or the code you used to convert and save pictures as npy format. Greate Thanks.

jcarta commented 4 years ago

I am having the same issue. My images are (256,256,1) grayscale and I am only predicting foreground vs background.

Here is my error: Error when checking input: expected data to have shape (None, None, 3) but got array with shape (256, 256, 1)

Do we have to update these flags?

def Xnet(backbone_name='vgg16', input_shape=(None, None, 3), input_tensor=None, encoder_weights='imagenet', freeze_encoder=False, skip_connections='default', decoder_block_type='upsampling', decoder_filters=(256,128,64,32,16), decoder_use_batchnorm=True, n_upsample_blocks=5, upsample_rates=(2,2,2,2,2), classes=1, activation='sigmoid'):