SIGN IN SIGN UP

🤗 Transformers: the model-definition framework for state-of-the-art machine learning models in text, vision, audio, and multimodal models, for both inference and training.

158577 0 0 Python

[Bugfix] Remove incorrect torchvision requirement from PIL backend image processors (#45045)

* [Bugfix] Remove incorrect torchvision requirement from PIL backend image processors

PR #45029 added @requires(backends=("vision", "torch", "torchvision")) to 67
PIL backend image_processing_pil_*.py files. This causes PIL backend classes
to become dummy objects when torchvision is not installed, making
AutoImageProcessor unable to find any working processor.

Fix: set @requires to ("vision",) for files that only need PIL, and
("vision", "torch") for files that also use torch directly. Also fix
5 modular source files so make fix-repo preserves the correct backends.

Fixes #45042

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* [Bugfix] Remove redundant @requires(backends=("vision",)) from PIL backends

Per reviewer feedback: the vision-only @requires decorator is redundant
for PIL backend classes since PilBackend base class already handles this.

- Remove @requires(backends=("vision",)) from 43 PIL backend files
- Remove unused `requires` import from 38 files (Category A)
- Keep @requires(backends=("vision", "torch")) on method-level decorators (Category B: 5 files)

* update

* remove torch when its not necessary

* remove if typechecking

* fix  import shinanigans

* marvellous that's how we protect torch :)

* beit is torchvisionbackend

* more import cleanup

* fiixup

* fix-repo

* update

* style

* fixes

* up

* more

* fix repo

* up

* update

* fix imports

* style

* fix check copies

* arf

* converter up

* fix?

* fix copies

* fix for func

* style

* ignore

* type

---------

Co-authored-by: Claude Opus 4.6 <[email protected]>
Co-authored-by: Arthur <[email protected]>
L
Lidang Jiang committed
2da00a3cec88fac160d481406e7961cf59472894
Parent: 2dbee5a
Committed by GitHub <[email protected]> on 3/30/2026, 7:25:49 AM