




'''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 		lowercase_   (			lowerCamelCase__       ):


   """simple docstring"""

   lowerCamelCase_      =						'''Salesforce/blip-image-captioning-base'''
   lowerCamelCase_      =						(
       '''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.'''
   )
   lowerCamelCase_      =						'''image_captioner'''
   lowerCamelCase_      =						AutoModelForVisionaSeq

   lowerCamelCase_      =						['''image''']
   lowerCamelCase_      =						['''text''']



   def __init__(   self :     Any  ,				*__lowerCamelCase :     Optional[Any]  ,				**__lowerCamelCase :     str   ):

      """simple docstring"""
      requires_backends(self  ,				["vision"]   )
      super().__init__(*__snake_case  ,				**__snake_case   )



   def 							lowerCAmelCase_      (   self :     str  ,				__lowerCamelCase :     "Image"   ):

      """simple docstring"""
      return self.pre_processor(images=__snake_case  ,				return_tensors="pt"   )



   def 							lowerCAmelCase_      (   self :     Any  ,				__lowerCamelCase :     Dict   ):

      """simple docstring"""
      return self.model.generate(**__snake_case   )



   def 							lowerCAmelCase_      (   self :     str  ,				__lowerCamelCase :     Tuple   ):

      """simple docstring"""
      return self.pre_processor.batch_decode(__snake_case  ,				skip_special_tokens=__snake_case   )[0].strip()







'''simple docstring'''



from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


lowerCamelCase_			=						{
    'configuration_bridgetower': [
        'BRIDGETOWER_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'BridgeTowerConfig',
        'BridgeTowerTextConfig',
        'BridgeTowerVisionConfig',
    ],
    'processing_bridgetower': ['BridgeTowerProcessor'],
}

try:
 if not is_vision_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCamelCase_			=						['BridgeTowerImageProcessor']

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCamelCase_			=						[
     'BRIDGETOWER_PRETRAINED_MODEL_ARCHIVE_LIST',
     'BridgeTowerForContrastiveLearning',
     'BridgeTowerForImageAndTextRetrieval',
     'BridgeTowerForMaskedLM',
     'BridgeTowerModel',
     'BridgeTowerPreTrainedModel',
 ]


if TYPE_CHECKING:
 from .configuration_bridgetower import (
     BRIDGETOWER_PRETRAINED_CONFIG_ARCHIVE_MAP,
     BridgeTowerConfig,
     BridgeTowerTextConfig,
     BridgeTowerVisionConfig,
 )
 from .processing_bridgetower import BridgeTowerProcessor

 try:
  if not is_vision_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .image_processing_bridgetower import BridgeTowerImageProcessor

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_bridgetower import (
      BRIDGETOWER_PRETRAINED_MODEL_ARCHIVE_LIST,
      BridgeTowerForContrastiveLearning,
      BridgeTowerForImageAndTextRetrieval,
      BridgeTowerForMaskedLM,
      BridgeTowerModel,
      BridgeTowerPreTrainedModel,
  )


else:
 import sys

 lowerCamelCase_			=						_LazyModule(__name__, globals()['__file__'], _import_structure)

