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 		_lowerCamelCase		(   UpperCamelCase_    ):
    __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 , *lowerCAmelCase , **lowerCAmelCase   )       ->					Dict:
     requires_backends(self , ['''vision''']   )
     super().__init__(*__a , **__a   )
    def 						UpperCamelCase_				(  self , lowerCAmelCase   )       ->					Union[str, Any]:
     return self.pre_processor(images=__a , return_tensors='''pt'''   )
    def 						UpperCamelCase_				(  self , lowerCAmelCase   )       ->					int:
     return self.model.generate(**__a   )



    def 						UpperCamelCase_				(  self , lowerCAmelCase   )       ->					Union[str, Any]:
     return self.pre_processor.batch_decode(__a , skip_special_tokens=__a   )[0].strip()


# tests directory-specific settings - this file is run automatically
# by pytest before any tests are run

import sys
import warnings
from os.path import abspath, dirname, join


# allow having multiple repository checkouts and not needing to remember to rerun
# 'pip install -e .[dev]' when switching between checkouts and running tests.
lowercase_     :   List[str] 				=				abspath(join(dirname(dirname(__file__)), 'src'))
sys.path.insert(1, git_repo_path)

# silence FutureWarning warnings in tests since often we can't act on them until
# they become normal warnings - i.e. the tests still need to test the current functionality
warnings.simplefilter(action='ignore', category=FutureWarning)







def 			A__      (	snake_case_ :		Optional[int]      ):
 from diffusers.utils.testing_utils import pytest_addoption_shared

 pytest_addoption_shared(snake_case_      )







def 			A__      (	snake_case_ :		Optional[int]      ):
 from diffusers.utils.testing_utils import pytest_terminal_summary_main

 SCREAMING_SNAKE_CASE__:   Optional[int]=      terminalreporter.config.getoption('''--make-reports'''      )
 if make_reports:
  pytest_terminal_summary_main(snake_case_       ,				id=snake_case_      )

