Skip to content

[transforms] Keep the shadow base corner when it is rounded onto the tip corner in create_shadow_mask - #2212

Merged
felixdittrich92 merged 1 commit into
mindee:mainfrom
RavSinghChandan:shadow-mask-coinciding-points
Nov 2, 2026
Merged

felixdittrich92 merged 1 commit into
mindee:mainfrom
RavSinghChandan:shadow-mask-coinciding-points

Conversation

@RavSinghChandan

Copy link
Copy Markdown
Contributor

create_shadow_mask (used by RandomShadow) sometimes raised a bare ValueError with no message. After the contour is rotated and rounded to pixels, a corner of the shadow base and the tip corner next to it can land on the same pixel, and expand_line then gets a line of length 0: it has no direction, so no edge point matches and it falls through to raise ValueError.

Running create_shadow_mask with seeds 0-4999 raised it once for a 64x64 image (seed 3074) and 15 times for 8x8, so a long training run with RandomShadow eventually stops on it. expand_line now keeps the first point when both points coincide, and all 45,000 runs over 9 image shapes pass.

Tests: a coinciding line in test_expand_line, and create_shadow_mask with the two failing random draws pinned through monkeypatch, like test_create_shadow_mask_covers_every_direction. They fail on main

@codecov

codecov Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.77%. Comparing base (b690ba9) to head (26486fc).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2212      +/-   ##
==========================================
- Coverage   97.78%   97.77%   -0.02%     
==========================================
  Files         170      170              
  Lines       10993    10995       +2     
==========================================
  Hits        10750    10750              
- Misses        243      245       +2     
Flag Coverage Δ
unittests 97.77% <100.00%> (-0.02%) ⬇️

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