I used ImageDataGenerator.flow_from_directory() to train and test my model.
When it is training, the accuracy was up to 90%.
But when I test my model, the accuracy was just the average(50%).
This is how I use ImageDataGenerator:
datagen = ImageDataGenerator(rescale=1. / 255)
train_data = datagen.flow_from_directory(img_path + '\\train', target_size=(224, 224),
classes=['NORMAL', 'PNEUMONIA'],
batch_size=10)
test_data = datagen.flow_from_directory(img_path + '\\test', target_size=(224, 224),
classes=['NORMAL', 'PNEUMONIA'],
batch_size=10)
This is how I train and test my model:
model.fit_generator(train_data, steps_per_epoch=32, epochs=100)
test_info = model.evaluate_generator(test_data, steps=10)
print(test_info)
I tried to replace test_data with train_data when test the model.
But the result was identical.