code: 
  
  
  
  
  
  
  """simple docstring"""
  
  import unittest
  
  import requests
  
  from transformers import MODEL_FOR_VISION_2_SEQ_MAPPING, TF_MODEL_FOR_VISION_2_SEQ_MAPPING, is_vision_available
  from transformers.pipelines import pipeline
  from transformers.testing_utils import (
      is_pipeline_test,
      is_torch_available,
      require_tf,
      require_torch,
      require_vision,
      slow,
  )
  
  from .test_pipelines_common import ANY
  
  
  if is_torch_available():
  					from transformers.pytorch_utils import is_torch_greater_or_equal_than_1_11
  else:
  					lowercase__      =				False
  
  
  if is_vision_available():
  					from PIL import Image
  else:
  
  
  					class 	__lowerCamelCase       :
  
  
  
  
  
  							'''simple docstring'''
  
  
  
  
  
  
  							@staticmethod
  							def      lowerCamelCase (     *a_							:			Any		,    **a_							:			List[Any]			):
  									pass
  
  
  @is_pipeline_test
  @require_vision
  class 	__lowerCamelCase       (				unittest.TestCase    ):
  
  
  
  
  
  		'''simple docstring'''
  
  
  
  
  
  
  		a_			:       List[Any]      =							MODEL_FOR_VISION_2_SEQ_MAPPING
  		a_			:       List[str]      =							TF_MODEL_FOR_VISION_2_SEQ_MAPPING
  
  
  
  
  
  		def      lowerCamelCase (     self							:			str		,    a_							:			Optional[int]		,    a_							:			Tuple		,    a_							:			int			):
  				lowerCAmelCase_     :							Optional[int]             =    pipeline("image-to-text"		,    model=a_		,    tokenizer=a_		,    image_processor=a_			)
  				lowerCAmelCase_     :							str             =    [
  				    Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"			),
  				    "./tests/fixtures/tests_samples/COCO/000000039769.png",
  				]
  				return pipe, examples
  
  
  
  
  
  		def      lowerCamelCase (     self							:			Any		,    a_							:			Tuple		,    a_							:			List[str]			):
  				lowerCAmelCase_     :							Optional[Any]             =    pipe(a_			)
  				self.assertEqual(
  				    a_		,    [
  				        [{"generated_text": ANY(a_			)}],
  				        [{"generated_text": ANY(a_			)}],
  				    ]		,    )
  
  
  
  
  
  		@require_tf
  		def      lowerCamelCase (     self							:			int			):
  				lowerCAmelCase_     :							Union[str, Any]             =    pipeline("image-to-text"		,    model="hf-internal-testing/tiny-random-vit-gpt2"		,    framework="tf"			)
  				lowerCAmelCase_     :							List[Any]             =    "./tests/fixtures/tests_samples/COCO/000000039769.png"
  
  				lowerCAmelCase_     :							Any             =    pipe(a_			)
  				self.assertEqual(
  				    a_		,    [
  				        {
  				            "generated_text": "growthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthGOGO"
  				        },
  				    ]		,    )
  
  				lowerCAmelCase_     :							Dict             =    pipe([image, image]			)
  				self.assertEqual(
  				    a_		,    [
  				        [
  				            {
  				                "generated_text": "growthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthGOGO"
  				            }
  				        ],
  				        [
  				            {
  				                "generated_text": "growthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthGOGO"
  				            }
  				        ],
  				    ]		,    )
  
  				lowerCAmelCase_     :							List[Any]             =    pipe(a_		,    max_new_tokens=1			)
  				self.assertEqual(
  				    a_		,    [{"generated_text": "growth"}]		,    )
  
  
  
  
  
  		@require_torch
  		def      lowerCamelCase (     self							:			str			):
  				lowerCAmelCase_     :							Any             =    pipeline("image-to-text"		,    model="hf-internal-testing/tiny-random-vit-gpt2"			)
  				lowerCAmelCase_     :							Dict             =    "./tests/fixtures/tests_samples/COCO/000000039769.png"
  
  				lowerCAmelCase_     :							Dict             =    pipe(a_			)
  				self.assertEqual(
  				    a_		,    [
  				        {
  				            "generated_text": "growthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthGOGO"
  				        },
  				    ]		,    )
  
  				lowerCAmelCase_     :							Any             =    pipe([image, image]			)
  				self.assertEqual(
  				    a_		,    [
  				        [
  				            {
  				                "generated_text": "growthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthGOGO"
  				            }
  				        ],
  				        [
  				            {
  				                "generated_text": "growthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthGOGO"
  				            }
  				        ],
  				    ]		,    )
  
  
  
  
  
  		@require_torch
  		def      lowerCamelCase (     self							:			Dict			):
  				lowerCAmelCase_     :							int             =    pipeline("image-to-text"		,    model="hf-internal-testing/tiny-random-BlipForConditionalGeneration"			)
  				lowerCAmelCase_     :							Optional[Any]             =    "./tests/fixtures/tests_samples/COCO/000000039769.png"
  				lowerCAmelCase_     :							Tuple             =    "a photo of"
  
  				lowerCAmelCase_     :							Optional[int]             =    pipe(a_		,    prompt=a_			)
  				self.assertTrue(outputs[0]["generated_text"].startswith(a_			)			)
  
  
  
  
  
  		@slow
  		@require_torch
  		def      lowerCamelCase (     self							:			List[str]			):
  				lowerCAmelCase_     :							Union[str, Any]             =    pipeline("image-to-text"		,    model="ydshieh/vit-gpt2-coco-en"			)
  				lowerCAmelCase_     :							int             =    "./tests/fixtures/tests_samples/COCO/000000039769.png"
  
  				lowerCAmelCase_     :							Dict             =    pipe(a_			)
  				self.assertEqual(a_		,    [{"generated_text": "a cat laying on a blanket next to a cat laying on a bed "}]			)
  
  				lowerCAmelCase_     :							List[Any]             =    pipe([image, image]			)
  				self.assertEqual(
  				    a_		,    [
  				        [{"generated_text": "a cat laying on a blanket next to a cat laying on a bed "}],
  				        [{"generated_text": "a cat laying on a blanket next to a cat laying on a bed "}],
  				    ]		,    )
  
  
  
  
  
  		@slow
  		@require_torch
  		def      lowerCamelCase (     self							:			Any			):
  				lowerCAmelCase_     :							Dict             =    pipeline("image-to-text"		,    model="Salesforce/blip-image-captioning-base"			)
  				lowerCAmelCase_     :							str             =    "https://huggingface.co/datasets/sayakpaul/sample-datasets/resolve/main/pokemon.png"
  				lowerCAmelCase_     :							Union[str, Any]             =    Image.open(requests.get(a_		,    stream=a_			).raw			)
  
  				lowerCAmelCase_     :							List[str]             =    pipe(a_			)
  				self.assertEqual(a_		,    [{"generated_text": "a pink pokemon pokemon with a blue shirt and a blue shirt"}]			)
  
  
  
  
  
  		@slow
  		@require_torch
  		def      lowerCamelCase (     self							:			int			):
  				lowerCAmelCase_     :							Optional[int]             =    pipeline("image-to-text"		,    model="microsoft/git-base-coco"			)
  				lowerCAmelCase_     :							Dict             =    "https://huggingface.co/datasets/sayakpaul/sample-datasets/resolve/main/pokemon.png"
  				lowerCAmelCase_     :							List[str]             =    Image.open(requests.get(a_		,    stream=a_			).raw			)
  
  				lowerCAmelCase_     :							Optional[Any]             =    pipe(a_			)
  				self.assertEqual(a_		,    [{"generated_text": "a cartoon of a purple character."}]			)
  
  
  
  
  
  		@slow
  		@require_torch
  		def      lowerCamelCase (     self							:			Union[str, Any]			):
  				lowerCAmelCase_     :							Any             =    pipeline("image-to-text"		,    model="Salesforce/blip-image-captioning-base"			)
  				lowerCAmelCase_     :							int             =    "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/ai2d-demo.jpg"
  				lowerCAmelCase_     :							int             =    Image.open(requests.get(a_		,    stream=a_			).raw			)
  
  				lowerCAmelCase_     :							Dict             =    "a photography of"
  
  				lowerCAmelCase_     :							Any             =    pipe(a_		,    prompt=a_			)
  				self.assertEqual(a_		,    [{"generated_text": "a photography of a volcano"}]			)
  
  				with self.assertRaises(a_			):
  						lowerCAmelCase_     :							Optional[Any]             =    pipe([image, image]		,    prompt=[prompt, prompt]			)
  
  
  
  
  
  		@slow
  		@require_torch
  		def      lowerCamelCase (     self							:			Optional[int]			):
  				lowerCAmelCase_     :							str             =    pipeline("image-to-text"		,    model="microsoft/git-base-coco"			)
  				lowerCAmelCase_     :							str             =    "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/ai2d-demo.jpg"
  				lowerCAmelCase_     :							List[str]             =    Image.open(requests.get(a_		,    stream=a_			).raw			)
  
  				lowerCAmelCase_     :							Optional[Any]             =    "a photo of a"
  
  				lowerCAmelCase_     :							Dict             =    pipe(a_		,    prompt=a_			)
  				self.assertEqual(a_		,    [{"generated_text": "a photo of a tent with a tent and a tent in the background."}]			)
  
  				with self.assertRaises(a_			):
  						lowerCAmelCase_     :							List[str]             =    pipe([image, image]		,    prompt=[prompt, prompt]			)
  
  
  
  
  
  		@unittest.skipIf(
  		    not is_torch_greater_or_equal_than_1_11		,    reason="`Pix2StructImageProcessor` requires `torch>=1.11.0`."			)
  		@slow
  		@require_torch
  		def      lowerCamelCase (     self							:			Any			):
  				lowerCAmelCase_     :							Optional[int]             =    pipeline("image-to-text"		,    model="google/pix2struct-ai2d-base"			)
  				lowerCAmelCase_     :							Union[str, Any]             =    "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/ai2d-demo.jpg"
  				lowerCAmelCase_     :							str             =    Image.open(requests.get(a_		,    stream=a_			).raw			)
  
  				lowerCAmelCase_     :							Union[str, Any]             =    "What does the label 15 represent? (1) lava (2) core (3) tunnel (4) ash cloud"
  
  				lowerCAmelCase_     :							Optional[int]             =    pipe(a_		,    prompt=a_			)
  				self.assertEqual(a_		,    [{"generated_text": "ash cloud"}]			)
  
  				with self.assertRaises(a_			):
  						lowerCAmelCase_     :							Optional[Any]             =    pipe([image, image]		,    prompt=[prompt, prompt]			)
  
  
  
  
  
  		@slow
  		@require_tf
  		def      lowerCamelCase (     self							:			Dict			):
  				lowerCAmelCase_     :							Dict             =    pipeline("image-to-text"		,    model="ydshieh/vit-gpt2-coco-en"		,    framework="tf"			)
  				lowerCAmelCase_     :							Tuple             =    "./tests/fixtures/tests_samples/COCO/000000039769.png"
  
  				lowerCAmelCase_     :							Tuple             =    pipe(a_			)
  				self.assertEqual(a_		,    [{"generated_text": "a cat laying on a blanket next to a cat laying on a bed "}]			)
  
  				lowerCAmelCase_     :							str             =    pipe([image, image]			)
  				self.assertEqual(
  				    a_		,    [
  				        [{"generated_text": "a cat laying on a blanket next to a cat laying on a bed "}],
  				        [{"generated_text": "a cat laying on a blanket next to a cat laying on a bed "}],
  				    ]		,    )
  
style_context: 
  
  
  
  
  
  
  """simple docstring"""
  
  from .pipeline_kandinskya_a import KandinskyVaaPipeline
  from .pipeline_kandinsky2_2_controlnet import KandinskyVaaControlnetPipeline
  from .pipeline_kandinsky2_2_controlnet_img2img import KandinskyVaaControlnetImgaImgPipeline
  from .pipeline_kandinsky2_2_img2img import KandinskyVaaImgaImgPipeline
  from .pipeline_kandinsky2_2_inpainting import KandinskyVaaInpaintPipeline
  from .pipeline_kandinsky2_2_prior import KandinskyVaaPriorPipeline
  from .pipeline_kandinsky2_2_prior_emb2emb import KandinskyVaaPriorEmbaEmbPipeline
  