Keras: confusion matrix with predict_generator
loaded_model.predict_generator(generator=test_generator)


will give us a set of probabilities 

y_true = test_generator.classes


will give us true labels

Because this is a binary classification problem, you have to find predicted labels. To do that you can use:

y_pred = probabilities &gt; 0.5


Then we have true labels and predicted labels on the test dataset. So, the confusion matrix is given by:

font = {
'family': 'Times New Roman',
'size': 12
}
matplotlib.rc('font', **font)
mat = confusion_matrix(y_true, y_pred)
plot_confusion_matrix(conf_mat=mat, figsize=(8, 8), show_normed=False)