Repository navigation
Conversation
added 2 commits
March 27, 2026 17:35
Prevent PIL image/video processor classes from inheriting torchvision backend requirements in the import structure so AutoProcessor/AutoImageProcessor can correctly fall back to PIL when torchvision is unavailable. Add regression tests to lock the import-structure behavior and the auto-backend fallback path. Made-with: Cursor
Patch the AutoImageProcessor fallback regression test to mock the backend resolution helper used by image_processing_auto, so it correctly simulates a no-torchvision environment in CI. Made-with: Cursor
This comment was marked as spam.
This comment was marked as spam.
Collaborator
There was a problem hiding this comment.
Ty! there's #45045 which came first and is more aligned with what we are trying to do!
Tho checking for torch "torch" in the file might also just work. We could do the same for PIL that need torch
Contributor
|
[For maintainers] Suggested jobs to run (before merge) run-slow: auto |
Contributor
|
View the CircleCI Test Summary for this PR: https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=45060&sha=8260c8 |
This comment was marked as spam.
This comment was marked as spam.
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.
This PR fixes a regression where PIL-based image/video processors were incorrectly treated as requiring
torchvision.As a result,
AutoProcessor/AutoImageProcessorcould fail in environments withouttorchvision, even though a valid PIL fallback exists.What changed
import_utilsso PIL modules do not inherittorchvisionrequirements:image_processing_pil_*video_processing_pil_*torchvisionfrom being attached to PIL-only modules during backend aggregation.torchvisionis unavailableFixes #45042
Tests
python -m pytest tests/utils/test_import_structure.py -k "pil_import_structure_does_not_require_torchvision" -qpython -m pytest tests/models/auto/test_image_processing_auto.py -k "auto_backend_falls_back_to_pil_when_torchvision_is_unavailable or backend_kwarg_pil" -q