Convert images to tensor

Hi, I am trying to train this model:

model.fit(X_train,
y_train,
batch_size=59,
epochs=50)

But I keep getting this error:
ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type tensorflow.python.framework.ops.EagerTensor).

The problem seems to be the format of the images I am trying to feed the model.
Does anyone had a similar problem and can help?

To convert images to tensor you can use tf.image.convert_image_dtype.

model.fit expects input data could be:

  • A Numpy array (or array-like), or a list of arrays (in case the model has multiple inputs).
  • A TensorFlow tensor, or a list of tensors (in case the model has multiple inputs).
  • A dict mapping input names to the corresponding array/tensors, if the model has named inputs.

Thank you.