




from collections import OrderedDict

from ...utils import logging
from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update
from .configuration_auto import CONFIG_MAPPING_NAMES


UpperCamelCase__    			=			logging.get_logger(__name__)


UpperCamelCase__    			=			OrderedDict(
    [
        # Base model mapping
        ("""albert""", """FlaxAlbertModel"""),
        ("""bart""", """FlaxBartModel"""),
        ("""beit""", """FlaxBeitModel"""),
        ("""bert""", """FlaxBertModel"""),
        ("""big_bird""", """FlaxBigBirdModel"""),
        ("""blenderbot""", """FlaxBlenderbotModel"""),
        ("""blenderbot-small""", """FlaxBlenderbotSmallModel"""),
        ("""clip""", """FlaxCLIPModel"""),
        ("""distilbert""", """FlaxDistilBertModel"""),
        ("""electra""", """FlaxElectraModel"""),
        ("""gpt-sw3""", """FlaxGPT2Model"""),
        ("""gpt2""", """FlaxGPT2Model"""),
        ("""gpt_neo""", """FlaxGPTNeoModel"""),
        ("""gptj""", """FlaxGPTJModel"""),
        ("""longt5""", """FlaxLongT5Model"""),
        ("""marian""", """FlaxMarianModel"""),
        ("""mbart""", """FlaxMBartModel"""),
        ("""mt5""", """FlaxMT5Model"""),
        ("""opt""", """FlaxOPTModel"""),
        ("""pegasus""", """FlaxPegasusModel"""),
        ("""regnet""", """FlaxRegNetModel"""),
        ("""resnet""", """FlaxResNetModel"""),
        ("""roberta""", """FlaxRobertaModel"""),
        ("""roberta-prelayernorm""", """FlaxRobertaPreLayerNormModel"""),
        ("""roformer""", """FlaxRoFormerModel"""),
        ("""t5""", """FlaxT5Model"""),
        ("""vision-text-dual-encoder""", """FlaxVisionTextDualEncoderModel"""),
        ("""vit""", """FlaxViTModel"""),
        ("""wav2vec2""", """FlaxWav2Vec2Model"""),
        ("""whisper""", """FlaxWhisperModel"""),
        ("""xglm""", """FlaxXGLMModel"""),
        ("""xlm-roberta""", """FlaxXLMRobertaModel"""),
    ]
)

UpperCamelCase__    			=			OrderedDict(
    [
        # Model for pre-training mapping
        ("""albert""", """FlaxAlbertForPreTraining"""),
        ("""bart""", """FlaxBartForConditionalGeneration"""),
        ("""bert""", """FlaxBertForPreTraining"""),
        ("""big_bird""", """FlaxBigBirdForPreTraining"""),
        ("""electra""", """FlaxElectraForPreTraining"""),
        ("""longt5""", """FlaxLongT5ForConditionalGeneration"""),
        ("""mbart""", """FlaxMBartForConditionalGeneration"""),
        ("""mt5""", """FlaxMT5ForConditionalGeneration"""),
        ("""roberta""", """FlaxRobertaForMaskedLM"""),
        ("""roberta-prelayernorm""", """FlaxRobertaPreLayerNormForMaskedLM"""),
        ("""roformer""", """FlaxRoFormerForMaskedLM"""),
        ("""t5""", """FlaxT5ForConditionalGeneration"""),
        ("""wav2vec2""", """FlaxWav2Vec2ForPreTraining"""),
        ("""whisper""", """FlaxWhisperForConditionalGeneration"""),
        ("""xlm-roberta""", """FlaxXLMRobertaForMaskedLM"""),
    ]
)

UpperCamelCase__    			=			OrderedDict(
    [
        # Model for Masked LM mapping
        ("""albert""", """FlaxAlbertForMaskedLM"""),
        ("""bart""", """FlaxBartForConditionalGeneration"""),
        ("""bert""", """FlaxBertForMaskedLM"""),
        ("""big_bird""", """FlaxBigBirdForMaskedLM"""),
        ("""distilbert""", """FlaxDistilBertForMaskedLM"""),
        ("""electra""", """FlaxElectraForMaskedLM"""),
        ("""mbart""", """FlaxMBartForConditionalGeneration"""),
        ("""roberta""", """FlaxRobertaForMaskedLM"""),
        ("""roberta-prelayernorm""", """FlaxRobertaPreLayerNormForMaskedLM"""),
        ("""roformer""", """FlaxRoFormerForMaskedLM"""),
        ("""xlm-roberta""", """FlaxXLMRobertaForMaskedLM"""),
    ]
)

