You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Respect do_normalize=false in legacy image processor configs - #941
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.
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.
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: 4
Check name
Status
Explanation
Title check
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
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
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
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.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
Developed and tested with OpenAI Codex.
If you have questions about this change, you can reach me at huangriken@gmail.com.