File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed
Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change 2929from transformers import AutoConfig , PretrainedConfig
3030from transformers .utils import SAFE_WEIGHTS_NAME , WEIGHTS_NAME , http_user_agent
3131
32- from ..utils .import_utils import is_diffusers_available , is_torch_available
32+ from ..utils .import_utils import is_diffusers_available , is_torch_available , is_transformers_version
3333from ..utils .logging import get_logger
3434
3535
@@ -152,8 +152,10 @@ class TasksManager:
152152 "AutoModelForUniversalSegmentation" ,
153153 ),
154154 "image-to-image" : "AutoModelForImageToImage" ,
155- # TODO: AutoModelForVision2Seq is deprecated and will be removed in Transformers v5
156- "image-to-text" : ("AutoModelForVision2Seq" , "AutoModel" ),
155+ "image-to-text" : (
156+ "AutoModelForVision2Seq" if is_transformers_version ("<" , "4.54" ) else "AutoModelForImageTextToText" ,
157+ "AutoModel" ,
158+ ),
157159 "image-text-to-text" : "AutoModelForImageTextToText" ,
158160 "mask-generation" : "AutoModel" ,
159161 "masked-im" : "AutoModelForMaskedImageModeling" ,
Original file line number Diff line number Diff line change 1717from typing import Any , Dict
1818
1919import numpy as np
20+ import pytest
2021from huggingface_hub .constants import HF_HUB_CACHE
2122from PIL import Image
2223from transformers import AutoTokenizer
2324from transformers .pipelines import Pipeline
2425
2526from optimum .pipelines import pipeline as optimum_pipeline
27+ from optimum .utils import is_transformers_version
2628from optimum .utils .testing_utils import remove_directory
2729
2830
@@ -192,6 +194,10 @@ def test_image_segmentation_pipeline(self):
192194 self .assertIn ("score" , result [0 ])
193195 self .assertIn ("mask" , result [0 ])
194196
197+ @pytest .mark .skipif (
198+ is_transformers_version (">=" , "5" ),
199+ reason = "requires transformers < v5 since image-to-text pipelines is deprecated" ,
200+ )
195201 def test_image_to_text_pipeline (self ):
196202 """Test image to text ORT pipeline"""
197203 pipe = optimum_pipeline (task = "image-to-text" , accelerator = "ort" )
You can’t perform that action at this time.
0 commit comments