UpperCamelCase__    			=			OrderedDict(
    [
        # Model for Seq2Seq Causal LM mapping
        ("""bart""", """FlaxBartForConditionalGeneration"""),
        ("""blenderbot""", """FlaxBlenderbotForConditionalGeneration"""),
        ("""blenderbot-small""", """FlaxBlenderbotSmallForConditionalGeneration"""),
        ("""encoder-decoder""", """FlaxEncoderDecoderModel"""),
        ("""longt5""", """FlaxLongT5ForConditionalGeneration"""),
        ("""marian""", """FlaxMarianMTModel"""),
        ("""mbart""", """FlaxMBartForConditionalGeneration"""),
        ("""mt5""", """FlaxMT5ForConditionalGeneration"""),
        ("""pegasus""", """FlaxPegasusForConditionalGeneration"""),
        ("""t5""", """FlaxT5ForConditionalGeneration"""),
    ]
)

UpperCamelCase__    			=			OrderedDict(
    [
        # Model for Image-classsification
        ("""beit""", """FlaxBeitForImageClassification"""),
        ("""regnet""", """FlaxRegNetForImageClassification"""),
        ("""resnet""", """FlaxResNetForImageClassification"""),
        ("""vit""", """FlaxViTForImageClassification"""),
    ]
)

UpperCamelCase__    			=			OrderedDict(
    [
        ("""vision-encoder-decoder""", """FlaxVisionEncoderDecoderModel"""),
    ]
)

UpperCamelCase__    			=			OrderedDict(
    [
        # Model for Causal LM mapping
        ("""bart""", """FlaxBartForCausalLM"""),
        ("""bert""", """FlaxBertForCausalLM"""),
        ("""big_bird""", """FlaxBigBirdForCausalLM"""),
        ("""electra""", """FlaxElectraForCausalLM"""),
        ("""gpt-sw3""", """FlaxGPT2LMHeadModel"""),
        ("""gpt2""", """FlaxGPT2LMHeadModel"""),
        ("""gpt_neo""", """FlaxGPTNeoForCausalLM"""),
        ("""gptj""", """FlaxGPTJForCausalLM"""),
        ("""opt""", """FlaxOPTForCausalLM"""),
        ("""roberta""", """FlaxRobertaForCausalLM"""),
        ("""roberta-prelayernorm""", """FlaxRobertaPreLayerNormForCausalLM"""),
        ("""xglm""", """FlaxXGLMForCausalLM"""),
        ("""xlm-roberta""", """FlaxXLMRobertaForCausalLM"""),
    ]
)

UpperCamelCase__    			=			OrderedDict(
    [
        # Model for Sequence Classification mapping
        ("""albert""", """FlaxAlbertForSequenceClassification"""),
        ("""bart""", """FlaxBartForSequenceClassification"""),
        ("""bert""", """FlaxBertForSequenceClassification"""),
        ("""big_bird""", """FlaxBigBirdForSequenceClassification"""),
        ("""distilbert""", """FlaxDistilBertForSequenceClassification"""),
        ("""electra""", """FlaxElectraForSequenceClassification"""),
        ("""mbart""", """FlaxMBartForSequenceClassification"""),
        ("""roberta""", """FlaxRobertaForSequenceClassification"""),
        ("""roberta-prelayernorm""", """FlaxRobertaPreLayerNormForSequenceClassification"""),
        ("""roformer""", """FlaxRoFormerForSequenceClassification"""),
        ("""xlm-roberta""", """FlaxXLMRobertaForSequenceClassification"""),
    ]
)

