





'''simple docstring'''






import unittest

from transformers import MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING, is_vision_available, pipeline
from transformers.testing_utils import (
    is_pipeline_test,
    nested_simplify,
    require_tf,
    require_torch,
    require_vision,
    slow,
)

from .test_pipelines_common import ANY


if is_vision_available():
      from PIL import Image
else:




      class  UpperCAmelCase     :




            @staticmethod
            def 				lowercase__    (			*__snake_case			: Union[str, Any]			,			**__snake_case			: Tuple  )				->      Any:
                  pass




@is_pipeline_test
@require_vision
@require_torch
class  UpperCAmelCase     (			unittest.TestCase   ):
      _lowercase:			Any						     =   MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING




      def 				lowercase__    (			self			: str			,			__snake_case			: Any			,			__snake_case			: int			,			__snake_case			: str  )				->      Optional[Any]:
            _lowerCAmelCase							     =							pipeline(
                """zero-shot-object-detection"""			,			model="""hf-internal-testing/tiny-random-owlvit-object-detection"""  )

            _lowerCAmelCase							     =							[
                {
                    """image""": """./tests/fixtures/tests_samples/COCO/000000039769.png""",
                    """candidate_labels""": ["""cat""", """remote""", """couch"""],
                }
            ]
            return object_detector, examples




      def 				lowercase__    (			self			: Dict			,			__snake_case			: Any			,			__snake_case			: List[str]  )				->      Dict:
            _lowerCAmelCase							     =							object_detector(examples[0]			,			threshold=0.0  )

            _lowerCAmelCase							     =							len(__snake_case  )
            self.assertGreater(__snake_case			,			0  )
            self.assertEqual(
                __snake_case			,			[
                    {
                        """score""": ANY(__snake_case  ),
                        """label""": ANY(__snake_case  ),
                        """box""": {"""xmin""": ANY(__snake_case  ), """ymin""": ANY(__snake_case  ), """xmax""": ANY(__snake_case  ), """ymax""": ANY(__snake_case  )},
                    }
                    for i in range(__snake_case  )
                ]			,			)




      @require_tf
      @unittest.skip("""Zero Shot Object Detection not implemented in TF"""  )
      def 				lowercase__    (			self			: int  )				->      Optional[int]:
            pass




      @require_torch
      def 				lowercase__    (			self			: List[str]  )				->      Union[str, Any]:
            _lowerCAmelCase							     =							pipeline(
                """zero-shot-object-detection"""			,			model="""hf-internal-testing/tiny-random-owlvit-object-detection"""  )

            _lowerCAmelCase							     =							object_detector(
                """./tests/fixtures/tests_samples/COCO/000000039769.png"""			,			candidate_labels=["""cat""", """remote""", """couch"""]			,			threshold=0.64			,			)

            self.assertEqual(
                nested_simplify(__snake_case			,			decimals=4  )			,			[
                    {"""score""": 0.72_35, """label""": """cat""", """box""": {"""xmin""": 2_04, """ymin""": 1_67, """xmax""": 2_32, """ymax""": 1_90}},
                    {"""score""": 0.72_18, """label""": """remote""", """box""": {"""xmin""": 2_04, """ymin""": 1_67, """xmax""": 2_32, """ymax""": 1_90}},
                    {"""score""": 0.71_84, """label""": """couch""", """box""": {"""xmin""": 2_04, """ymin""": 1_67, """xmax""": 2_32, """ymax""": 1_90}},
                    {"""score""": 0.67_48, """label""": """remote""", """box""": {"""xmin""": 5_71, """ymin""": 83, """xmax""": 5_98, """ymax""": 1_03}},
                    {"""score""": 0.66_56, """label""": """cat""", """box""": {"""xmin""": 5_71, """ymin""": 83, """xmax""": 5_98, """ymax""": 1_03}},
                    {"""score""": 0.66_14, """label""": """couch""", """box""": {"""xmin""": 5_71, """ymin""": 83, """xmax""": 5_98, """ymax""": 1_03}},
                    {"""score""": 0.64_56, """label""": """remote""", """box""": {"""xmin""": 4_94, """ymin""": 1_05, """xmax""": 5_21, """ymax""": 1_27}},
                    {"""score""": 0.6_42, """label""": """remote""", """box""": {"""xmin""": 67, """ymin""": 2_74, """xmax""": 93, """ymax""": 2_97}},
                    {"""score""": 0.64_19, """label""": """cat""", """box""": {"""xmin""": 4_94, """ymin""": 1_05, """xmax""": 5_21, """ymax""": 1_27}},
                ]			,			)

            _lowerCAmelCase							     =							object_detector(
                [
                    {
                        """image""": """./tests/fixtures/tests_samples/COCO/000000039769.png""",
                        """candidate_labels""": ["""cat""", """remote""", """couch"""],
                    }
                ]			,			threshold=0.64			,			)

            self.assertEqual(
                nested_simplify(__snake_case			,			decimals=4  )			,			[
                    [
                        {"""score""": 0.72_35, """label""": """cat""", """box""": {"""xmin""": 2_04, """ymin""": 1_67, """xmax""": 2_32, """ymax""": 1_90}},
                        {"""score""": 0.72_18, """label""": """remote""", """box""": {"""xmin""": 2_04, """ymin""": 1_67, """xmax""": 2_32, """ymax""": 1_90}},
                        {"""score""": 0.71_84, """label""": """couch""", """box""": {"""xmin""": 2_04, """ymin""": 1_67, """xmax""": 2_32, """ymax""": 1_90}},
                        {"""score""": 0.67_48, """label""": """remote""", """box""": {"""xmin""": 5_71, """ymin""": 83, """xmax""": 5_98, """ymax""": 1_03}},
                        {"""score""": 0.66_56, """label""": """cat""", """box""": {"""xmin""": 5_71, """ymin""": 83, """xmax""": 5_98, """ymax""": 1_03}},
                        {"""score""": 0.66_14, """label""": """couch""", """box""": {"""xmin""": 5_71, """ymin""": 83, """xmax""": 5_98, """ymax""": 1_03}},
                        {"""score""": 0.64_56, """label""": """remote""", """box""": {"""xmin""": 4_94, """ymin""": 1_05, """xmax""": 5_21, """ymax""": 1_27}},
                        {"""score""": 0.6_42, """label""": """remote""", """box""": {"""xmin""": 67, """ymin""": 2_74, """xmax""": 93, """ymax""": 2_97}},
                        {"""score""": 0.64_19, """label""": """cat""", """box""": {"""xmin""": 4_94, """ymin""": 1_05, """xmax""": 5_21, """ymax""": 1_27}},
                    ]
                ]			,			)




      @require_torch
      @slow
      def 				lowercase__    (			self			: int  )				->      Any:
            _lowerCAmelCase							     =							pipeline("""zero-shot-object-detection"""  )

            _lowerCAmelCase							     =							object_detector(
                """http://images.cocodataset.org/val2017/000000039769.jpg"""			,			candidate_labels=["""cat""", """remote""", """couch"""]			,			)
            self.assertEqual(
                nested_simplify(__snake_case			,			decimals=4  )			,			[
                    {"""score""": 0.28_68, """label""": """cat""", """box""": {"""xmin""": 3_24, """ymin""": 20, """xmax""": 6_40, """ymax""": 3_73}},
                    {"""score""": 0.2_77, """label""": """remote""", """box""": {"""xmin""": 40, """ymin""": 72, """xmax""": 1_77, """ymax""": 1_15}},
                    {"""score""": 0.25_37, """label""": """cat""", """box""": {"""xmin""": 1, """ymin""": 55, """xmax""": 3_15, """ymax""": 4_72}},
                    {"""score""": 0.14_74, """label""": """remote""", """box""": {"""xmin""": 3_35, """ymin""": 74, """xmax""": 3_71, """ymax""": 1_87}},
                    {"""score""": 0.12_08, """label""": """couch""", """box""": {"""xmin""": 4, """ymin""": 0, """xmax""": 6_42, """ymax""": 4_76}},
                ]			,			)

            _lowerCAmelCase							     =							object_detector(
                [
                    {
                        """image""": """http://images.cocodataset.org/val2017/000000039769.jpg""",
                        """candidate_labels""": ["""cat""", """remote""", """couch"""],
                    },
                    {
                        """image""": """http://images.cocodataset.org/val2017/000000039769.jpg""",
                        """candidate_labels""": ["""cat""", """remote""", """couch"""],
                    },
                ]			,			)
            self.assertEqual(
                nested_simplify(__snake_case			,			decimals=4  )			,			[
                    [
                        {"""score""": 0.28_68, """label""": """cat""", """box""": {"""xmin""": 3_24, """ymin""": 20, """xmax""": 6_40, """ymax""": 3_73}},
                        {"""score""": 0.2_77, """label""": """remote""", """box""": {"""xmin""": 40, """ymin""": 72, """xmax""": 1_77, """ymax""": 1_15}},
                        {"""score""": 0.25_37, """label""": """cat""", """box""": {"""xmin""": 1, """ymin""": 55, """xmax""": 3_15, """ymax""": 4_72}},
                        {"""score""": 0.14_74, """label""": """remote""", """box""": {"""xmin""": 3_35, """ymin""": 74, """xmax""": 3_71, """ymax""": 1_87}},
                        {"""score""": 0.12_08, """label""": """couch""", """box""": {"""xmin""": 4, """ymin""": 0, """xmax""": 6_42, """ymax""": 4_76}},
                    ],
                    [
                        {"""score""": 0.28_68, """label""": """cat""", """box""": {"""xmin""": 3_24, """ymin""": 20, """xmax""": 6_40, """ymax""": 3_73}},
                        {"""score""": 0.2_77, """label""": """remote""", """box""": {"""xmin""": 40, """ymin""": 72, """xmax""": 1_77, """ymax""": 1_15}},
                        {"""score""": 0.25_37, """label""": """cat""", """box""": {"""xmin""": 1, """ymin""": 55, """xmax""": 3_15, """ymax""": 4_72}},
                        {"""score""": 0.14_74, """label""": """remote""", """box""": {"""xmin""": 3_35, """ymin""": 74, """xmax""": 3_71, """ymax""": 1_87}},
                        {"""score""": 0.12_08, """label""": """couch""", """box""": {"""xmin""": 4, """ymin""": 0, """xmax""": 6_42, """ymax""": 4_76}},
                    ],
                ]			,			)




      @require_tf
      @unittest.skip("""Zero Shot Object Detection not implemented in TF"""  )
      def 				lowercase__    (			self			: Any  )				->      Optional[Any]:
            pass




      @require_torch
      @slow
      def 				lowercase__    (			self			: List[str]  )				->      str:
            _lowerCAmelCase							     =							0.2
            _lowerCAmelCase							     =							pipeline("""zero-shot-object-detection"""  )

            _lowerCAmelCase							     =							object_detector(
                """http://images.cocodataset.org/val2017/000000039769.jpg"""			,			candidate_labels=["""cat""", """remote""", """couch"""]			,			threshold=__snake_case			,			)
            self.assertEqual(
                nested_simplify(__snake_case			,			decimals=4  )			,			[
                    {"""score""": 0.28_68, """label""": """cat""", """box""": {"""xmin""": 3_24, """ymin""": 20, """xmax""": 6_40, """ymax""": 3_73}},
                    {"""score""": 0.2_77, """label""": """remote""", """box""": {"""xmin""": 40, """ymin""": 72, """xmax""": 1_77, """ymax""": 1_15}},
                    {"""score""": 0.25_37, """label""": """cat""", """box""": {"""xmin""": 1, """ymin""": 55, """xmax""": 3_15, """ymax""": 4_72}},
                ]			,			)




      @require_torch
      @slow
      def 				lowercase__    (			self			: int  )				->      int:
            _lowerCAmelCase							     =							2
            _lowerCAmelCase							     =							pipeline("""zero-shot-object-detection"""  )

            _lowerCAmelCase							     =							object_detector(
                """http://images.cocodataset.org/val2017/000000039769.jpg"""			,			candidate_labels=["""cat""", """remote""", """couch"""]			,			top_k=__snake_case			,			)
            self.assertEqual(
                nested_simplify(__snake_case			,			decimals=4  )			,			[
                    {"""score""": 0.28_68, """label""": """cat""", """box""": {"""xmin""": 3_24, """ymin""": 20, """xmax""": 6_40, """ymax""": 3_73}},
                    {"""score""": 0.2_77, """label""": """remote""", """box""": {"""xmin""": 40, """ymin""": 72, """xmax""": 1_77, """ymax""": 1_15}},
                ]			,			)













