BUG: YOLO incorrectly labels Toothbrush (Class ID 79) detections as Unknown
Is there an existing issue for this?
- [x] I have searched the existing issues
What happened?
Bug Description
The YOLO detection visualization incorrectly labels the last COCO class, "toothbrush" (class ID 79), as "unknown".
The issue is in backend/app/utils/YOLO.py, inside the
YOLO_util_draw_detections() function.
Root Cause
The current condition is:
if score < confidence_threshold or class_id >= len(class_names) - 1:
Since class_names contains 80 classes (indices 0–79), this condition
incorrectly treats class ID 79 as invalid.
Expected Behavior
Class ID 79 should be recognized as "toothbrush".
Actual Behavior
Class ID 79 is displayed as "unknown".
Impact
The issue causes incorrect object labels in the detection visualization for the last category in the COCO class list.
Testing
I reproduced the issue using a unit test with:
- Class ID: 79
- Confidence score: 0.90
Expected output: toothbrush 90%
Actual output: unknown 90%
The test fails with the current implementation.
Record
- [x] I agree to follow this project's Code of Conduct
👋 Thanks for opening this issue! The maintainers will review it shortly. Till then, do not open any PR. This is a strict rule we like to follow around here :)
⚠️ Potential Duplicate Issue (Semantic Match)
This issue appears semantically similar to the following issues in AOSSIE-Org/PictoPy:
-
DOCS: Add missing docstrings to YOLO utility functions Body: (#847, closed) https://github.com/AOSSIE-Org/PictoPy/issues/847 Similarity: 69.5%
-
YOLO and ObjectClassifier fail silently on invalid or unreadable images (#710, open) https://github.com/AOSSIE-Org/PictoPy/issues/710 Similarity: 61.2%
Please review before proceeding.
⚠️ Potential Duplicate Issue (Semantic Match)
This issue appears semantically similar to the following issues in AOSSIE-Org/PictoPy:
- DOCS: Add missing docstrings to YOLO utility functions Body: (DOCS: Add missing docstrings to YOLO utility functions Body: #847, closed) DOCS: Add missing docstrings to YOLO utility functions Body: #847 Similarity: 69.5%
- YOLO and ObjectClassifier fail silently on invalid or unreadable images (YOLO and ObjectClassifier fail silently on invalid or unreadable images #710, open) YOLO and ObjectClassifier fail silently on invalid or unreadable images #710 Similarity: 61.2%
Please review before proceeding.
I reviewed both issues. #847 concerns missing docstrings, while #710 concerns invalid or unreadable images. This issue addresses a separate off-by-one error that incorrectly labels the valid toothbrush class (ID 79) as unknown. Therefore, I believe it is not a duplicate.
hey! @rohan-pandeyy The fix for this issue has been submitted in PR #1719 now the class ID 79 is NOT labelled as unknown and fetch with its original class ID. Thanks!