Fix PIL backend fallback when torchvision is unavailable#45060
Fix PIL backend fallback when torchvision is unavailable#45060ErenAta16 wants to merge 3 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
|
Thanks for the run. The current failure is in This PR only changes PIL backend import-structure/fallback logic:
Could we rerun |
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
|
[For maintainers] Suggested jobs to run (before merge) run-slow: auto |
|
View the CircleCI Test Summary for this PR: https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=45060&sha=8260c8 |
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