Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix naming issue with Image2TextGenerationPipeline #18864

Merged
merged 1 commit into from
Sep 2, 2022
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
6 changes: 3 additions & 3 deletions docs/source/en/main_classes/pipelines.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ There are two categories of pipeline abstractions to be aware about:
- [`FillMaskPipeline`]
- [`ImageClassificationPipeline`]
- [`ImageSegmentationPipeline`]
- [`Image2TextGenerationPipeline`]
- [`ImageToTextPipeline`]
- [`ObjectDetectionPipeline`]
- [`QuestionAnsweringPipeline`]
- [`SummarizationPipeline`]
Expand Down Expand Up @@ -366,9 +366,9 @@ That should enable you to do all the custom code you want.
- __call__
- all

### Image2TextGenerationPipeline
### ImageToTextPipeline

[[autodoc]] Image2TextGenerationPipeline
[[autodoc]] ImageToTextPipeline
- __call__
- all

Expand Down
4 changes: 2 additions & 2 deletions src/transformers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,9 @@
"CsvPipelineDataFormat",
"FeatureExtractionPipeline",
"FillMaskPipeline",
"Image2TextGenerationPipeline",
"ImageClassificationPipeline",
"ImageSegmentationPipeline",
"ImageToTextPipeline",
"JsonPipelineDataFormat",
"NerPipeline",
"ObjectDetectionPipeline",
Expand Down Expand Up @@ -3192,9 +3192,9 @@
CsvPipelineDataFormat,
FeatureExtractionPipeline,
FillMaskPipeline,
Image2TextGenerationPipeline,
ImageClassificationPipeline,
ImageSegmentationPipeline,
ImageToTextPipeline,
JsonPipelineDataFormat,
NerPipeline,
ObjectDetectionPipeline,
Expand Down
6 changes: 3 additions & 3 deletions src/transformers/pipelines/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
from .conversational import Conversation, ConversationalPipeline
from .feature_extraction import FeatureExtractionPipeline
from .fill_mask import FillMaskPipeline
from .image2text_generation import Image2TextGenerationPipeline
from .image_classification import ImageClassificationPipeline
from .image_segmentation import ImageSegmentationPipeline
from .image_to_text import ImageToTextPipeline
from .object_detection import ObjectDetectionPipeline
from .question_answering import QuestionAnsweringArgumentHandler, QuestionAnsweringPipeline
from .table_question_answering import TableQuestionAnsweringArgumentHandler, TableQuestionAnsweringPipeline
Expand Down Expand Up @@ -305,8 +305,8 @@
"default": {"model": {"pt": ("facebook/detr-resnet-50-panoptic", "fc15262")}},
"type": "image",
},
"image2text-generation": {
"impl": Image2TextGenerationPipeline,
"image-to-text": {
"impl": ImageToTextPipeline,
"tf": (TFAutoModelForVision2Seq,) if is_tf_available() else (),
"pt": (AutoModelForVision2Seq,) if is_torch_available() else (),
"default": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@


@add_end_docstrings(PIPELINE_INIT_ARGS)
class Image2TextGenerationPipeline(Pipeline):
class ImageToTextPipeline(Pipeline):
"""
Image2Text Generation pipeline using a `AutoModelForVision2Seq`. This pipeline predicts a caption for a given
image.
Image To Text pipeline using a `AutoModelForVision2Seq`. This pipeline predicts a caption for a given image.
This image to text generation pipeline can currently be loaded from pipeline() using the following task identifier:
"image2text-generation".
This image to text pipeline can currently be loaded from pipeline() using the following task identifier:
"image-to-text".
See the list of available models on
[huggingface.co/models](https://huggingface.co/models?pipeline_tag=image-to-text).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ def open(*args, **kwargs):

@is_pipeline_test
@require_vision
class Image2TextGenerationPipelineTests(unittest.TestCase, metaclass=PipelineTestCaseMeta):
class ImageToTextPipelineTests(unittest.TestCase, metaclass=PipelineTestCaseMeta):
model_mapping = MODEL_FOR_VISION_2_SEQ_MAPPING
tf_model_mapping = TF_MODEL_FOR_VISION_2_SEQ_MAPPING

def get_test_pipeline(self, model, tokenizer, feature_extractor):
pipe = pipeline("image2text-generation", model=model, tokenizer=tokenizer, feature_extractor=feature_extractor)
pipe = pipeline("image-to-text", model=model, tokenizer=tokenizer, feature_extractor=feature_extractor)
examples = [
Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"),
"./tests/fixtures/tests_samples/COCO/000000039769.png",
Expand All @@ -57,7 +57,7 @@ def run_pipeline_test(self, pipe, examples):

@require_tf
def test_small_model_tf(self):
pipe = pipeline("image2text-generation", model="hf-internal-testing/tiny-random-vit-gpt2")
pipe = pipeline("image-to-text", model="hf-internal-testing/tiny-random-vit-gpt2")
image = "./tests/fixtures/tests_samples/COCO/000000039769.png"

outputs = pipe(image)
Expand Down Expand Up @@ -104,7 +104,7 @@ def test_small_model_tf(self):

@require_torch
def test_small_model_pt(self):
pipe = pipeline("image2text-generation", model="hf-internal-testing/tiny-random-vit-gpt2")
pipe = pipeline("image-to-text", model="hf-internal-testing/tiny-random-vit-gpt2")
image = "./tests/fixtures/tests_samples/COCO/000000039769.png"

outputs = pipe(image)
Expand Down Expand Up @@ -137,7 +137,7 @@ def test_small_model_pt(self):
@slow
@require_torch
def test_large_model_pt(self):
pipe = pipeline("image2text-generation", model="ydshieh/vit-gpt2-coco-en")
pipe = pipeline("image-to-text", model="ydshieh/vit-gpt2-coco-en")
image = "./tests/fixtures/tests_samples/COCO/000000039769.png"

outputs = pipe(image)
Expand All @@ -155,7 +155,7 @@ def test_large_model_pt(self):
@slow
@require_tf
def test_large_model_tf(self):
pipe = pipeline("image2text-generation", model="ydshieh/vit-gpt2-coco-en")
pipe = pipeline("image-to-text", model="ydshieh/vit-gpt2-coco-en")
image = "./tests/fixtures/tests_samples/COCO/000000039769.png"

outputs = pipe(image)
Expand Down