Skip to content

[transforms] Crop an image without any box in crop_detection - #2191

Merged
felixdittrich92 merged 1 commit into
mindee:mainfrom
RavSinghChandan:crop-detection-no-boxes
Oct 30, 2026
Merged

felixdittrich92 merged 1 commit into
mindee:mainfrom
RavSinghChandan:crop-detection-no-boxes

Conversation

@RavSinghChandan

Copy link
Copy Markdown
Contributor

crop_detection and crop_boxes read boxes.max() to tell relative from absolute coordinates, which raises ValueError: zero-size array to reduction operation maximum which has no identity when there is no box, e.g. for an image without any text. RandomCrop avoids it by returning such samples uncropped, and crops a mask with a dummy box.

An empty box array is now returned as is, and the image is still cropped

@codecov

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.72%. Comparing base (9ae237d) to head (0960b46).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2191      +/-   ##
==========================================
- Coverage   97.75%   97.72%   -0.03%     
==========================================
  Files         170      170              
  Lines       10959    10961       +2     
==========================================
- Hits        10713    10712       -1     
- Misses        246      249       +3     
Flag Coverage Δ
unittests 97.72% <100.00%> (-0.03%) ⬇️

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 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 self-assigned this Oct 30, 2026
@felixdittrich92 felixdittrich92 added type: enhancement Improvement ext: tests Related to tests folder module: transforms Related to doctr.transforms labels Oct 30, 2026
@felixdittrich92 felixdittrich92 added this to the 1.2.0 milestone Oct 30, 2026
@felixdittrich92
felixdittrich92 merged commit 2e274dc into mindee:main Oct 30, 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: transforms Related to doctr.transforms type: enhancement Improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants