Fix cnn prediction (#14904)

* Fix CNN prediction threshold for binary classification

* Use ternary operator for binary prediction

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
This commit is contained in:
ParikshitGupta2605
2026-09-12 23:27:26 +02:00
committed by GitHub
co-authored by Christian Clauss
parent 2f4a9fe998
commit 242bd232a9
+3 -4
View File
@@ -94,7 +94,6 @@ if __name__ == "__main__":
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"