I have a dataset folder with 22 sub-folders in. Each sub-folder is named according to the class for my classification project, and contain many images (randomly named) for that class.
I have used the following code to import my dataset in to Tensorflow/Keras:
train_ds, val_ds = tf.keras.utils.image_dataset_from_directory(
dataset_path, # path to dataset
validation_split=0.3, # 70/30 split
seed=44, # random seed for reproducibility
shuffle=True, # shuffle the images
subset='both', # return both training and validation datasets
image_size=(img_height, img_width), # set the expected image size
batch_size=batch_size, # how many images per batch
color_mode='grayscale' # rgb or grayscale
)
# Get a list of class names
class_names = train_ds.class_names
num_classes = len(class_names)
I have a separate folder (same structure) with some brand new test images (taken from totally different source) that I’d like to use for testing my model. My question is, if I import my test dataset in the same way, will the class labels be the same?
In other words, does the shuffling only apply to the images within each class folder, or does it also apply to the classes themselves? So if class ‘cat’ is mapped to 0 in the training/val dataset, will it still be mapped to 0 in the test dataset?