Skip to content

[Python] Tolerate Pillow 13 resize rounding in PyTorch MaskRCNN COCO ITs - #41641

Closed
damccorm wants to merge 1 commit into
apache:masterfrom
damccorm:fix/pytorch-maskrcnn-pillow13-tolerance
Closed

damccorm wants to merge 1 commit into
apache:masterfrom
damccorm:fix/pytorch-maskrcnn-pillow13-tolerance

Conversation

@damccorm

Copy link
Copy Markdown
Contributor

Makes the two COCO MaskRCNN integration tests in pytorch_inference_it_test.py resilient to minor image-resizing rounding differences across Pillow/PyTorch versions:

  • MaskRCNN returns all detections above box_score_thresh=0.05 sorted by score. Pillow 13.0.0 (used by Beam's Python 3.11–3.14 environments) produces a ±1/255 bilinear resize difference on two COCO val2017 images (000000006818.jpg and 000000331352.jpg), which reorders nearly-tied detections and toggles borderline detections near 0.05.
  • Adds _assert_labels_match to compare parsed detection label lists using an exact top-5 match plus >= 0.8 multiset IoU, keeping the assertion meaningful across Pillow 10–13 without mutating the shared GCS golden files used by older release branches.

(Note: the 15 missing COCO val2017 JPEG inputs referenced by gs://apache-beam-ml/testing/inputs/it_coco_validation_inputs.txt have also been restored to gs://apache-beam-ml/datasets/coco/raw-data/val2017/.)

Verification

Part of the stack leading up to re-enabling Python 3.13 inferencePostCommitIT in #41595 (independent of the other prerequisite PRs; can be merged in any order).

MaskRCNN returns all detections above score 0.05 sorted by confidence, so +/-1
pixel bilinear resize rounding differences introduced in Pillow 13.0.0 reorder
nearly-tied detections and toggle borderline detections near 0.05. Compare
parsed label lists using exact top-5 match plus >= 0.8 multiset IoU so tests
remain resilient across Pillow/PyTorch versions without mutating shared GCS
golden files.
@damccorm

Copy link
Copy Markdown
Contributor Author

Replaced by native stacked PR #41646.

@damccorm damccorm closed this Nov 24, 2026
@damccorm
damccorm deleted the fix/pytorch-maskrcnn-pillow13-tolerance branch November 24, 2026 18:17
@github-actions github-actions Bot added python size/s S: 10-49 lines changed labels Nov 24, 2026
@codecov

codecov Bot commented Nov 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.04%. Comparing base (3e230c6) to head (a1f40e4).

Additional details and impacted files
@@            Coverage Diff            @@
##             master   #41641   +/-   ##
=========================================
  Coverage     58.03%   58.04%           
  Complexity     2844     2844           
=========================================
  Files          1210     1210           
  Lines        173259   173280   +21     
  Branches       2329     2329           
=========================================
+ Hits         100554   100583   +29     
+ Misses        69995    69987    -8     
  Partials       2710     2710           
Flag Coverage Δ
python 80.68% <ø> (+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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python size/s S: 10-49 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant