The title is pretty much it. For a bit of context, I've been tinkering with ImageNet and pretrained models lately, and I'd like to retrain some of those with different parameters. Training dataset didn't pose a problem since all classes are in independent folders, so tf/keras can label them seamlessly. Problem is, I can't seem to setup my validation dataset's labels. I have them in a .txt file but the output I get when I try to setup the dataset is always
Found 50000 files belonging to 1 classes.
When I should get 1000 classes. I precise, the val dataset is just a single folder containing 50,000 photos
My code is the following
path_val = './ILSVRC/Data/val/'
path_val_labels = './ILSVRC/Data/val.txt'
val_labels = list(np.loadtxt(path_val_labels).astype(int))
val_dataset_224 = tf.keras.utils.image_dataset_from_directory(
path_val,
labels=val_labels,
image_size=(224, 224),
batch_size=32,
color_mode='rgb',
shuffle=True,
seed=None,
validation_split=None,
subset=None,
interpolation='bilinear',
follow_links=False,
crop_to_aspect_ratio=False)
The .txt that I'm loading is just the sorted list of classes of the images in the validation dataset, so it's just 50,000 lines going
391
819
...
186
And the list I created from it has a len of 50,000 integers so the problem does not seem to come from there. I've tried using other formats, to no avail. The tensorflowkeras.utils.image_dataset_from_directory documentation mentions on the 'labels' argument
Either "inferred" (labels are generated from the directory structure), None (no labels), or a list/tuple of integer labels of the same size as the number of image files found in the directory. Labels should be sorted according to the alphanumeric order of the image file paths (obtained via os.walk(directory) in Python).
Which is what I think I'm doing. I'm at my wits' end, so I turn to you - thank you for your time !