I’m using Kaggle with TensorFlow 2.12. This code:
train_ds, val_ds = tf.keras.utils.image_dataset_from_directory(...)
give me this error:
---------------------------------------------------------------------------
InvalidArgumentError Traceback (most recent call last)
Cell In[82], line 77
75 # Addestrare il modello
76 tf.random.set_seed(666)
---> 77 history = model.fit(
78 train_ds,
79 epochs = 300,
80 batch_size = 32,
81 validation_data = val_ds,
82 callbacks = [checkpoint, cos_decay] # reduce_lr_callback
83 )
84 model.evaluate(val_generator) # 69
File /opt/conda/lib/python3.10/site-packages/keras/src/utils/traceback_utils.py:70, in filter_traceback.<locals>.error_handler(*args, **kwargs)
67 filtered_tb = _process_traceback_frames(e.__traceback__)
68 # To get the full stack trace, call:
69 # `tf.debugging.disable_traceback_filtering()`
---> 70 raise e.with_traceback(filtered_tb) from None
71 finally:
72 del filtered_tb
File /opt/conda/lib/python3.10/site-packages/tensorflow/python/eager/execute.py:53, 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:
56 if name is not None:
InvalidArgumentError: Graph execution error:
Unknown image file format. One of JPEG, PNG, GIF, BMP required.
[[{{node decode_image/DecodeImage}}]]
[[IteratorGetNext]] [Op:__inference_train_function_334279]
But with ImageDataGenerator.flow_from_dataframe
don’t give me any error. How to setup tf.keras.utils.image_dataset_from_directory
to avoid this problem.