I'm trying to use a Convolutional Neural Network (CNN) to predict the classes of the test images, as follows:
for root, dirs, files in os.walk(test_directory):
for file in files:
img = cv2.imread(root + '/' + file)
img = cv2.resize(img,(512,512),interpolation=cv2.INTER_AREA)
img = np.expand_dims(img, axis=0)
img = img/255.0
if os.path.basename(root) == 'nevus':
label = 1
elif os.path.basename(root) == 'melanoma':
label = 0
labels.append(label)
img_class = model.predict_classes(img)
img_class_probability = model.predict(img)
prediction_probability = img_class_probability[0]
prediction_probabilities.append(prediction_probability)
prediction = img_class[0]
if prediction == label:
correct_classification = correct_classification + 1
number_of_test_images = number_of_test_images + 1
fpr, tpr, thresholds = roc_curve(labels, prediction_probabilities)
auc_value = auc(fpr, tpr)
I would like to ask why am I always having AUC = 0.5? Maybe I'm doing something wrong?
Thanks.