Unknown image file format. One of JPEG, PNG, GIF, BMP required

getting this error even when all images are in jpg only

history = model.fit(train_ds,epochs=10,validation_data=validation_ds)

Epoch 1/10

InvalidArgumentError Traceback (most recent call last)
in <cell line: 1>()
----> 1 history = model.fit(train_ds,epochs=10,validation_data=validation_ds)

1 frames
/usr/local/lib/python3.10/dist-packages/tensorflow/python/eager/execute.py in quick_execute(op_name, num_outputs, inputs, attrs, ctx, name)
51 try:
52 ctx.ensure_initialized()
—> 53 tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
54 inputs, attrs, num_outputs)
55 except core._NotOkStatusException as e:

InvalidArgumentError: Graph execution error:

Detected at node decode_image/DecodeImage defined at (most recent call last):

Unknown image file format. One of JPEG, PNG, GIF, BMP required.
[[{{node decode_image/DecodeImage}}]]
[[IteratorGetNext]] [Op:__inference_train_function_2683]

Hi @Harsh_Shinde Welcome to the Tensorflow Forum ,

The error message you’re encountering indicates that there’s an issue with decoding the image files during the training process. It seems like TensorFlow is unable to determine the format of the image files, even though you’ve confirmed that all images are in JPEG format.

Here are a few steps you can take to troubleshoot this issue:

  1. Verify Image Formats :Sometimes, there might be a few files that are mislabeled or corrupted, causing TensorFlow to fail during decoding.

  2. Check File Paths:Ensure that the file paths provided to TensorFlow’s dataset API are correct and that they point to the directory containing the JPEG image files.

  3. TensorFlow Version Compatibility : Verify that your TensorFlow version is compatible with the JPEG decoding functionality. It’s rare, but there could be compatibility issues between TensorFlow versions that affect image decoding.

Thank You !