Cat and Dog Classifier: empty test set

Even after I have properly use the image generator for the test data set, my ‘test_data_gen’ shows the message ‘found 0 images corresponding to 0 classes.’ I have already checked whether the test_dir is empty but by printing its lenght it shows 50 elements as expected. Has anybody come with a solution to that?

Share your code so that people can help.

I have tried changing the parameters but nothing helps

Have a look at the folder structure:

  1. Each directory has a folder for each class.
  2. The test folder inside PATH has the images and does not have any subfolders.

image

Since there are no folders inside test, you are getting 0 images with 0 classes.

test_data_gen = test_image_generator.flow_from_directory(
    directory = PATH,
    classes = ['test'], 
    target_size = (IMG_HEIGHT, IMG_WIDTH),
    batch_size = batch_size,
    shuffle = False,
)
1 Like

Thanks, that really worked! I tried alternatively creating a subdirectory (as shown in many other fora) and moving the images to it but it messed up the evaluation at the end. Your solution was much more elegant.

I was having a hard time trying to edit the file structure on google colab since I couldn’t find where the dataset was downloaded. Your implementation is much more efficient, thank you.