Commit 2da00a3
[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 <noreply@anthropic.com>
* [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 <noreply@anthropic.com>
Co-authored-by: Arthur <arthur.zucker@gmail.com>1 parent 2dbee5a commit 2da00a3
188 files changed
Lines changed: 5095 additions & 1270 deletions
File tree
- src/transformers
- models
- aria
- beit
- bridgetower
- chameleon
- chmv2
- cohere2_vision
- conditional_detr
- convnext
- deepseek_vl_hybrid
- deepseek_vl
- deformable_detr
- depth_pro
- detr
- dinov3_vit
- donut
- dpt
- efficientloftr
- efficientnet
- eomt
- ernie4_5_vl_moe
- flava
- fuyu
- gemma3
- glm46v
- glm4v
- glm_image
- glpn
- got_ocr2
- grounding_dino
- idefics2
- idefics3
- idefics
- imagegpt
- janus
- kosmos2_5
- layoutlmv2
- layoutlmv3
- levit
- lfm2_vl
- lightglue
- lighton_ocr
- llama4
- llava_next
- llava_onevision
- llava
- mask2former
- maskformer
- mllama
- mobilenet_v2
- mobilevit
- nougat
- oneformer
- ovis2
- owlv2
- owlvit
- paddleocr_vl
- perceiver
- perception_lm
- phi4_multimodal
- pix2struct
- pixtral
- poolformer
- pp_doclayout_v2
- pp_doclayout_v3
- prompt_depth_anything
- qwen2_vl
- rt_detr
- sam2
- sam3_video
- sam
- segformer
- seggpt
- siglip2
- smolvlm
- superglue
- superpoint
- swin2sr
- textnet
- tvp
- video_llama_3
- videomae
- vilt
- vitmatte
- vitpose
- yolos
- zoedepth
- utils
- utils
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
529 | 529 | | |
530 | 530 | | |
531 | 531 | | |
532 | | - | |
| 532 | + | |
533 | 533 | | |
534 | 534 | | |
535 | 535 | | |
| |||
628 | 628 | | |
629 | 629 | | |
630 | 630 | | |
631 | | - | |
| 631 | + | |
632 | 632 | | |
633 | 633 | | |
634 | 634 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 28 | + | |
32 | 29 | | |
33 | 30 | | |
34 | 31 | | |
| |||
Lines changed: 23 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | | - | |
30 | | - | |
31 | 29 | | |
32 | 30 | | |
33 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
34 | 50 | | |
35 | 51 | | |
36 | 52 | | |
| |||
65 | 81 | | |
66 | 82 | | |
67 | 83 | | |
68 | | - | |
| 84 | + | |
69 | 85 | | |
70 | 86 | | |
71 | 87 | | |
| |||
90 | 106 | | |
91 | 107 | | |
92 | 108 | | |
93 | | - | |
| 109 | + | |
94 | 110 | | |
95 | 111 | | |
96 | 112 | | |
| |||
131 | 147 | | |
132 | 148 | | |
133 | 149 | | |
134 | | - | |
| 150 | + | |
135 | 151 | | |
136 | 152 | | |
137 | 153 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
| 44 | + | |
50 | 45 | | |
51 | 46 | | |
52 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
42 | | - | |
43 | | - | |
44 | 43 | | |
45 | 44 | | |
46 | 45 | | |
| |||
323 | 322 | | |
324 | 323 | | |
325 | 324 | | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | 325 | | |
334 | 326 | | |
335 | 327 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
18 | 22 | | |
19 | 23 | | |
20 | 24 | | |
| |||
27 | 31 | | |
28 | 32 | | |
29 | 33 | | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
| 34 | + | |
39 | 35 | | |
40 | 36 | | |
41 | 37 | | |
| |||
Lines changed: 18 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | 17 | | |
21 | 18 | | |
22 | 19 | | |
| |||
28 | 25 | | |
29 | 26 | | |
30 | 27 | | |
31 | | - | |
32 | | - | |
| 28 | + | |
| 29 | + | |
33 | 30 | | |
34 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
35 | 43 | | |
36 | 44 | | |
37 | 45 | | |
38 | | - | |
39 | 46 | | |
40 | 47 | | |
41 | 48 | | |
| |||
124 | 131 | | |
125 | 132 | | |
126 | 133 | | |
127 | | - | |
| 134 | + | |
128 | 135 | | |
129 | 136 | | |
130 | 137 | | |
| |||
152 | 159 | | |
153 | 160 | | |
154 | 161 | | |
| 162 | + | |
155 | 163 | | |
156 | 164 | | |
157 | 165 | | |
| |||
168 | 176 | | |
169 | 177 | | |
170 | 178 | | |
171 | | - | |
172 | | - | |
| 179 | + | |
| 180 | + | |
173 | 181 | | |
174 | 182 | | |
175 | 183 | | |
| |||
Lines changed: 3 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
| 34 | + | |
40 | 35 | | |
41 | 36 | | |
42 | 37 | | |
| |||
Lines changed: 47 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
| 26 | + | |
25 | 27 | | |
26 | | - | |
| 28 | + | |
27 | 29 | | |
28 | | - | |
29 | | - | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
33 | 74 | | |
34 | 75 | | |
35 | 76 | | |
| |||
57 | 98 | | |
58 | 99 | | |
59 | 100 | | |
60 | | - | |
| 101 | + | |
61 | 102 | | |
62 | 103 | | |
63 | 104 | | |
| |||
82 | 123 | | |
83 | 124 | | |
84 | 125 | | |
85 | | - | |
| 126 | + | |
86 | 127 | | |
87 | 128 | | |
88 | 129 | | |
| |||
Lines changed: 3 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
| |||
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
26 | | - | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | 31 | | |
36 | 32 | | |
37 | 33 | | |
| |||
0 commit comments