Repository navigation
fix: preserve nearest interpolation for Jina CLIP - #725
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe interpolation resolver now distinguishes an unresolved value from a valid falsy Pillow resampling value. The Jina CLIP resize fallback selects bicubic only when interpolation is Estimated code review effort: 2 (Simple) | ~8 minutes Merge Risk: ⚪ Minimal · up to The change preserves nearest-neighbor resizing for the reported inputs without changing the default. No merge-blocking issue is identified. 🚥 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 |
|
Hey @HuaTNA Thanks for pointing it out and fixing this! |
|
Though, I decided to remove the tests, since this path has actually never been hit. Jina's model uses bicubic, and it's the only model which uses this processing path. |
Description
Fixes #724.
Jina CLIP preprocessing rejects
interpolation="nearest"and silently changesinterpolation=0/Image.Resampling.NEARESTto bicubic. Pillow's nearest-neighbor enum is zero, so both truthiness checks treat a valid selection as missing.Use explicit
Nonechecks for the string lookup and numeric fallback. Other interpolation modes, the bicubic default, and rejection of invalid names are preserved.Add pixel-level tests through
Compose.from_config, comparing a resized checkerboard with Pillow's reference result. Coverage includes string and mixed-case names, zero and enum inputs, every other supported string mode, the default, and invalid names. No model download is needed for the new tests.Validation
pytest -q tests/test_image_transform.py— 4 failed, 18 passed. String nearest modes raiseValueError; integer/enum nearest modes produce incorrect pixels.pytest -q tests/test_image_transform.py tests/test_preprocessor_utils.py tests/test_postprocess.py— 54 passed.mypy fastembed --disallow-incomplete-defs --disallow-untyped-defs --disable-error-code=import-untyped— no issues in 64 source files.All Submissions
AI assistance (Codex) was used for investigation, implementation, and local test execution.