Skip to content

test: cover image transform helpers used by Idefics3 and Jina CLIP preprocessing - #785

Open
Aditya17-bot wants to merge 1 commit into
qdrant:mainfrom
Aditya17-bot:test/image-transform-ops
Open

Aditya17-bot wants to merge 1 commit into
qdrant:mainfrom
Aditya17-bot:test/image-transform-ops

Conversation

@Aditya17-bot

Copy link
Copy Markdown

Adds unit tests for the image transform helpers that only ran through model tests (which download weights): pad2square, crop_ndarray, resize_ndarray, ResizeForVisionEncoder, ImageSplitter and SquareResize. They are used by Jina CLIP (PadtoSquare) and ColModernVBERT (Idefics3 resizing and splitting).

What the tests pin:

  • pad2square: a smaller image is pasted top-left on the fill color; a larger one is center-cropped with round-half-to-even offsets (7 -> 2, 9 -> 2), matching the torchvision note in the code.
  • crop_ndarray: channel-first and channel-last crops agree.
  • resize_ndarray: size is (width, height), the layout stays (C, H, W), uint8 stays uint8, and float images stay in [0, 1].
  • ResizeForVisionEncoder: landscape, portrait, smaller-than-one-tile and exact-tile inputs round up to multiples of the tile size, with the same sizes as resize_for_vision_encoder in transformers' Idefics3 image processor.
  • ImageSplitter: small images pass through untouched; larger ones give rows * cols tiles in row order plus a 512x512 global view; per-image grouping is kept.
  • SquareResize: each image is wrapped in its own list at size x size.

ImageSplitter is only tested on multiples of the tile size, since ResizeForVisionEncoder always runs first. For other sizes it splits into evenly sized patches, whereas transformers' current split_images takes fixed tiles, so I didn't want to pin that path.

The tests are in a new file so they don't conflict with #760 and #761, which both edit tests/test_image_transform.py. I left resize_longest_edge out because #761 covers it.

Coverage from tests/test_image_transform.py alone vs. with the new file:

  • functional.py: 57% -> 82%
  • operators.py: 43% -> 62%
$ pytest tests/test_image_transform_ops.py tests/test_image_transform.py
29 passed
$ ruff format --check / ruff check: clean
  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Does your submission pass the existing tests?

…eprocessing

pad2square, crop_ndarray, resize_ndarray, ResizeForVisionEncoder,
ImageSplitter and SquareResize had no unit tests; they were only reached
through model tests that download weights. Expected sizes follow the
Idefics3 image processor in transformers.
@Aditya17-bot
Aditya17-bot requested a review from joein as a code owner October 6, 2026 17:18
@coderabbitai

coderabbitai Bot commented Oct 6, 2026

Copy link
Copy Markdown

Review in Change Stack →

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: 65846d75-3e03-499a-8e80-de61ced4d165
📥 Commits

Reviewing files that changed from the base of the PR and between c0588ac and 8f3072a.

📒 Files selected for processing (1)
  • tests/test_image_transform_ops.py

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


📝 Walkthrough

Walkthrough

The change adds tests for image padding, cropping, and resizing, including channel layouts and output dtype expectations. It adds assertions for vision-encoder dimensions, image-splitting tile contents and counts, per-image grouping, and SquareResize frame shapes. It does not change production code.

Priority: ⬇️ Low

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

Change: Other

Merge Risk: ⚪ Minimal · up to 8f307

No merge-blocking issue is identified; merge after normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 1 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 summarizes the main change: adding tests for image transform helpers used in Idefics3 and Jina CLIP preprocessing.
Description check ✅ Passed The description explains which image transform helpers the tests cover and summarizes the tested behavior and reported validation results.
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.
  • Fix all pre-merge checks with AI
✨ 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.

This branch has not been deployed

No deployments
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.

1 participant