qubvel / segmentation_models

Segmentation models with pretrained backbones. Keras and TensorFlow Keras.
MIT License
4.67k stars 1.03k forks source link

Need Assistance for Prediction from image #499

Open akharaphan opened 2 years ago

akharaphan commented 2 years ago

Dear All,

I'm not sure about prediction statement can you help me to correct it ?

X = cv2.imread('/content/download (6).png') model.predict(X)

------------------ ERROR-------------

low:Model was constructed with shape (None, None, None, 3) for input KerasTensor(type_spec=TensorSpec(shape=(None, None, None, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (32, 834, 3).

ValueError: Input 0 of layer stem_conv is incompatible with the layer: : expected min_ndim=4, found ndim=3. Full shape received: (32, 834, 3)

lambdaterm commented 2 years ago

Probably your model requires a batch to perform prediction:

X = cv2.imread('/content/download (6).png')
X = np.expand_dims(X, 0)
model.predict(X)