qubvel / segmentation_models

Segmentation models with pretrained backbones. Keras and TensorFlow Keras.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Call arguments received by layer 'model_18' (type Functional): • inputs=tf.Tensor(shape=(1, 384, 8), dtype=float32) • training=True • mask=None

luizfysouza opened this issue · comments

I'm trying to segment MRI images with the following shape (x_img, y_image, n_slices).

The shape varies from image to image (in number of slices and image size).

I tried to use only 1 image to train just to test if the dimensions are correct, but it returns the following error:

Call arguments received by layer 'model_18' (type Functional): • inputs=tf.Tensor(shape=(1, 384, 8), dtype=float32) • training=True • mask=None

The code used was:

BACKBONE = 'resnet34'
preprocess_input = sm.get_preprocessing(BACKBONE)
model = sm.Unet('resnet34', encoder_weights=None, classes=3, activation='relu', input_shape=(None, None, 10))
model.compile('Adam', loss=sm.losses.bce_jaccard_loss, metrics=[sm.metrics.iou_score])

img = preprocess_input(img)

model.fit( x = img, y = img, batch_size=1, epochs=1, verbose=1)

*Note that i used input_shape (None, None, 8) because the image i tested has shape (276, 384, 8), but other images of the dataset have different number of channels and dimension, but I didn't see any way of using a dataset with images that have different number of channels.

This return the error in the title, is there a way to correct it?