PictoPy icon indicating copy to clipboard operation
PictoPy copied to clipboard

BUG: YOLO incorrectly labels Toothbrush (Class ID 79) detections as Unknown

Open onitshubham14 opened this issue 3 weeks ago • 4 comments

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

onitshubham14 avatar Nov 09 '26 04:11 onitshubham14

👋 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 :)

github-actions[bot] avatar Nov 09 '26 04:11 github-actions[bot]

⚠️ Potential Duplicate Issue (Semantic Match)

This issue appears semantically similar to the following issues in AOSSIE-Org/PictoPy:

  1. DOCS: Add missing docstrings to YOLO utility functions Body: (#847, closed) https://github.com/AOSSIE-Org/PictoPy/issues/847 Similarity: 69.5%

  2. 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.

github-actions[bot] avatar Nov 09 '26 04:11 github-actions[bot]

⚠️ Potential Duplicate Issue (Semantic Match)

This issue appears semantically similar to the following issues in AOSSIE-Org/PictoPy:

  1. 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%
  2. 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.

onitshubham14 avatar Nov 09 '26 04:11 onitshubham14

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!

onitshubham14 avatar Nov 15 '26 05:11 onitshubham14