

'''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   UpperCamelCase__    (   a_   ):


		"""simple docstring"""

		SCREAMING_SNAKE_CASE__  :	List[Any]   =							"Salesforce/blip-image-captioning-base"
		SCREAMING_SNAKE_CASE__  :	str   =							(
		    "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."
		)
		SCREAMING_SNAKE_CASE__  :	Optional[int]   =							"image_captioner"
		SCREAMING_SNAKE_CASE__  :	List[Any]   =							AutoModelForVisionaSeq

		SCREAMING_SNAKE_CASE__  :	List[str]   =							["image"]
		SCREAMING_SNAKE_CASE__  :	Optional[int]   =							["text"]







		def __init__( self    ,			*snake_case    ,			**snake_case			):


							'''simple docstring'''

							requires_backends(self    ,			["vision"]			)
							super().__init__(*_lowerCamelCase    ,			**_lowerCamelCase			)







		def       A_       ( self    ,			snake_case			):


							'''simple docstring'''

							return self.pre_processor(images=_lowerCamelCase    ,			return_tensors="pt"			)







		def       A_       ( self    ,			snake_case			):


							'''simple docstring'''

							return self.model.generate(**_lowerCamelCase			)







		def       A_       ( self    ,			snake_case			):


							'''simple docstring'''

							return self.pre_processor.batch_decode(_lowerCamelCase    ,			skip_special_tokens=_lowerCamelCase			)[0].strip()








"""simple docstring"""



from argparse import ArgumentParser

from .env import EnvironmentCommand
def 						_SCREAMING_SNAKE_CASE (    ):





  '''simple docstring'''





  lowercase							    =       ArgumentParser('Diffusers CLI tool'		,					usage='diffusers-cli <command> [<args>]'    )
  lowercase							    =       parser.add_subparsers(help='diffusers-cli command helpers'    )

  # Register commands
  EnvironmentCommand.register_subcommand(__snake_case    )

  # Let's go
  lowercase							    =       parser.parse_args()

  if not hasattr(__snake_case		,					'func'    ):
    parser.print_help()
    exit(1    )

  # Run
  lowercase							    =       args.func(__snake_case    )
  service.run()


if __name__ == "__main__":
    main()


