Fix PIL backend fallback when torchvision is unavailable#45060
Open
ErenAta16 wants to merge 2 commits intohuggingface:mainfrom
Open
Fix PIL backend fallback when torchvision is unavailable#45060ErenAta16 wants to merge 2 commits intohuggingface:mainfrom
ErenAta16 wants to merge 2 commits intohuggingface:mainfrom
Conversation
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
039b93f to
9350f48
Compare
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=9350f4 |
Author
|
Thanks for the run. The current failure is in This PR only changes PIL backend import-structure/fallback logic:
Could we rerun |
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