[Solved] Low accuracy i.e. 52% in predicting whereas the training and validation accuracy during training is around 92%

Mahisha Patel Asks: Low accuracy i.e. 52% in predicting whereas the training and validation accuracy during training is around 92%
I’m using pre-trained VGG19 to train the model. While training I’m getting good accuracy around 92% (both training and validation).

Code:
vgg19 = VGG19(input_shape=IMAGE_SIZE, weights='imagenet', include_top=False)
for layer in vgg19.layers:
    layer.trainable = False

x = Flatten()(vgg19.output)
prediction = Dense(len(folders), activation='softmax')(x)
model = Model(inputs=vgg19.input, outputs=prediction)

model.compile(loss='categorical_crossentropy',
  optimizer=tf.keras.optimizers.Adam(
    learning_rate=0.0005,
    name="Adam"),
  metrics=['accuracy']
)

r = model.fit_generator(
  training_set,
  validation_data=test_set,
  epochs=20,
  steps_per_epoch=len(training_set),
  validation_steps=len(test_set)
)

predictions = model.predict(test_set, steps = test_set.n // 31, verbose=1)

y_pred = []
for i in predictions:
  y_pred.append(int(np.argmax(i)))
y_pred = np.asarray(y_pred)

The accuracy while training can be viewed from here.
Training and Validation Loss and Accuracy

However, while predicting, I’m getting an accuracy of 52.33% only.

Can someone please tell me what am I doing wrong here? Thank you!

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.