



"""simple docstring"""






from typing import TYPE_CHECKING

from ..models.auto import AutoModelForVisionaSeq
from ..utils import requires_backends
from .base import PipelineTool


if TYPE_CHECKING:
				from PIL import Image

class 	__SCREAMING_SNAKE_CASE     (				lowerCAmelCase_       ):


					'''simple docstring'''





					_a             =							'Salesforce/blip-image-captioning-base'
					_a             =							(
					    'This is a tool that generates a description of an image. It takes an input named `image` which should be the '
					    'image to caption, and returns a text that contains the description in English.'
					)
					_a             =							'image_captioner'
					_a             =							AutoModelForVisionaSeq

					_a             =							['image']
					_a             =							['text']



					def __init__(	self							:  Dict,  *lowerCamelCase							:  Dict,  **lowerCamelCase							:  List[Any]					)-> List[Any]:
								requires_backends(self,  ['''vision''']					)
								super().__init__(*lowerCamelCase,  **lowerCamelCase					)



					def 		snake_case	(	self							:  Optional[int],  lowerCamelCase							:  "Image"					)-> Any:
								return self.pre_processor(images=lowerCamelCase,  return_tensors='''pt'''					)



					def 		snake_case	(	self							:  Tuple,  lowerCamelCase							:  List[Any]					)-> Optional[Any]:
								return self.model.generate(**lowerCamelCase					)




					def 		snake_case	(	self							:  List[str],  lowerCamelCase							:  Any					)-> List[str]:
								return self.pre_processor.batch_decode(lowerCamelCase,  skip_special_tokens=lowerCamelCase					)[0].strip()









"""simple docstring"""






from ..utils import DummyObject, requires_backends

class 	__SCREAMING_SNAKE_CASE     (				metaclass=lowerCAmelCase_       ):


					'''simple docstring'''





					_a             =							['torch', 'torchsde']



					def __init__(	self							:  Union[str, Any],  *lowerCamelCase							:  str,  **lowerCamelCase							:  int					)-> Tuple:
								requires_backends(self,  ['''torch''', '''torchsde''']					)



					@classmethod
					def 		snake_case	(	cls							:  List[str],  *lowerCamelCase							:  Optional[Any],  **lowerCamelCase							:  Dict					)-> str:
								requires_backends(cls,  ['''torch''', '''torchsde''']					)




					@classmethod
					def 		snake_case	(	cls							:  Tuple,  *lowerCamelCase							:  Dict,  **lowerCamelCase							:  Tuple					)-> List[str]:
								requires_backends(cls,  ['''torch''', '''torchsde''']					)




