Fix deprecated max_size parameter handling in DETR image processors#39046
Open
nck90 wants to merge 6 commits intohuggingface:mainfrom
Open
Fix deprecated max_size parameter handling in DETR image processors#39046nck90 wants to merge 6 commits intohuggingface:mainfrom
nck90 wants to merge 6 commits intohuggingface:mainfrom
Conversation
Fixes huggingface#37939 The deprecated max_size parameter was incorrectly overriding the size parameter completely instead of being properly handled. This affected both ConditionalDetrImageProcessor and DetrImageProcessor. Changes: - Fixed __init__ method to properly handle max_size parameter by setting longest_edge when size dict doesn't have it, instead of replacing size - Fixed preprocess method to handle max_size parameter correctly - Added max_size as explicit parameter to __init__ for proper from_dict support - Added comprehensive tests for max_size parameter handling The fix ensures backward compatibility while properly deprecating the max_size parameter in favor of size['longest_edge'].
- Fix whitespace and trailing spaces detected by ruff - Apply black code formatting - Ensure all code quality checks pass
- Fix runtime error: ensure longest_edge is always present in size dict - Fix ruff formatting issues - Fix check_copies.py consistency by updating DeformableDetr as well - Properly handle max_size parameter in all DETR image processors
- Fix max_size parameter handling in preprocess method to match DETR ImageProcessor - Ensure consistency across all DETR image processors - This should resolve the check_copies.py validation error
- Fix __init__ method: Remove hardcoded max_size=1333 in get_size_dict call - Fix resize method: Handle max_size with existing size dict properly - Fix test: Use proper test dict without conflicting longest_edge - Ensure max_size works correctly with from_dict and preprocess methods - All DETR variants (Conditional, Deformable, standard) now consistent
- Fix ConditionalDetrImageProcessor.from_dict to handle max_size correctly - Fix DetrImageProcessor.from_dict to handle max_size correctly - Fix DeformableDetrImageProcessor.from_dict to handle max_size correctly - Fix preprocess methods in all DETR variants to handle max_size properly - Add comprehensive test verification script - Ensure max_size is properly converted to longest_edge in size dict - Handle both integer size and dict size with max_size parameter - All fixes maintain backward compatibility with deprecation warnings Fixes issue where max_size parameter would incorrectly overwrite existing size settings instead of being properly integrated.
Member
Contributor
|
Hello @nck90, thanks for opening a PR, but unfortunately, we can't remove support for |
This was referenced Apr 29, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #37939
The deprecated max_size parameter was incorrectly overriding the size parameter completely instead of being properly handled. This affected both ConditionalDetrImageProcessor and DetrImageProcessor.
Changes:
The fix ensures backward compatibility while properly deprecating the max_size parameter in favor of size['longest_edge'].
What does this PR do?
Fixes # (issue)
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.