Skip to content

[transforms] Keep the shape of the mask in RandomRotate - #2215

Merged
felixdittrich92 merged 1 commit into
mindee:mainfrom
RavSinghChandan:rotate-mask-shape
Nov 3, 2026
Merged

felixdittrich92 merged 1 commit into
mindee:mainfrom
RavSinghChandan:rotate-mask-shape

Conversation

@RavSinghChandan

Copy link
Copy Markdown
Contributor

RandomRotate added a channel axis to the mask: a (H, W) mask came back as (1, H, W), while every other transform (Resize, RandomCrop, RandomHorizontalFlip, RandomPerspective...) keeps it (H, W). With RandomApply(RandomRotate(...)), a batch then mixes both shapes and torch.stack fails:

RuntimeError: stack expects each tensor to be equal size, but got [16, 16] at entry 0 and [1, 16, 16] at entry 1

The axis added for the rotation is now removed again. The existing test said # Mask should be 2D but asserted the extra axis; it now checks the mask has the image's spatial shape, and keeps the input shape without expansion (fails on main).

@codecov

codecov Bot commented Nov 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.78%. Comparing base (a800f48) to head (a171111).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2215      +/-   ##
==========================================
- Coverage   97.79%   97.78%   -0.01%     
==========================================
  Files         170      170              
  Lines       10997    10998       +1     
==========================================
  Hits        10754    10754              
- Misses        243      244       +1     
Flag Coverage Δ
unittests 97.78% <100.00%> (-0.01%) ⬇️

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 3, 2026
@felixdittrich92 felixdittrich92 added this to the 1.2.0 milestone Nov 3, 2026
@felixdittrich92 felixdittrich92 added type: bug Something isn't working ext: tests Related to tests folder module: transforms Related to doctr.transforms labels Nov 3, 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 ab7b422 into mindee:main Nov 3, 2026
55 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: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants