I have a folder with 25000 images with cats and dogs picture - how to use tf.keras.utils.image_dataset_from_directory?
I am using vats-vs-dogs data set where the subdirectories are not precreated. Only 1 folder with 25000 images. (cat.001.jpg.... etc then dog.342.jpg.... etc) all in one folder. There are no separate folders called /cats or /dogs. How to use
tf.keras.utils.image_dataset_from_directory function in such case ?
Do I need to explicitly compartmentalize all dogs in /dog and all cats into /cats and then do it ?
img_height = 300
img_width = 300
training_dir = 'drive/MyDrive/training1/dog-cat-train/train'
train_ds = tf.keras.utils.image_dataset_from_directory(
training_dir,
labels='inferred',
label_mode='categorical',
color_mode='rgb',
batch_size=batch_size,
validation_split=0.2,
crop_to_aspect_ratio=False,
seed = 123,
subset=training,
image_size=(img_height, img_width))
val_ds = tf.keras.utils.image_dataset_from_directory(
training_dir,
labels='inferred',
label_mode='categorical',
color_mode='rgb',
validation_split=0.2,
subset=validation,
crop_to_aspect_ratio=False,
seed=123,
image_size=(img_height, img_width),
batch_size=batch_size)```
Topic keras tensorflow
Category Data Science