fix(image): respect do_resize=False in ConvNeXT preprocessing - #765
RAMZI0TO99 wants to merge 1 commit into
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthrough
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~12 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to No actionable issue remains; the change is mergeable after normal checks. 🚥 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 |
Compose._get_resize adds ConvNeXT resize operations even when the
configuration explicitly sets do_resize=False. Below a shortest edge of
384 it also adds the associated center crop. A patterned 96 x 160 image
therefore becomes 224 x 224 despite disabled resizing; even an already
224 x 224 image can have its pixels changed.
Return from the ConvNextFeatureExtractor resize branch when do_resize is
false. Keep the default True for omitted flags, preserving the existing
enabled behavior. The return only exits _get_resize, so later array
conversion, rescaling and normalization still execute.
This follows the Hugging Face ConvNeXT contract: resizing is enabled by
default, and do_resize controls both resize and its associated center crop.
See the ConvNextFeatureExtractor documentation
and version-pinned processor source.
Add 25 regression cases covering portrait, landscape and already-sized
patterned images, target sizes 224/384/512, omitted geometry when disabled,
explicitly enabled and default resizing, enabled size validation, later
rescale/normalize steps, and existing CLIP/Siglip flag behavior. Expected
pixels come from original image arrays, independent Pillow resize/crop
references, and a direct normalization formula.
Reproduction, requiring no model download or inference:
Before:
After, matching the expected result:
Environment: Windows 11 build 10.0.26200, Python 3.13.5, NumPy 2.3.5,
Pillow 12.3.0, pytest 9.1.1, FastEmbed 0.8.1 at upstream main commit
7d36728. These checks import the actual
FastEmbed package, rather than copied preprocessing methods.
Validation:
image-transform test file:
python -m pytest tests/test_convnext_do_resize.py tests/test_image_transform.py -qPillow 12.3.0 / pytest 8.4.2.
All Submissions
found in eight complete all-state searches or full file-diff inspection
of all 34 open PRs reviewed. Open fix: preserve ColModernVBERT image patch geometry #760 changes image patch metadata and
fix(image): keep longest-edge resize dimensions nonzero #761 changes longest-edge resizing; neither addresses this flag.