UpperCamelCase__    			=			OrderedDict(
    [
        # Model for Question Answering mapping
        ("""albert""", """FlaxAlbertForQuestionAnswering"""),
        ("""bart""", """FlaxBartForQuestionAnswering"""),
        ("""bert""", """FlaxBertForQuestionAnswering"""),
        ("""big_bird""", """FlaxBigBirdForQuestionAnswering"""),
        ("""distilbert""", """FlaxDistilBertForQuestionAnswering"""),
        ("""electra""", """FlaxElectraForQuestionAnswering"""),
        ("""mbart""", """FlaxMBartForQuestionAnswering"""),
        ("""roberta""", """FlaxRobertaForQuestionAnswering"""),
        ("""roberta-prelayernorm""", """FlaxRobertaPreLayerNormForQuestionAnswering"""),
        ("""roformer""", """FlaxRoFormerForQuestionAnswering"""),
        ("""xlm-roberta""", """FlaxXLMRobertaForQuestionAnswering"""),
    ]
)

UpperCamelCase__    			=			OrderedDict(
    [
        # Model for Token Classification mapping
        ("""albert""", """FlaxAlbertForTokenClassification"""),
        ("""bert""", """FlaxBertForTokenClassification"""),
        ("""big_bird""", """FlaxBigBirdForTokenClassification"""),
        ("""distilbert""", """FlaxDistilBertForTokenClassification"""),
        ("""electra""", """FlaxElectraForTokenClassification"""),
        ("""roberta""", """FlaxRobertaForTokenClassification"""),
        ("""roberta-prelayernorm""", """FlaxRobertaPreLayerNormForTokenClassification"""),
        ("""roformer""", """FlaxRoFormerForTokenClassification"""),
        ("""xlm-roberta""", """FlaxXLMRobertaForTokenClassification"""),
    ]
)

UpperCamelCase__    			=			OrderedDict(
    [
        # Model for Multiple Choice mapping
        ("""albert""", """FlaxAlbertForMultipleChoice"""),
        ("""bert""", """FlaxBertForMultipleChoice"""),
        ("""big_bird""", """FlaxBigBirdForMultipleChoice"""),
        ("""distilbert""", """FlaxDistilBertForMultipleChoice"""),
        ("""electra""", """FlaxElectraForMultipleChoice"""),
        ("""roberta""", """FlaxRobertaForMultipleChoice"""),
        ("""roberta-prelayernorm""", """FlaxRobertaPreLayerNormForMultipleChoice"""),
        ("""roformer""", """FlaxRoFormerForMultipleChoice"""),
        ("""xlm-roberta""", """FlaxXLMRobertaForMultipleChoice"""),
    ]
)

UpperCamelCase__    			=			OrderedDict(
    [
        ("""bert""", """FlaxBertForNextSentencePrediction"""),
    ]
)

UpperCamelCase__    			=			OrderedDict(
    [
        ("""speech-encoder-decoder""", """FlaxSpeechEncoderDecoderModel"""),
        ("""whisper""", """FlaxWhisperForConditionalGeneration"""),
    ]
)

UpperCamelCase__    			=			OrderedDict(
    [
        ("""whisper""", """FlaxWhisperForAudioClassification"""),
    ]
)

UpperCamelCase__    			=			_LazyAutoMapping(CONFIG_MAPPING_NAMES, FLAX_MODEL_MAPPING_NAMES)
UpperCamelCase__    			=			_LazyAutoMapping(CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_PRETRAINING_MAPPING_NAMES)
UpperCamelCase__    			=			_LazyAutoMapping(CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_MASKED_LM_MAPPING_NAMES)
UpperCamelCase__    			=			_LazyAutoMapping(
    CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES
)
UpperCamelCase__    			=			_LazyAutoMapping(
    CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES
)
UpperCamelCase__    			=			_LazyAutoMapping(CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES)
UpperCamelCase__    			=			_LazyAutoMapping(CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_CAUSAL_LM_MAPPING_NAMES)
UpperCamelCase__    			=			_LazyAutoMapping(
    CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES
)
UpperCamelCase__    			=			_LazyAutoMapping(
    CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES
)
UpperCamelCase__    			=			_LazyAutoMapping(
    CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES
)
UpperCamelCase__    			=			_LazyAutoMapping(
    CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_MULTIPLE_CHOICE_MAPPING_NAMES
)
UpperCamelCase__    			=			_LazyAutoMapping(
    CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_NEXT_SENTENCE_PREDICTION_MAPPING_NAMES
)
UpperCamelCase__    			=			_LazyAutoMapping(
    CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES
)
UpperCamelCase__    			=			_LazyAutoMapping(
    CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES
)
class 			a__    (					_BaseAutoModelClass      ):
						_a							:    Tuple					=    FLAX_MODEL_MAPPING






