Skip to content

[models] Raise a clear error for an empty crop in RecognitionPredictor - #2221

Merged
felixdittrich92 merged 1 commit into
mindee:mainfrom
RavSinghChandan:recognition-empty-crop
Nov 11, 2026
Merged

felixdittrich92 merged 1 commit into
mindee:mainfrom
RavSinghChandan:recognition-empty-crop

Conversation

@RavSinghChandan

Copy link
Copy Markdown
Contributor

Calling a recognition predictor directly with an empty crop (a zero height, width or channel count, e.g. a box that was cropped to nothing) failed deep inside the preprocessing with ZeroDivisionError while splitting or resizing the crop, without saying which input was wrong.

RecognitionPredictor now raises ValueError: incorrect input shape: crops are expected to be non-empty, got shape (0, 20, 3)., next to the existing check on the number of dimensions. ocr_predictor already drops empty crops before recognition, so it is unaffected. Test added (fails on main)

@codecov

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.83%. Comparing base (ca06a62) to head (00cedba).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2221      +/-   ##
==========================================
- Coverage   97.86%   97.83%   -0.04%     
==========================================
  Files         171      171              
  Lines       11774    11777       +3     
==========================================
- Hits        11523    11522       -1     
- Misses        251      255       +4     
Flag Coverage Δ
unittests 97.83% <100.00%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@felixdittrich92 felixdittrich92 self-assigned this Nov 11, 2026
@felixdittrich92 felixdittrich92 added this to the 1.2.0 milestone Nov 11, 2026
@felixdittrich92 felixdittrich92 added type: enhancement Improvement module: models Related to doctr.models ext: tests Related to tests folder topic: text recognition Related to the task of text recognition labels Nov 11, 2026

@felixdittrich92 felixdittrich92 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

@felixdittrich92
felixdittrich92 merged commit 2ab09b2 into mindee:main Nov 11, 2026
56 of 57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ext: tests Related to tests folder module: models Related to doctr.models topic: text recognition Related to the task of text recognition type: enhancement Improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants