You can use image_dataset_from_directory for this where you just have to pass in the path to the files in the argument directory
.
from tensorflow.keras.preprocessing import image_dataset_from_directory
train_dataset = image_dataset_from_directory(
directory=TRAIN_DIR,
labels="inferred",
label_mode="categorical",
image_size=SIZE,
seed=SEED,
subset=None,
interpolation="bilinear",
follow_links=False,
)
validation_dataset = image_dataset_from_directory(
directory=VALIDATION_DIR,
labels="inferred",
label_mode="categorical",
image_size=SIZE,
seed=SEED,
subset=None,
interpolation="bilinear",
follow_links=False,
)
test_dataset = image_dataset_from_directory(
directory=TEST_DIR,
labels="inferred",
label_mode="categorical",
image_size=SIZE,
seed=SEED,
subset=None,
interpolation="bilinear",
follow_links=False,
)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…