I have a keras model trained to classify images. Since I want to predict a lot of new images (about 100k) I think the usage of a generator is the fastest way.
from keras.preprocessing.image import ImageDataGenerator
# Set up my generator
datagen = ImageDataGenerator(rescale=1./255)
test_generator = datagen.flow_from_directory(
r"C:\new_data",
target_size=(260, 180),
batch_size=100,
color_mode="grayscale",
class_mode="categorical",
)
predicted_elements = model.predict(test_generator, batch_size=10, verbose="auto", steps=None, callbacks=None)
What I need is a table, to see which image belongs to which (predicted) class. Like:
filename | predicton |
---|---|
1.jpg | coffee |
2.jpg | car |
3.jpg | plane |
... | ... |
Edit: My Question is: How can I create this table? The generator resorts the images anyway. Also I don't know how to get the names.