Fix clipping boxes with large coordinates - #9047
Conversation
Signed-off-by: Rajioba1 <raji.lukmon@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/data/test_box_utils.py (1)
273-285: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a docstring to the new test.
test_large_coordinates_are_not_droppedis a new Python definition without a docstring.Proposed fix
def test_large_coordinates_are_not_dropped(self): + """Verify large coordinates survive cropping and image clipping."""As per path instructions, every Python definition must have a Google-style docstring.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/data/test_box_utils.py` around lines 273 - 285, Add a Google-style docstring to the test_large_coordinates_are_not_dropped test method describing that large-coordinate bounding boxes remain preserved by spatial cropping and image clipping.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/data/test_box_utils.py`:
- Around line 273-285: Add a Google-style docstring to the
test_large_coordinates_are_not_dropped test method describing that
large-coordinate bounding boxes remain preserved by spatial cropping and image
clipping.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 36d185bf-9b8e-4507-8de0-75c9c2397077
📒 Files selected for processing (2)
monai/data/box_utils.pytests/data/test_box_utils.py
Signed-off-by: Rajioba1 <raji.lukmon@gmail.com>
Fixes #9045.
Description
spatial_crop_boxesconverted crop ROI bounds totorch.int16, which overflows for coordinates above 32767. This could cause valid boxes in large images to be clamped incorrectly and silently removed whenremove_empty=True.This PR keeps the ROI bounds in the same tensor dtype as the boxes during clipping and adds a regression test covering both
spatial_crop_boxesand the publicclip_boxes_to_imagepath for large coordinates.Types of changes
./runtests.sh -f -u --net --coverage../runtests.sh --quick --unittests --disttests.make htmlcommand in thedocs/folder.Local validation:
python -m tests.data.test_box_utilspython -m ruff check monai/data/box_utils.py tests/data/test_box_utils.pyblackandisortwere not installed in my local Python environment, so I could not run those checks directly.