Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions optimum/exporters/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from transformers import AutoConfig, PretrainedConfig
from transformers.utils import SAFE_WEIGHTS_NAME, WEIGHTS_NAME, http_user_agent

from ..utils.import_utils import is_diffusers_available, is_torch_available
from ..utils.import_utils import is_diffusers_available, is_torch_available, is_transformers_version
from ..utils.logging import get_logger


Expand Down Expand Up @@ -152,8 +152,10 @@ class TasksManager:
"AutoModelForUniversalSegmentation",
),
"image-to-image": "AutoModelForImageToImage",
# TODO: AutoModelForVision2Seq is deprecated and will be removed in Transformers v5
"image-to-text": ("AutoModelForVision2Seq", "AutoModel"),
"image-to-text": (
"AutoModelForVision2Seq" if is_transformers_version("<", "4.54") else "AutoModelForImageTextToText",
"AutoModel",
),
"image-text-to-text": "AutoModelForImageTextToText",
"mask-generation": "AutoModel",
"masked-im": "AutoModelForMaskedImageModeling",
Expand Down
6 changes: 6 additions & 0 deletions tests/pipelines/test_pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
from typing import Any, Dict

import numpy as np
import pytest
from huggingface_hub.constants import HF_HUB_CACHE
from PIL import Image
from transformers import AutoTokenizer
from transformers.pipelines import Pipeline

from optimum.pipelines import pipeline as optimum_pipeline
from optimum.utils import is_transformers_version
from optimum.utils.testing_utils import remove_directory


Expand Down Expand Up @@ -192,6 +194,10 @@ def test_image_segmentation_pipeline(self):
self.assertIn("score", result[0])
self.assertIn("mask", result[0])

@pytest.mark.skipif(
is_transformers_version(">=", "5"),
reason="requires transformers < v5 since image-to-text pipelines is deprecated",
)
def test_image_to_text_pipeline(self):
"""Test image to text ORT pipeline"""
pipe = optimum_pipeline(task="image-to-text", accelerator="ort")
Comment on lines +197 to 203

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can use the image-text-to-text pipeline ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm yeh maybe leave to abother pr as we don't really support that pipeline class here

Expand Down
Loading