

"""simple docstring"""




import unittest
from pathlib import Path

from transformers import is_vision_available, load_tool
from transformers.testing_utils import get_tests_dir

from .test_tools_common import ToolTesterMixin


if is_vision_available():
      from PIL import Image







class    __lowercase	(			unittest.TestCase		,	__a    ):

  def       __lowercase				(     self						:	Optional[Any]			):






   '''simple docstring'''
   UpperCAmelCase__    :     Dict          =    load_tool("""image-captioning"""			)
   self.tool.setup()
   UpperCAmelCase__    :     int          =    load_tool("""image-captioning"""    ,remote=lowerCAmelCase__			)

  def       __lowercase				(     self						:	Optional[Any]			):






   '''simple docstring'''
   UpperCAmelCase__    :     Any          =    Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO"""			)			) / """000000039769.png"""			)
   UpperCAmelCase__    :     Optional[Any]          =    self.tool(lowerCAmelCase__			)
   self.assertEqual(lowerCAmelCase__    ,"""two cats sleeping on a couch"""			)

  def       __lowercase				(     self						:	Any			):






   '''simple docstring'''
   UpperCAmelCase__    :     Optional[Any]          =    Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO"""			)			) / """000000039769.png"""			)
   UpperCAmelCase__    :     Optional[Any]          =    self.remote_tool(lowerCAmelCase__			)
   self.assertEqual(lowerCAmelCase__    ,"""two cats sleeping on a couch"""			)

  def       __lowercase				(     self						:	List[str]			):






   '''simple docstring'''
   UpperCAmelCase__    :     Optional[Any]          =    Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO"""			)			) / """000000039769.png"""			)
   UpperCAmelCase__    :     List[Any]          =    self.tool(image=lowerCAmelCase__			)
   self.assertEqual(lowerCAmelCase__    ,"""two cats sleeping on a couch"""			)




  def       __lowercase				(     self						:	Any			):






   '''simple docstring'''
   UpperCAmelCase__    :     Tuple          =    Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO"""			)			) / """000000039769.png"""			)
   UpperCAmelCase__    :     List[str]          =    self.remote_tool(image=lowerCAmelCase__			)
   self.assertEqual(lowerCAmelCase__    ,"""two cats sleeping on a couch"""			)







'''simple docstring'''

import unittest

from transformers import is_torch_available, load_tool

from .test_tools_common import ToolTesterMixin


if is_torch_available():
   import torch







class 	__lowerCAmelCase    (  unittest.TestCase       ,					__a				):



     def     snake_case_ (self	):
          _UpperCAmelCase					:  Tuple         =    load_tool("""speech-to-text"""	)
          self.tool.setup()



     def     snake_case_ (self	):
          _UpperCAmelCase					:  str         =    self.tool(torch.ones(3_0_0_0	)	)
          self.assertEqual(lowerCAmelCase__						,	""" you"""	)



     def     snake_case_ (self	):
          _UpperCAmelCase					:  Union[str, Any]         =    self.tool(audio=torch.ones(3_0_0_0	)	)
          self.assertEqual(lowerCAmelCase__						,	""" you"""	)


