Skip to content

fix(image): keep longest-edge resize dimensions nonzero - #761

Merged
joein merged 3 commits into
qdrant:colmodernvbert-fixesfrom
JesusMan0529:fix/nonzero-image-resize
Oct 6, 2026
Merged

joein merged 3 commits into
qdrant:colmodernvbert-fixesfrom
JesusMan0529:fix/nonzero-image-resize

Conversation

@JesusMan0529

Copy link
Copy Markdown
Contributor

A 4096 x 1 or 1 x 4096 image resized to a longest edge of 2048 currently truncates its shorter edge to zero. Pillow raises ValueError: height and width must be > 0, including when the image goes through ColModernVBERT's Idefics3 preprocessing.

Clamp the final resize dimensions to at least one pixel, matching Idefics3's reference behavior. Tests cover both orientations, existing even rounding and ordinary images, plus the real Compose pipeline with image splitting, rescaling and normalization.

Validation:

  • The added image tests on an immutable copy of the original package: 4 failed, 15 passed; the four failures reproduce the zero-dimension exception.
  • pytest tests/test_image_transform.py tests/test_common.py tests/test_postprocess.py::test_empty_multivectors_raise_value_error -q: 27 passed.
  • Pinned pre-commit hooks on both changed files, repository-wide Ruff lint, the CI mypy command, pyright tests/type_stub.py, and git diff --check: passed.
  • Repository-wide ruff format --check . reports three unchanged files (experiments/attention_export.py, experiments/try_attention_export.py, tests/test_postprocess.py); both modified files pass formatting. The full model-download/inference suite was not completed locally.

All submissions:

Copilot AI balanced review requested due to automatic review settings October 3, 2026 10:15
@JesusMan0529
JesusMan0529 requested a review from joein as a code owner October 3, 2026 10:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

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
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 413bda9b-1926-4d2a-a87d-f33f53957046
📥 Commits

Reviewing files that changed from the base of the PR and between b002a50 and 06e4cce.

📒 Files selected for processing (2)
  • fastembed/image/transform/functional.py
  • tests/test_image_transform.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • fastembed/image/transform/functional.py
  • tests/test_image_transform.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

resize_longest_edge clamps each resized dimension to at least one pixel. Tests check the 2048-pixel longest-edge cap, nonzero output dimensions, even-rounded dimensions, and Idefics3 preprocessing for very thin images.

Priority: ➖ Normal

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

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 06e4c

The thin-image resize fix has no identified merge-blocking issue. Normal checks remain appropriate before merging.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: preventing longest-edge resizing from producing zero-sized dimensions.
Description check ✅ Passed The description explains the zero-dimension issue, the fix, the tests, and the reported validation results. It is directly related to the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@JesusMan0529

Copy link
Copy Markdown
Contributor Author

Reproduced the crash in both orientations (4096 x 1 and 1 x 4096) using the real ColModernVBERT preprocessing config. The original package fails four regression cases; after the fix, the shorter edge stays at one pixel and preprocessing produces five normalized 3 x 512 x 512 patches per image. The dimensions also match the Idefics3 reference.

Local validation: 27 related tests passed, both pinned pre-commit hooks passed, repository-wide Ruff lint and the CI mypy/pyright commands passed. The root formatting check reports three unchanged files; full model-download/inference tests were not completed locally.

@JesusMan0529

Copy link
Copy Markdown
Contributor Author

Added concise docstrings to resize_longest_edge and both new regression-test functions to address the docstring-coverage warning. This follow-up adds only three docstring lines; comparing the executable AST before and after confirms that behavior is unchanged. The 27 related tests and both pinned Ruff pre-commit hooks pass again.

@JesusMan0529

Copy link
Copy Markdown
Contributor Author

Hope it could be merged 😊

@joein
joein changed the base branch from main to colmodernvbert-fixes October 6, 2026 14:46
@joein

joein commented Oct 6, 2026

Copy link
Copy Markdown
Member

thank you for the fix!

@joein
joein merged commit 421b000 into qdrant:colmodernvbert-fixes Oct 6, 2026
5 checks passed
joein added a commit that referenced this pull request Oct 7, 2026
…t queries via model_v2.onnx (#784)

* tests: check ColModernVBERT mixed-size batches against the re-exported test model

* tests: add tmp test script

* tests: probe whether onnxruntime 1.18 crashes on the published ColModernVBERT on Windows too

* tests: drop onnxruntime 1.18 and the probe job from the temporary ColModernVBERT check

* fix: build ColModernVBERT image prompts from the actual tile grid

Co-authored-by: Hulk <happyhls@gmail.com>

* fix(image): keep longest-edge resize dimensions nonzero (#761)

* fix(image): keep longest-edge resize dimensions nonzero

* docs(image): document resize behavior and regression tests

* tests: drop the extra tests and docstring from the nonzero resize fix

---------

Co-authored-by: George Panchuk <george.panchuk@qdrant.tech>

* fix: send ColModernVBERT text queries without image tiles and warn that the model was updated

* tests: run the ColModernVBERT query test on all platforms and drop the temporary CI check

* fix: switch ColModernVBERT to model_v2.onnx, avoid an empty tensor on CUDA, drop padding rows and lower the default image batch size

* fix: set qdrant hf account as model source for colmodernvbert

---------

Co-authored-by: Hulk <happyhls@gmail.com>
Co-authored-by: Li Haodong <1638272030@qq.com>
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.

3 participants