Skip to content

fix(image): respect do_resize=False in ConvNeXT preprocessing - #765

Closed
RAMZI0TO99 wants to merge 1 commit into
qdrant:mainfrom
RAMZI0TO99:fix/convnext-do-resize
Closed

RAMZI0TO99 wants to merge 1 commit into
qdrant:mainfrom
RAMZI0TO99:fix/convnext-do-resize

Conversation

@RAMZI0TO99

Copy link
Copy Markdown
Contributor

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:

import numpy as np
from PIL import Image
from fastembed.image.transform.operators import Compose

pixels = (
    np.arange(96 * 160 * 3, dtype=np.uint32).reshape(96, 160, 3) % 251
).astype(np.uint8)
processor = Compose.from_config({
    "image_processor_type": "ConvNextFeatureExtractor",
    "do_resize": False,
    "size": {"shortest_edge": 224},
    "do_rescale": False,
    "do_normalize": False,
})
output = processor([Image.fromarray(pixels)])[0]
expected = pixels.transpose(2, 0, 1)
print("Expected shape:", expected.shape)
print("Actual shape:  ", output.shape)
print("Pixels preserved:", np.array_equal(output, expected))

Before:

Expected shape: (3, 96, 160)
Actual shape:   (3, 224, 224)
Pixels preserved: False

After, matching the expected result:

Expected shape: (3, 96, 160)
Actual shape:   (3, 96, 160)
Pixels preserved: True

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:

  • Before: 11 new cases failed and 14 passed.
  • After: all 36 cases pass on Python 3.13.5, including the entire existing
    image-transform test file:
    python -m pytest tests/test_convnext_do_resize.py tests/test_image_transform.py -q
  • All 25 new cases also pass cleanly on Python 3.10.11 / NumPy 2.2.6 /
    Pillow 12.3.0 / pytest 8.4.2.
  • Ruff 0.3.4 lint/format and whitespace checks pass.
  • Model inference and the full model-download suite were not run locally.

All Submissions

@RAMZI0TO99
RAMZI0TO99 requested a review from joein as a code owner October 3, 2026 15:22
@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: c51425a2-786c-4299-a123-56f9a4d8614d
📥 Commits

Reviewing files that changed from the base of the PR and between 7d36728 and 27077dd.

📒 Files selected for processing (2)
  • fastembed/image/transform/operators.py
  • tests/test_convnext_do_resize.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

Compose._get_resize now skips resize processing for ConvNextFeatureExtractor when do_resize is false. When the setting is absent, resizing remains enabled by default. Tests cover ConvNext resize outputs, invalid size settings, rescaling and normalization with resizing disabled, and CLIP and SigLIP resize-flag behavior.

Priority: ⬇️ Low

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

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 27077

No actionable issue remains; the change is mergeable after normal checks.

🚥 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 8 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 summarizes the main change: ConvNeXT preprocessing now respects do_resize=False.
Description check ✅ Passed The description explains the bug, the fix, and the regression tests. It directly relates to the changeset.
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.

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