I am training a fruit classification model. As of right now my classes are: ['Fresh Apples', 'Fresh Bananas', 'Fresh Oranges']
I am using train, validation, and test generators using ImageDataGenerator and flow_from_directory. I have trained the model and am now wanting to feed the test generator into the model to see the performance of the model. Right now I only have 2 images in the test generator. I have the following code to make predictions:
predictions = tuned_model.predict(test_generator)
score = tf.nn.softmax(predictions[0])
print(
'This image most likely belongs to {} with a {:.2f} percent
confidence.'.format(
class_names[np.argmax(score)], 100 * np.max(score)
)
)
And am getting the following as a result:
This image most likely belongs to Fresh Apples with a 46.19 percent confidence.
Yes it is low accuracy, I have only trained for 10 epochs lol. BUT, is there a way I can see which image is being tested? Or a way to know if this prediction is the correct prediction?
EDIT:
Including code of generators...
generator = ImageDataGenerator(
rotation_range=45,
rescale=1./255,
horizontal_flip=True,
vertical_flip=True,
validation_split=.2
)
train_generator = generator.flow_from_directory(
train_path,
target_size=(im_height, im_width),
batch_size = batch_size,
subset='training'
)
validation_generator = generator.flow_from_directory(
train_path,
target_size=(im_height, im_width),
batch_size=batch_size,
subset='validation'
)
test_generator = generator.flow_from_directory(
test_path,
target_size= (im_height, im_width),
batch_size= batch_size,
)
In terms of my class labels, as of right now I simply hard coded them
class_names = ['Fresh Apples', 'Fresh Bananas', 'Fresh Bananas']
I know I should probably import os and create labels based on file structure, but I will do this later unless I absolutely need to.