PictoPy icon indicating copy to clipboard operation
PictoPy copied to clipboard

BUG: Unreadable images interrupt the entire AI-tagging process

Open onitshubham14 opened this issue 3 weeks ago • 2 comments

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

  1. Application retrieves multiple untagged images from the database.
  2. YOLO processes images sequentially.
  3. One image is corrupt or unreadable.
  4. get_classes() returns None.
  5. len(None) raises a TypeError.
  6. The entire tagging batch terminates.
  7. 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

onitshubham14 avatar Nov 11 '26 10: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 11 '26 10:11 github-actions[bot]

⚠️ Potential Duplicate Issue (Semantic Match)

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

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

  2. YOLO and ObjectClassifier fail silently on invalid or unreadable images (#710, open) https://github.com/AOSSIE-Org/PictoPy/issues/710 Similarity: 74.3%

  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.

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