diff --git a/computer_vision/cnn_classification.py b/computer_vision/cnn_classification.py index 115333eba0d1..2cf2de00f982 100644 --- a/computer_vision/cnn_classification.py +++ b/computer_vision/cnn_classification.py @@ -94,7 +94,6 @@ test_image = np.expand_dims(test_image, axis=0) result = classifier.predict(test_image) # training_set.class_indices - if result[0][0] == 0: - prediction = "Normal" - if result[0][0] == 1: - prediction = "Abnormality detected" + # The sigmoid output is a probability in the range [0, 1]. + # Use a threshold of 0.5 to convert the probability into a binary prediction. + prediction = "Normal" if result[0][0] < 0.5 else "Abnormality detected"