code: 
  
  
  
  
  
  
  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 ,   a    ):
  
  
  
        """simple docstring"""
  
  
  
  
  
  
        def 						UpperCAmelCase		( self   )       ->   Union[str, Any]:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          __snake_case   :				Dict        =       load_tool("image-captioning"   )
          self.tool.setup()
          __snake_case   :				List[str]        =       load_tool("image-captioning"				,						remote=UpperCAmelCase   )
  
  
  
  
  
  
  
        def 						UpperCAmelCase		( self   )       ->   int:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          __snake_case   :				List[Any]        =       Image.open(Path(get_tests_dir("fixtures/tests_samples/COCO"   )   ) / "000000039769.png"   )
          __snake_case   :				Dict        =       self.tool(UpperCAmelCase   )
          self.assertEqual(UpperCAmelCase				,						"two cats sleeping on a couch"   )
  
  
  
  
  
  
  
        def 						UpperCAmelCase		( self   )       ->   str:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          __snake_case   :				Union[str, Any]        =       Image.open(Path(get_tests_dir("fixtures/tests_samples/COCO"   )   ) / "000000039769.png"   )
          __snake_case   :				Dict        =       self.remote_tool(UpperCAmelCase   )
          self.assertEqual(UpperCAmelCase				,						"two cats sleeping on a couch"   )
  
  
  
  
  
  
  
        def 						UpperCAmelCase		( self   )       ->   List[str]:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          __snake_case   :				Optional[int]        =       Image.open(Path(get_tests_dir("fixtures/tests_samples/COCO"   )   ) / "000000039769.png"   )
          __snake_case   :				List[Any]        =       self.tool(image=UpperCAmelCase   )
          self.assertEqual(UpperCAmelCase				,						"two cats sleeping on a couch"   )
  
  
  
  
  
  
  
        def 						UpperCAmelCase		( self   )       ->   Dict:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          __snake_case   :				Optional[Any]        =       Image.open(Path(get_tests_dir("fixtures/tests_samples/COCO"   )   ) / "000000039769.png"   )
          __snake_case   :				Optional[int]        =       self.remote_tool(image=UpperCAmelCase   )
          self.assertEqual(UpperCAmelCase				,						"two cats sleeping on a couch"   )
  
  
style_context: 
  
  
  
  
  
  from typing import TYPE_CHECKING
  
  from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available
  
  
  _UpperCamelCase       = {
      '''configuration_deta''': ['''DETA_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''DetaConfig'''],
  }
  
  try:
       if not is_vision_available():
            raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
       pass
  else:
       _UpperCamelCase       = ['''DetaImageProcessor''']
  
  try:
       if not is_torch_available():
            raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
       pass
  else:
       _UpperCamelCase       = [
           '''DETA_PRETRAINED_MODEL_ARCHIVE_LIST''',
           '''DetaForObjectDetection''',
           '''DetaModel''',
           '''DetaPreTrainedModel''',
       ]
  
  
  if TYPE_CHECKING:
       from .configuration_deta import DETA_PRETRAINED_CONFIG_ARCHIVE_MAP, DetaConfig
  
       try:
            if not is_vision_available():
                 raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
            pass
       else:
            from .image_processing_deta import DetaImageProcessor
  
       try:
            if not is_torch_available():
                 raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
            pass
       else:
            from .modeling_deta import (
                DETA_PRETRAINED_MODEL_ARCHIVE_LIST,
                DetaForObjectDetection,
                DetaModel,
                DetaPreTrainedModel,
            )
  
  else:
       import sys
  
       _UpperCamelCase       = _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)
  
  