'Variation in Accuracy when using Image Data Generator and Loading Images individually

I have a CNN model that has already been trained. Its training and validation accuracy are around 99%. I saved this model and then loaded it to make predictions on the test data. The test data consists of 4000 images(2000 in each of the 2 classes) When I used Image data Generator and ran the following code, I was able to get around 99% accuracy.

Code corresponding to the Image data generator

Accuracy when Image Data Generator has been used

But when I tried to make predictions by loading images one after the other, all the images in the negative class were classified correctly but 754 images from the Positive class have been classified incorrectly. This leads to an accuracy of about 81.15%.

Number of images incorrectly classified when loaded individually

I fail to understand why is there a huge drop in the accuracy. For the purpose of my project, I will have to load the images individually and will not be able to use an Image Data Generator. It would be of great help if anyone could let me know, how to improve the accuracy when loading the images individually.



Solution 1:[1]

Simple rule of understanding when your model learn how to catagorize from set of image with high accuracy, it can remember objects learn until simplify for pattern.

I use drop out or signusoids techniques for catagorize problem or simplify image input for possible action.

... Catagorize problem - CIFAR 100

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Martijn Pieters