BUG: Unreadable images interrupt the entire AI-tagging process
Is there an existing issue for this?
- [x] I have searched the existing issues
What happened?
Description
The AI-tagging process can terminate unexpectedly when PictoPy encounters an image that OpenCV cannot load or decode(corrupt or unsupported image).
In ObjectClassifier.get_classes() (backend/app/models/ObjectClassifier.py), cv2.imread() returns None when an image cannot be loaded. However, image_util_classify_and_face_detect_images() (backend/app/utils/images.py) directly calls len(classes) without checking for None, resulting in a TypeError that interrupts the entire tagging batch.
Expected Behaviour
- Unreadable images should be logged and skipped.
- Their isTagged status should remain False.
- Processing should continue with the remaining images.
- Successfully processed images with no detections should still be marked as tagged.
Actual behaviour
- Application retrieves multiple untagged images from the database.
- YOLO processes images sequentially.
- One image is corrupt or unreadable.
- get_classes() returns None.
- len(None) raises a TypeError.
- The entire tagging batch terminates.
- Remaining images are not processed during that run.
Why Does This Matter? A single unreadable image can prevent an entire batch of otherwise valid images from receiving AI-generated tags. Handling such failures individually would improve the reliability and stability of PictoPy's AI-tagging pipeline.
Proposed Solution Handle the None return value before accessing len(classes). Skip the unreadable image and continue processing the remaining images.
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:
-
BUG: AI tagging aborts entire batch when encountering a corrupt/unreadable image (#1496, open) https://github.com/AOSSIE-Org/PictoPy/issues/1496 Similarity: 86.5%
-
YOLO and ObjectClassifier fail silently on invalid or unreadable images (#710, open) https://github.com/AOSSIE-Org/PictoPy/issues/710 Similarity: 74.3%
-
BUG: AI tagging hangs indefinitely when an image fails to load, blocking subsequent tagging jobs (#1444, open) https://github.com/AOSSIE-Org/PictoPy/issues/1444 Similarity: 74%
Please review before proceeding.