



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 						UpperCAmelCase__     (     unittest.TestCase		,lowerCamelCase__  ):




			'''simple docstring'''






			def 					snake_case__	(  self				:					Any					):
					'''simple docstring'''





					__UpperCAmelCase       :	List[Any]						=      load_tool('''image-question-answering'''					)
					self.tool.setup()
					__UpperCAmelCase       :	str						=      load_tool('''image-question-answering'''			,			remote=_UpperCAmelCase					)




			def 					snake_case__	(  self				:					List[Any]					):
					'''simple docstring'''





					__UpperCAmelCase       :	int						=      Image.open(Path(get_tests_dir('''fixtures/tests_samples/COCO'''					)					) / '''000000039769.png'''					)
					__UpperCAmelCase       :	int						=      self.tool(_UpperCAmelCase			,			'''How many cats are sleeping on the couch?'''					)
					self.assertEqual(_UpperCAmelCase			,			'''2'''					)




			def 					snake_case__	(  self				:					int					):
					'''simple docstring'''





					__UpperCAmelCase       :	Optional[int]						=      Image.open(Path(get_tests_dir('''fixtures/tests_samples/COCO'''					)					) / '''000000039769.png'''					)
					__UpperCAmelCase       :	Optional[Any]						=      self.remote_tool(_UpperCAmelCase			,			'''How many cats are sleeping on the couch?'''					)
					self.assertEqual(_UpperCAmelCase			,			'''2'''					)




			def 					snake_case__	(  self				:					List[Any]					):
					'''simple docstring'''





					__UpperCAmelCase       :	Optional[int]						=      Image.open(Path(get_tests_dir('''fixtures/tests_samples/COCO'''					)					) / '''000000039769.png'''					)
					__UpperCAmelCase       :	Union[str, Any]						=      self.tool(image=_UpperCAmelCase			,			question='''How many cats are sleeping on the couch?'''					)
					self.assertEqual(_UpperCAmelCase			,			'''2'''					)




			def 					snake_case__	(  self				:					List[Any]					):
					'''simple docstring'''





					__UpperCAmelCase       :	Optional[Any]						=      Image.open(Path(get_tests_dir('''fixtures/tests_samples/COCO'''					)					) / '''000000039769.png'''					)
					__UpperCAmelCase       :	Any						=      self.remote_tool(image=_UpperCAmelCase			,			question='''How many cats are sleeping on the couch?'''					)
					self.assertEqual(_UpperCAmelCase			,			'''2'''					)









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 lowerCAmelCase_		(					unittest.TestCase   ,		lowerCamelCase__			):

 '''simple docstring'''

 def 		UpperCamelCase__	(      self   ):
       snake_case_			= load_tool('''image-question-answering'''   )
       self.tool.setup()
       snake_case_			= load_tool('''image-question-answering'''						, remote=_UpperCAmelCase   )



 def 		UpperCamelCase__	(      self   ):
       snake_case_			= Image.open(Path(get_tests_dir('''fixtures/tests_samples/COCO'''   )   ) / '''000000039769.png'''   )
       snake_case_			= self.tool(_UpperCAmelCase						, '''How many cats are sleeping on the couch?'''   )
       self.assertEqual(_UpperCAmelCase						, '''2'''   )



 def 		UpperCamelCase__	(      self   ):
       snake_case_			= Image.open(Path(get_tests_dir('''fixtures/tests_samples/COCO'''   )   ) / '''000000039769.png'''   )
       snake_case_			= self.remote_tool(_UpperCAmelCase						, '''How many cats are sleeping on the couch?'''   )
       self.assertEqual(_UpperCAmelCase						, '''2'''   )



 def 		UpperCamelCase__	(      self   ):
       snake_case_			= Image.open(Path(get_tests_dir('''fixtures/tests_samples/COCO'''   )   ) / '''000000039769.png'''   )
       snake_case_			= self.tool(image=_UpperCAmelCase						, question='''How many cats are sleeping on the couch?'''   )
       self.assertEqual(_UpperCAmelCase						, '''2'''   )





 def 		UpperCamelCase__	(      self   ):
       snake_case_			= Image.open(Path(get_tests_dir('''fixtures/tests_samples/COCO'''   )   ) / '''000000039769.png'''   )
       snake_case_			= self.remote_tool(image=_UpperCAmelCase						, question='''How many cats are sleeping on the couch?'''   )
       self.assertEqual(_UpperCAmelCase						, '''2'''   )