Spaces:
Sleeping
Sleeping
File size: 816 Bytes
239017e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | import tensorflow as tf
IMG_SIZE = (224, 224)
BATCH_SIZE = 16
TRAIN_DIR = "dataset/train"
VAL_DIR = "dataset/validation"
TEST_DIR = "dataset/test"
def load_datasets():
train_ds = tf.keras.preprocessing.image_dataset_from_directory(
TRAIN_DIR,
image_size=IMG_SIZE,
batch_size=BATCH_SIZE,
label_mode="binary",
shuffle=True
)
val_ds = tf.keras.preprocessing.image_dataset_from_directory(
VAL_DIR,
image_size=IMG_SIZE,
batch_size=BATCH_SIZE,
label_mode="binary",
shuffle=False
)
test_ds = tf.keras.preprocessing.image_dataset_from_directory(
TEST_DIR,
image_size=IMG_SIZE,
batch_size=BATCH_SIZE,
label_mode="binary",
shuffle=False
)
return train_ds, val_ds, test_ds
|