'''simple docstring'''




import unittest

from transformers import (
    MODEL_FOR_OBJECT_DETECTION_MAPPING,
    AutoFeatureExtractor,
    AutoModelForObjectDetection,
    ObjectDetectionPipeline,
    is_vision_available,
    pipeline,
)
from transformers.testing_utils import (
    is_pipeline_test,
    nested_simplify,
    require_pytesseract,
    require_tf,
    require_timm,
    require_torch,
    require_vision,
    slow,
)

from .test_pipelines_common import ANY


if is_vision_available():
  from PIL import Image
else:


  class  SCREAMING_SNAKE_CASE    :


       @staticmethod
       def 							SCREAMING_SNAKE_CASE  (						*_UpperCAmelCase						,	**_UpperCAmelCase):

            '''simple docstring'''






            pass


@is_pipeline_test
@require_vision
@require_timm
@require_torch
class  SCREAMING_SNAKE_CASE    (unittest.TestCase							):
     lowerCAmelCase					=       MODEL_FOR_OBJECT_DETECTION_MAPPING


     def 							SCREAMING_SNAKE_CASE  (						self						,	_UpperCAmelCase						,	_UpperCAmelCase						,	_UpperCAmelCase):

          '''simple docstring'''






          __A						: Dict      =       ObjectDetectionPipeline(model=_UpperCAmelCase						,	image_processor=_UpperCAmelCase)
          return object_detector, ["./tests/fixtures/tests_samples/COCO/000000039769.png"]


     def 							SCREAMING_SNAKE_CASE  (						self						,	_UpperCAmelCase						,	_UpperCAmelCase):

          '''simple docstring'''






          __A						: str      =       object_detector('./tests/fixtures/tests_samples/COCO/000000039769.png'						,	threshold=0.0)

          self.assertGreater(len(_UpperCAmelCase)						,	0)
          for detected_object in outputs:
               self.assertEqual(
                   _UpperCAmelCase						,	{
                       'score': ANY(_UpperCAmelCase),
                       'label': ANY(_UpperCAmelCase),
                       'box': {'xmin': ANY(_UpperCAmelCase), 'ymin': ANY(_UpperCAmelCase), 'xmax': ANY(_UpperCAmelCase), 'ymax': ANY(_UpperCAmelCase)},
                   }						,	)

          import datasets

          __A						: Tuple      =       datasets.load_dataset('hf-internal-testing/fixtures_image_utils'						,	'image'						,	split='test')

          __A						: List[str]      =       [
              Image.open('./tests/fixtures/tests_samples/COCO/000000039769.png'),
              'http://images.cocodataset.org/val2017/000000039769.jpg',
              # RGBA
              dataset[0]['file'],
              # LA
              dataset[1]['file'],
              # L
              dataset[2]['file'],
          ]
          __A						: Union[str, Any]      =       object_detector(_UpperCAmelCase						,	threshold=0.0)

          self.assertEqual(len(_UpperCAmelCase)						,	len(_UpperCAmelCase))
          for outputs in batch_outputs:
               self.assertGreater(len(_UpperCAmelCase)						,	0)
               for detected_object in outputs:
                    self.assertEqual(
                        _UpperCAmelCase						,	{
                            'score': ANY(_UpperCAmelCase),
                            'label': ANY(_UpperCAmelCase),
                            'box': {'xmin': ANY(_UpperCAmelCase), 'ymin': ANY(_UpperCAmelCase), 'xmax': ANY(_UpperCAmelCase), 'ymax': ANY(_UpperCAmelCase)},
                        }						,	)


     @require_tf
     @unittest.skip('Object detection not implemented in TF')
     def 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          pass


     @require_torch
     def 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          __A						: List[str]      =       'hf-internal-testing/tiny-detr-mobilenetsv3'

          __A						: Any      =       AutoModelForObjectDetection.from_pretrained(_UpperCAmelCase)
          __A						: int      =       AutoFeatureExtractor.from_pretrained(_UpperCAmelCase)
          __A						: Any      =       ObjectDetectionPipeline(model=_UpperCAmelCase						,	feature_extractor=_UpperCAmelCase)

          __A						: Dict      =       object_detector('http://images.cocodataset.org/val2017/000000039769.jpg'						,	threshold=0.0)

          self.assertEqual(
              nested_simplify(_UpperCAmelCase						,	decimals=4)						,	[
                  {'score': 0.3376, 'label': 'LABEL_0', 'box': {'xmin': 159, 'ymin': 120, 'xmax': 480, 'ymax': 359}},
                  {'score': 0.3376, 'label': 'LABEL_0', 'box': {'xmin': 159, 'ymin': 120, 'xmax': 480, 'ymax': 359}},
              ]						,	)

          __A						: Optional[Any]      =       object_detector(
              [
                  'http://images.cocodataset.org/val2017/000000039769.jpg',
                  'http://images.cocodataset.org/val2017/000000039769.jpg',
              ]						,	threshold=0.0						,	)

          self.assertEqual(
              nested_simplify(_UpperCAmelCase						,	decimals=4)						,	[
                  [
                      {'score': 0.3376, 'label': 'LABEL_0', 'box': {'xmin': 159, 'ymin': 120, 'xmax': 480, 'ymax': 359}},
                      {'score': 0.3376, 'label': 'LABEL_0', 'box': {'xmin': 159, 'ymin': 120, 'xmax': 480, 'ymax': 359}},
                  ],
                  [
                      {'score': 0.3376, 'label': 'LABEL_0', 'box': {'xmin': 159, 'ymin': 120, 'xmax': 480, 'ymax': 359}},
                      {'score': 0.3376, 'label': 'LABEL_0', 'box': {'xmin': 159, 'ymin': 120, 'xmax': 480, 'ymax': 359}},
                  ],
              ]						,	)


     @require_torch
     @slow
     def 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          __A						: Optional[Any]      =       'facebook/detr-resnet-50'

          __A						: Union[str, Any]      =       AutoModelForObjectDetection.from_pretrained(_UpperCAmelCase)
          __A						: Tuple      =       AutoFeatureExtractor.from_pretrained(_UpperCAmelCase)
          __A						: List[Any]      =       ObjectDetectionPipeline(model=_UpperCAmelCase						,	feature_extractor=_UpperCAmelCase)

          __A						: Union[str, Any]      =       object_detector('http://images.cocodataset.org/val2017/000000039769.jpg')
          self.assertEqual(
              nested_simplify(_UpperCAmelCase						,	decimals=4)						,	[
                  {'score': 0.9982, 'label': 'remote', 'box': {'xmin': 40, 'ymin': 70, 'xmax': 175, 'ymax': 117}},
                  {'score': 0.9960, 'label': 'remote', 'box': {'xmin': 333, 'ymin': 72, 'xmax': 368, 'ymax': 187}},
                  {'score': 0.9955, 'label': 'couch', 'box': {'xmin': 0, 'ymin': 1, 'xmax': 639, 'ymax': 473}},
                  {'score': 0.9988, 'label': 'cat', 'box': {'xmin': 13, 'ymin': 52, 'xmax': 314, 'ymax': 470}},
                  {'score': 0.9987, 'label': 'cat', 'box': {'xmin': 345, 'ymin': 23, 'xmax': 640, 'ymax': 368}},
              ]						,	)

          __A						: Tuple      =       object_detector(
              [
                  'http://images.cocodataset.org/val2017/000000039769.jpg',
                  'http://images.cocodataset.org/val2017/000000039769.jpg',
              ])
          self.assertEqual(
              nested_simplify(_UpperCAmelCase						,	decimals=4)						,	[
                  [
                      {'score': 0.9982, 'label': 'remote', 'box': {'xmin': 40, 'ymin': 70, 'xmax': 175, 'ymax': 117}},
                      {'score': 0.9960, 'label': 'remote', 'box': {'xmin': 333, 'ymin': 72, 'xmax': 368, 'ymax': 187}},
                      {'score': 0.9955, 'label': 'couch', 'box': {'xmin': 0, 'ymin': 1, 'xmax': 639, 'ymax': 473}},
                      {'score': 0.9988, 'label': 'cat', 'box': {'xmin': 13, 'ymin': 52, 'xmax': 314, 'ymax': 470}},
                      {'score': 0.9987, 'label': 'cat', 'box': {'xmin': 345, 'ymin': 23, 'xmax': 640, 'ymax': 368}},
                  ],
                  [
                      {'score': 0.9982, 'label': 'remote', 'box': {'xmin': 40, 'ymin': 70, 'xmax': 175, 'ymax': 117}},
                      {'score': 0.9960, 'label': 'remote', 'box': {'xmin': 333, 'ymin': 72, 'xmax': 368, 'ymax': 187}},
                      {'score': 0.9955, 'label': 'couch', 'box': {'xmin': 0, 'ymin': 1, 'xmax': 639, 'ymax': 473}},
                      {'score': 0.9988, 'label': 'cat', 'box': {'xmin': 13, 'ymin': 52, 'xmax': 314, 'ymax': 470}},
                      {'score': 0.9987, 'label': 'cat', 'box': {'xmin': 345, 'ymin': 23, 'xmax': 640, 'ymax': 368}},
                  ],
              ]						,	)


     @require_torch
     @slow
     def 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          __A						: List[Any]      =       'facebook/detr-resnet-50'

          __A						: str      =       pipeline('object-detection'						,	model=_UpperCAmelCase)

          __A						: Any      =       object_detector('http://images.cocodataset.org/val2017/000000039769.jpg')
          self.assertEqual(
              nested_simplify(_UpperCAmelCase						,	decimals=4)						,	[
                  {'score': 0.9982, 'label': 'remote', 'box': {'xmin': 40, 'ymin': 70, 'xmax': 175, 'ymax': 117}},
                  {'score': 0.9960, 'label': 'remote', 'box': {'xmin': 333, 'ymin': 72, 'xmax': 368, 'ymax': 187}},
                  {'score': 0.9955, 'label': 'couch', 'box': {'xmin': 0, 'ymin': 1, 'xmax': 639, 'ymax': 473}},
                  {'score': 0.9988, 'label': 'cat', 'box': {'xmin': 13, 'ymin': 52, 'xmax': 314, 'ymax': 470}},
                  {'score': 0.9987, 'label': 'cat', 'box': {'xmin': 345, 'ymin': 23, 'xmax': 640, 'ymax': 368}},
              ]						,	)

          __A						: str      =       object_detector(
              [
                  'http://images.cocodataset.org/val2017/000000039769.jpg',
                  'http://images.cocodataset.org/val2017/000000039769.jpg',
              ])
          self.assertEqual(
              nested_simplify(_UpperCAmelCase						,	decimals=4)						,	[
                  [
                      {'score': 0.9982, 'label': 'remote', 'box': {'xmin': 40, 'ymin': 70, 'xmax': 175, 'ymax': 117}},
                      {'score': 0.9960, 'label': 'remote', 'box': {'xmin': 333, 'ymin': 72, 'xmax': 368, 'ymax': 187}},
                      {'score': 0.9955, 'label': 'couch', 'box': {'xmin': 0, 'ymin': 1, 'xmax': 639, 'ymax': 473}},
                      {'score': 0.9988, 'label': 'cat', 'box': {'xmin': 13, 'ymin': 52, 'xmax': 314, 'ymax': 470}},
                      {'score': 0.9987, 'label': 'cat', 'box': {'xmin': 345, 'ymin': 23, 'xmax': 640, 'ymax': 368}},
                  ],
                  [
                      {'score': 0.9982, 'label': 'remote', 'box': {'xmin': 40, 'ymin': 70, 'xmax': 175, 'ymax': 117}},
                      {'score': 0.9960, 'label': 'remote', 'box': {'xmin': 333, 'ymin': 72, 'xmax': 368, 'ymax': 187}},
                      {'score': 0.9955, 'label': 'couch', 'box': {'xmin': 0, 'ymin': 1, 'xmax': 639, 'ymax': 473}},
                      {'score': 0.9988, 'label': 'cat', 'box': {'xmin': 13, 'ymin': 52, 'xmax': 314, 'ymax': 470}},
                      {'score': 0.9987, 'label': 'cat', 'box': {'xmin': 345, 'ymin': 23, 'xmax': 640, 'ymax': 368}},
                  ],
              ]						,	)


     @require_torch
     @slow
     def 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          __A						: List[Any]      =       0.9985
          __A						: List[Any]      =       'facebook/detr-resnet-50'

          __A						: List[str]      =       pipeline('object-detection'						,	model=_UpperCAmelCase)

          __A						: List[Any]      =       object_detector('http://images.cocodataset.org/val2017/000000039769.jpg'						,	threshold=_UpperCAmelCase)
          self.assertEqual(
              nested_simplify(_UpperCAmelCase						,	decimals=4)						,	[
                  {'score': 0.9988, 'label': 'cat', 'box': {'xmin': 13, 'ymin': 52, 'xmax': 314, 'ymax': 470}},
                  {'score': 0.9987, 'label': 'cat', 'box': {'xmin': 345, 'ymin': 23, 'xmax': 640, 'ymax': 368}},
              ]						,	)


     @require_torch
     @require_pytesseract
     @slow
     def 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          __A						: Optional[int]      =       'Narsil/layoutlmv3-finetuned-funsd'
          __A						: Tuple      =       0.9993

          __A						: str      =       pipeline('object-detection'						,	model=_UpperCAmelCase						,	threshold=_UpperCAmelCase)

          __A						: Optional[int]      =       object_detector(
              'https://huggingface.co/spaces/impira/docquery/resolve/2359223c1837a7587402bda0f2643382a6eefeab/invoice.png')
          self.assertEqual(
              nested_simplify(_UpperCAmelCase						,	decimals=4)						,	[
                  {'score': 0.9993, 'label': 'I-ANSWER', 'box': {'xmin': 294, 'ymin': 254, 'xmax': 343, 'ymax': 264}},
                  {'score': 0.9993, 'label': 'I-ANSWER', 'box': {'xmin': 294, 'ymin': 254, 'xmax': 343, 'ymax': 264}},
              ]						,	)