Skip to content

Respect do_normalize=false in legacy image processor configs - #941

Open
Riken0321 wants to merge 1 commit into
qdrant:mainfrom
Riken0321:fix/respect-image-normalization-flag
Open

Riken0321 wants to merge 1 commit into
qdrant:mainfrom
Riken0321:fix/respect-image-normalization-flag

Conversation

@Riken0321

Copy link
Copy Markdown

I reproduced this while checking a local image encoder loaded with specific_model_path. Its preprocessor_config.json explicitly sets do_normalize to false and still contains legacy mean and std entries. FastEmbed applies normalization anyway because the legacy fallback also runs when the option is false.

For example, use a solid RGB image with channel values (64, 128, 192), rescale by 1/256, and set mean to 0.5 and std to 0.25. With normalization disabled the model should see (0.25, 0.5, 0.75). The current processor sends (-1, 0, 1) instead. An ONNX CPU model that reports the channel means confirmed the change through ImageEmbedding.embed.

Check for an explicit false before trying the fallback. Configurations that omit the flag can still opt into legacy normalization by providing mean and std, and the regression includes both that form and modern configs with normalization enabled.

On Windows, the image transform and preprocessor utility suites passed (58 tests). The disabled-normalization case failed on the upstream implementation. Ruff lint and format checks passed.

  • Followed the contributing guidelines.
  • Checked for an existing PR for the same change.

Developed and tested with OpenAI Codex.

If you have questions about this change, you can reach me at huangriken@gmail.com.

@Riken0321
Riken0321 requested a review from joein as a code owner December 4, 2026 03:53
@coderabbitai

coderabbitai Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The normalization helper now skips normalization when do_normalize is explicitly False. Tests cover default normalization, explicitly enabled normalization, and disabled normalization.

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

Change: Bug fix

Merge Risk: Minimal · up to 9bfbe

This change makes image preprocessing respect an explicit do_normalize: false in legacy configs, so legacy mean/std values no longer normalize images. Regression tests cover the default, enabled, and disabled cases, and no merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main behavioral change: legacy image processor configs now respect an explicit do_normalize=false. It matches the raw summary, which says _get_normalize returns early when do_norma…
Description check Passed The description explains the bug, a concrete reproduction with expected and actual pixel values, the fix (check for explicit false before the legacy fallback), and the tests that cover it. It relates …
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.
Full details: Title check

Explanation

The title names the main behavioral change: legacy image processor configs now respect an explicit do_normalize=false. It matches the raw summary, which says _get_normalize returns early when do_normalize is explicitly False, and the PR objectives, which describe checking for an explicit false before the legacy mean/std fallback. The title is short and specific.

Full details: Description check

Explanation

The description explains the bug, a concrete reproduction with expected and actual pixel values, the fix (check for explicit false before the legacy fallback), and the tests that cover it. It relates directly to the changeset in fastembed/image/transform/operators.py and the new test in tests/test_image_transform.py.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · 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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 24f7c235-488f-4993-9f6c-a04d4c5221d6
Commits

Reviewing files that changed from the base of the PR and between ac9ab5c and 9bfbe21.

Files selected for processing: 2

  • fastembed/image/transform/operators.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; 7 remain after this review.

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