Getting the data labels from ImageDataGenerator.flow_from_directory() for all batches

I am using an ImageDataGenerator with the method flow_from_directory() to grab the images for my CNN. According to the documentation flow_from_directory() returns a tuple (x, y) where x is the data and y the labels for every item in the batch.

I tried to get the labels of every batch with the next() method and a loop but received the ValueError: too many values to unpack (expected 2).

What’s the recommended way to get all the matching labels for every image? I couldn’t find anything online except the approach with next(), which only worked for a single batch without a loop.


test_datagen = ImageDataGenerator(rescale=1./255) test_df = test_datagen.flow_from_directory( path, target_size=(512, 512), batch_size=32, class_mode='categorical') y = [] steps = test_df.n//32 #My approach that wasn't working for i in range(steps): a, b = y.extend(b) 

submitted by /u/obskure_Gestalt
[visit reddit] [comments]

Leave a Reply

Your email address will not be published. Required fields are marked *