Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions computer_vision/cnn_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@
test_image = np.expand_dims(test_image, axis=0)
result = classifier.predict(test_image)
# training_set.class_indices
if result[0][0] == 0:
# 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.
if result[0][0] < 0.5:
prediction = "Normal"
if result[0][0] == 1:
else:
prediction = "Abnormality detected"

Check failure on line 102 in computer_vision/cnn_classification.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (SIM108)

computer_vision/cnn_classification.py:99:5: SIM108 Use ternary operator `prediction = "Normal" if result[0][0] < 0.5 else "Abnormality detected"` instead of `if`-`else`-block help: Replace `if`-`else`-block with `prediction = "Normal" if result[0][0] < 0.5 else "Abnormality detected"`
Loading