Skip to content

fix: preserve nearest interpolation for Jina CLIP - #725

Merged
joein merged 2 commits into
qdrant:mainfrom
HuaTNA:fix-jina-nearest-interpolation
Sep 25, 2026
Merged

joein merged 2 commits into
qdrant:mainfrom
HuaTNA:fix-jina-nearest-interpolation

Conversation

@HuaTNA

@HuaTNA HuaTNA commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #724.

Jina CLIP preprocessing rejects interpolation="nearest" and silently changes interpolation=0 / Image.Resampling.NEAREST to bicubic. Pillow's nearest-neighbor enum is zero, so both truthiness checks treat a valid selection as missing.

Use explicit None checks 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

  • Before the fix: pytest -q tests/test_image_transform.py — 4 failed, 18 passed. String nearest modes raise ValueError; integer/enum nearest modes produce incorrect pixels.
  • After the fix: pytest -q tests/test_image_transform.py tests/test_preprocessor_utils.py tests/test_postprocess.py — 54 passed.
  • Ruff 0.3.4 lint and format checks, including repository pre-commit hooks, pass for both changed files.
  • mypy fastembed --disallow-incomplete-defs --disallow-untyped-defs --disable-error-code=import-untyped — no issues in 64 source files.
  • Python 3.11.15, Pillow 12.3.0, NumPy 2.4.6, macOS arm64. The full model/GPU test suite was not run.

All Submissions

  • Followed the contribution guidelines.
  • Checked existing issues and PRs for the same change.
  • Added regression tests and ran the relevant tests locally.
  • Installed and ran the repository pre-commit hooks.

AI assistance (Codex) was used for investigation, implementation, and local test execution.

@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 76bb82a8-3c87-4959-ae38-42f0eb98a0ac

📥 Commits

Reviewing files that changed from the base of the PR and between 8de28b8 and e69f352.

📒 Files selected for processing (2)
  • fastembed/image/transform/operators.py
  • tests/test_image_transform.py

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The 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 None. New tests cover supported interpolation inputs, including nearest-neighbor string, integer, and enum values, and verify that empty or unknown strings raise ValueError.

Estimated code review effort: 2 (Simple) | ~8 minutes

Merge Risk: ⚪ Minimal · up to 690aa

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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: preserving nearest interpolation for Jina CLIP.
Description check ✅ Passed The description directly explains the interpolation bug, the fix, the regression tests, and validation results.
Linked Issues check ✅ Passed The implementation satisfies issue #724. Compose._get_resize now preserves 0 and Image.Resampling.NEAREST and uses bicubic only when interpolation is None. _interpolation_resolver now return…
Out of Scope Changes check ✅ Passed The changes stay within issue #724. They modify interpolation resolution and add focused regression tests for the Jina CLIP image processor. No unrelated production behavior or unrelated files changed…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@joein

joein commented Sep 24, 2026

Copy link
Copy Markdown
Member

Hey @HuaTNA

Thanks for pointing it out and fixing this!

@joein

joein commented Sep 24, 2026

Copy link
Copy Markdown
Member

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.

@joein
joein self-requested a review September 25, 2026 05:37
@joein
joein merged commit 92aa6a5 into qdrant:main Sep 25, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Jina CLIP rejects or ignores nearest-neighbor interpolation

2 participants