UpperCamelCase__    			=			auto_class_update(FlaxAutoModel)
class 			a__    (					_BaseAutoModelClass      ):
						_a							:    Any					=    FLAX_MODEL_FOR_PRETRAINING_MAPPING






UpperCamelCase__    			=			auto_class_update(FlaxAutoModelForPreTraining, head_doc="""pretraining""")
class 			a__    (					_BaseAutoModelClass      ):
						_a							:    List[Any]					=    FLAX_MODEL_FOR_CAUSAL_LM_MAPPING






UpperCamelCase__    			=			auto_class_update(FlaxAutoModelForCausalLM, head_doc="""causal language modeling""")
class 			a__    (					_BaseAutoModelClass      ):
						_a							:    Optional[int]					=    FLAX_MODEL_FOR_MASKED_LM_MAPPING






UpperCamelCase__    			=			auto_class_update(FlaxAutoModelForMaskedLM, head_doc="""masked language modeling""")
class 			a__    (					_BaseAutoModelClass      ):
						_a							:    Dict					=    FLAX_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING






UpperCamelCase__    			=			auto_class_update(
    FlaxAutoModelForSeqaSeqLM, head_doc="""sequence-to-sequence language modeling""", checkpoint_for_example="""t5-base"""
)
class 			a__    (					_BaseAutoModelClass      ):
						_a							:    Any					=    FLAX_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING






UpperCamelCase__    			=			auto_class_update(
    FlaxAutoModelForSequenceClassification, head_doc="""sequence classification"""
)
class 			a__    (					_BaseAutoModelClass      ):
						_a							:    int					=    FLAX_MODEL_FOR_QUESTION_ANSWERING_MAPPING






UpperCamelCase__    			=			auto_class_update(FlaxAutoModelForQuestionAnswering, head_doc="""question answering""")
class 			a__    (					_BaseAutoModelClass      ):
						_a							:    Tuple					=    FLAX_MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING






UpperCamelCase__    			=			auto_class_update(
    FlaxAutoModelForTokenClassification, head_doc="""token classification"""
)
class 			a__    (					_BaseAutoModelClass      ):
						_a							:    int					=    FLAX_MODEL_FOR_MULTIPLE_CHOICE_MAPPING






UpperCamelCase__    			=			auto_class_update(FlaxAutoModelForMultipleChoice, head_doc="""multiple choice""")
class 			a__    (					_BaseAutoModelClass      ):
						_a							:    List[Any]					=    FLAX_MODEL_FOR_NEXT_SENTENCE_PREDICTION_MAPPING






UpperCamelCase__    			=			auto_class_update(
    FlaxAutoModelForNextSentencePrediction, head_doc="""next sentence prediction"""
)
class 			a__    (					_BaseAutoModelClass      ):
						_a							:    Tuple					=    FLAX_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING






UpperCamelCase__    			=			auto_class_update(
    FlaxAutoModelForImageClassification, head_doc="""image classification"""
)
class 			a__    (					_BaseAutoModelClass      ):
						_a							:    int					=    FLAX_MODEL_FOR_VISION_2_SEQ_MAPPING






UpperCamelCase__    			=			auto_class_update(FlaxAutoModelForVisionaSeq, head_doc="""vision-to-text modeling""")
class 			a__    (					_BaseAutoModelClass      ):
						_a							:    int					=    FLAX_MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING






UpperCamelCase__    			=			auto_class_update(
    FlaxAutoModelForSpeechSeqaSeq, head_doc="""sequence-to-sequence speech-to-text modeling"""
)











'''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}},
              ]						,	)