

import unittest

from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available
from transformers.pipelines import pipeline
from transformers.pipelines.document_question_answering import apply_tesseract
from transformers.testing_utils import (
    is_pipeline_test,
    nested_simplify,
    require_detectrona,
    require_pytesseract,
    require_tf,
    require_torch,
    require_vision,
    slow,
)

from .test_pipelines_common import ANY


if is_vision_available():
    from PIL import Image

    from transformers.image_utils import load_image
else:
    class  _A		:

      @staticmethod
      def  UpperCAmelCase    (				*_SCREAMING_SNAKE_CASE ,					**_SCREAMING_SNAKE_CASE					):





            """simple docstring"""







            pass

    def    A_  (							a  ):

          """simple docstring"""



          return None


# This is a pinned image from a specific revision of a document question answering space, hosted by HuggingFace,
# so we can expect it to be available.
lowerCAmelCase     :   Dict						     =  (
    'https://huggingface.co/spaces/impira/docquery/resolve/2f6c96314dc84dfda62d40de9da55f2f5165d403/invoice.png'
)
@is_pipeline_test
@require_torch
@require_vision
class  _A		(  unittest.TestCase):
  SCREAMING_SNAKE_CASE    :      List[str]       =  MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING

  @require_pytesseract
  @require_vision
  def  UpperCAmelCase    (				self ,					_SCREAMING_SNAKE_CASE ,					_SCREAMING_SNAKE_CASE ,					_SCREAMING_SNAKE_CASE					):





        """simple docstring"""







        SCREAMING_SNAKE_CASE_				:  Dict           =     pipeline(
            'document-question-answering' ,					model=_SCREAMING_SNAKE_CASE ,					tokenizer=_SCREAMING_SNAKE_CASE ,					image_processor=_SCREAMING_SNAKE_CASE					)

        SCREAMING_SNAKE_CASE_				:  Optional[Any]           =     INVOICE_URL
        SCREAMING_SNAKE_CASE_				:  Tuple           =     list(zip(*apply_tesseract(load_image(_SCREAMING_SNAKE_CASE					) ,					_SCREAMING_SNAKE_CASE ,					''					)					)					)
        SCREAMING_SNAKE_CASE_				:  List[str]           =     'What is the placebo?'
        SCREAMING_SNAKE_CASE_				:  List[Any]           =     [
            {
                'image': load_image(_SCREAMING_SNAKE_CASE					),
                'question': question,
            },
            {
                'image': image,
                'question': question,
            },
            {
                'image': image,
                'question': question,
                'word_boxes': word_boxes,
            },
        ]
        return dqa_pipeline, examples

  def  UpperCAmelCase    (				self ,					_SCREAMING_SNAKE_CASE ,					_SCREAMING_SNAKE_CASE					):





        """simple docstring"""







        SCREAMING_SNAKE_CASE_				:  Optional[int]           =     dqa_pipeline(_SCREAMING_SNAKE_CASE ,					top_k=2					)
        self.assertEqual(
            _SCREAMING_SNAKE_CASE ,					[
                [
                    {'score': ANY(_SCREAMING_SNAKE_CASE					), 'answer': ANY(_SCREAMING_SNAKE_CASE					), 'start': ANY(_SCREAMING_SNAKE_CASE					), 'end': ANY(_SCREAMING_SNAKE_CASE					)},
                    {'score': ANY(_SCREAMING_SNAKE_CASE					), 'answer': ANY(_SCREAMING_SNAKE_CASE					), 'start': ANY(_SCREAMING_SNAKE_CASE					), 'end': ANY(_SCREAMING_SNAKE_CASE					)},
                ]
            ]
            * 3 ,					)

  @require_torch
  @require_detectrona
  @require_pytesseract
  def  UpperCAmelCase    (				self					):





        """simple docstring"""







        SCREAMING_SNAKE_CASE_				:  Any           =     pipeline('document-question-answering' ,					model='hf-internal-testing/tiny-random-layoutlmv2'					)
        SCREAMING_SNAKE_CASE_				:  Any           =     INVOICE_URL
        SCREAMING_SNAKE_CASE_				:  Optional[Any]           =     'How many cats are there?'

        SCREAMING_SNAKE_CASE_				:  int           =     [
            {'score': 0.0001, 'answer': 'oy 2312/2019', 'start': 38, 'end': 39},
            {'score': 0.0001, 'answer': 'oy 2312/2019 DUE', 'start': 38, 'end': 40},
        ]
        SCREAMING_SNAKE_CASE_				:  Dict           =     dqa_pipeline(image=_SCREAMING_SNAKE_CASE ,					question=_SCREAMING_SNAKE_CASE ,					top_k=2					)
        self.assertEqual(nested_simplify(_SCREAMING_SNAKE_CASE ,					decimals=4					) ,					_SCREAMING_SNAKE_CASE					)

        SCREAMING_SNAKE_CASE_				:  Optional[Any]           =     dqa_pipeline({'image': image, 'question': question} ,					top_k=2					)
        self.assertEqual(nested_simplify(_SCREAMING_SNAKE_CASE ,					decimals=4					) ,					_SCREAMING_SNAKE_CASE					)

        # This image does not detect ANY text in it, meaning layoutlmv2 should fail.
        # Empty answer probably
        SCREAMING_SNAKE_CASE_				:  Optional[int]           =     './tests/fixtures/tests_samples/COCO/000000039769.png'
        SCREAMING_SNAKE_CASE_				:  Optional[Any]           =     dqa_pipeline(image=_SCREAMING_SNAKE_CASE ,					question=_SCREAMING_SNAKE_CASE ,					top_k=2					)
        self.assertEqual(_SCREAMING_SNAKE_CASE ,					[]					)

        # We can optionnally pass directly the words and bounding boxes
        SCREAMING_SNAKE_CASE_				:  List[str]           =     './tests/fixtures/tests_samples/COCO/000000039769.png'
        SCREAMING_SNAKE_CASE_				:  Any           =     []
        SCREAMING_SNAKE_CASE_				:  Dict           =     []
        SCREAMING_SNAKE_CASE_				:  Union[str, Any]           =     dqa_pipeline(image=_SCREAMING_SNAKE_CASE ,					question=_SCREAMING_SNAKE_CASE ,					words=_SCREAMING_SNAKE_CASE ,					boxes=_SCREAMING_SNAKE_CASE ,					top_k=2					)
        self.assertEqual(_SCREAMING_SNAKE_CASE ,					[]					)

  @slow
  @require_torch
  @require_detectrona
  @require_pytesseract
  def  UpperCAmelCase    (				self					):





        """simple docstring"""







        SCREAMING_SNAKE_CASE_				:  str           =     pipeline(
            'document-question-answering' ,					model='tiennvcs/layoutlmv2-base-uncased-finetuned-docvqa' ,					revision='9977165' ,					)
        SCREAMING_SNAKE_CASE_				:  str           =     INVOICE_URL
        SCREAMING_SNAKE_CASE_				:  Optional[int]           =     'What is the invoice number?'

        SCREAMING_SNAKE_CASE_				:  Optional[Any]           =     dqa_pipeline(image=_SCREAMING_SNAKE_CASE ,					question=_SCREAMING_SNAKE_CASE ,					top_k=2					)
        self.assertEqual(
            nested_simplify(_SCREAMING_SNAKE_CASE ,					decimals=4					) ,					[
                {'score': 0.9944, 'answer': 'us-001', 'start': 16, 'end': 16},
                {'score': 0.0009, 'answer': 'us-001', 'start': 16, 'end': 16},
            ] ,					)

        SCREAMING_SNAKE_CASE_				:  Optional[int]           =     dqa_pipeline({'image': image, 'question': question} ,					top_k=2					)
        self.assertEqual(
            nested_simplify(_SCREAMING_SNAKE_CASE ,					decimals=4					) ,					[
                {'score': 0.9944, 'answer': 'us-001', 'start': 16, 'end': 16},
                {'score': 0.0009, 'answer': 'us-001', 'start': 16, 'end': 16},
            ] ,					)

        SCREAMING_SNAKE_CASE_				:  Any           =     dqa_pipeline(
            [{'image': image, 'question': question}, {'image': image, 'question': question}] ,					top_k=2					)
        self.assertEqual(
            nested_simplify(_SCREAMING_SNAKE_CASE ,					decimals=4					) ,					[
                [
                    {'score': 0.9944, 'answer': 'us-001', 'start': 16, 'end': 16},
                    {'score': 0.0009, 'answer': 'us-001', 'start': 16, 'end': 16},
                ],
            ]
            * 2 ,					)

  @slow
  @require_torch
  @require_detectrona
  @require_pytesseract
  def  UpperCAmelCase    (				self					):





        """simple docstring"""







        SCREAMING_SNAKE_CASE_				:  int           =     pipeline(
            'document-question-answering' ,					model='tiennvcs/layoutlmv2-base-uncased-finetuned-docvqa' ,					revision='9977165' ,					max_seq_len=50 ,					)
        SCREAMING_SNAKE_CASE_				:  List[Any]           =     INVOICE_URL
        SCREAMING_SNAKE_CASE_				:  Optional[int]           =     'What is the invoice number?'

        SCREAMING_SNAKE_CASE_				:  str           =     dqa_pipeline(image=_SCREAMING_SNAKE_CASE ,					question=_SCREAMING_SNAKE_CASE ,					top_k=2					)
        self.assertEqual(
            nested_simplify(_SCREAMING_SNAKE_CASE ,					decimals=4					) ,					[
                {'score': 0.9974, 'answer': '1110212019', 'start': 23, 'end': 23},
                {'score': 0.9948, 'answer': 'us-001', 'start': 16, 'end': 16},
            ] ,					)

        SCREAMING_SNAKE_CASE_				:  str           =     dqa_pipeline({'image': image, 'question': question} ,					top_k=2					)
        self.assertEqual(
            nested_simplify(_SCREAMING_SNAKE_CASE ,					decimals=4					) ,					[
                {'score': 0.9974, 'answer': '1110212019', 'start': 23, 'end': 23},
                {'score': 0.9948, 'answer': 'us-001', 'start': 16, 'end': 16},
            ] ,					)

        SCREAMING_SNAKE_CASE_				:  Optional[int]           =     dqa_pipeline(
            [{'image': image, 'question': question}, {'image': image, 'question': question}] ,					top_k=2					)
        self.assertEqual(
            nested_simplify(_SCREAMING_SNAKE_CASE ,					decimals=4					) ,					[
                [
                    {'score': 0.9974, 'answer': '1110212019', 'start': 23, 'end': 23},
                    {'score': 0.9948, 'answer': 'us-001', 'start': 16, 'end': 16},
                ]
            ]
            * 2 ,					)

  @slow
  @require_torch
  @require_pytesseract
  @require_vision
  def  UpperCAmelCase    (				self					):





        """simple docstring"""







        SCREAMING_SNAKE_CASE_				:  Dict           =     AutoTokenizer.from_pretrained(
            'impira/layoutlm-document-qa' ,					revision='3dc6de3' ,					add_prefix_space=_SCREAMING_SNAKE_CASE					)
        SCREAMING_SNAKE_CASE_				:  List[Any]           =     pipeline(
            'document-question-answering' ,					model='impira/layoutlm-document-qa' ,					tokenizer=_SCREAMING_SNAKE_CASE ,					revision='3dc6de3' ,					)
        SCREAMING_SNAKE_CASE_				:  str           =     INVOICE_URL
        SCREAMING_SNAKE_CASE_				:  Optional[int]           =     'What is the invoice number?'

        SCREAMING_SNAKE_CASE_				:  List[str]           =     dqa_pipeline(image=_SCREAMING_SNAKE_CASE ,					question=_SCREAMING_SNAKE_CASE ,					top_k=2					)
        self.assertEqual(
            nested_simplify(_SCREAMING_SNAKE_CASE ,					decimals=4					) ,					[
                {'score': 0.4251, 'answer': 'us-001', 'start': 16, 'end': 16},
                {'score': 0.0819, 'answer': '1110212019', 'start': 23, 'end': 23},
            ] ,					)

        SCREAMING_SNAKE_CASE_				:  Optional[int]           =     dqa_pipeline({'image': image, 'question': question} ,					top_k=2					)
        self.assertEqual(
            nested_simplify(_SCREAMING_SNAKE_CASE ,					decimals=4					) ,					[
                {'score': 0.4251, 'answer': 'us-001', 'start': 16, 'end': 16},
                {'score': 0.0819, 'answer': '1110212019', 'start': 23, 'end': 23},
            ] ,					)

        SCREAMING_SNAKE_CASE_				:  List[str]           =     dqa_pipeline(
            [{'image': image, 'question': question}, {'image': image, 'question': question}] ,					top_k=2					)
        self.assertEqual(
            nested_simplify(_SCREAMING_SNAKE_CASE ,					decimals=4					) ,					[
                [
                    {'score': 0.4251, 'answer': 'us-001', 'start': 16, 'end': 16},
                    {'score': 0.0819, 'answer': '1110212019', 'start': 23, 'end': 23},
                ]
            ]
            * 2 ,					)

        SCREAMING_SNAKE_CASE_				:  int           =     list(zip(*apply_tesseract(load_image(_SCREAMING_SNAKE_CASE					) ,					_SCREAMING_SNAKE_CASE ,					''					)					)					)

        # This model should also work if `image` is set to None
        SCREAMING_SNAKE_CASE_				:  Optional[Any]           =     dqa_pipeline({'image': None, 'word_boxes': word_boxes, 'question': question} ,					top_k=2					)
        self.assertEqual(
            nested_simplify(_SCREAMING_SNAKE_CASE ,					decimals=4					) ,					[
                {'score': 0.4251, 'answer': 'us-001', 'start': 16, 'end': 16},
                {'score': 0.0819, 'answer': '1110212019', 'start': 23, 'end': 23},
            ] ,					)

  @slow
  @require_torch
  @require_pytesseract
  @require_vision
  def  UpperCAmelCase    (				self					):





        """simple docstring"""







        SCREAMING_SNAKE_CASE_				:  Any           =     AutoTokenizer.from_pretrained(
            'impira/layoutlm-document-qa' ,					revision='3dc6de3' ,					add_prefix_space=_SCREAMING_SNAKE_CASE					)
        SCREAMING_SNAKE_CASE_				:  Dict           =     pipeline(
            'document-question-answering' ,					model='impira/layoutlm-document-qa' ,					tokenizer=_SCREAMING_SNAKE_CASE ,					revision='3dc6de3' ,					max_seq_len=50 ,					)
        SCREAMING_SNAKE_CASE_				:  Union[str, Any]           =     INVOICE_URL
        SCREAMING_SNAKE_CASE_				:  Any           =     'What is the invoice number?'

        SCREAMING_SNAKE_CASE_				:  Optional[int]           =     dqa_pipeline(image=_SCREAMING_SNAKE_CASE ,					question=_SCREAMING_SNAKE_CASE ,					top_k=2					)
        self.assertEqual(
            nested_simplify(_SCREAMING_SNAKE_CASE ,					decimals=4					) ,					[
                {'score': 0.9999, 'answer': 'us-001', 'start': 16, 'end': 16},
                {'score': 0.9998, 'answer': 'us-001', 'start': 16, 'end': 16},
            ] ,					)

        SCREAMING_SNAKE_CASE_				:  str           =     dqa_pipeline(
            [{'image': image, 'question': question}, {'image': image, 'question': question}] ,					top_k=2					)
        self.assertEqual(
            nested_simplify(_SCREAMING_SNAKE_CASE ,					decimals=4					) ,					[
                [
                    {'score': 0.9999, 'answer': 'us-001', 'start': 16, 'end': 16},
                    {'score': 0.9998, 'answer': 'us-001', 'start': 16, 'end': 16},
                ]
            ]
            * 2 ,					)

        SCREAMING_SNAKE_CASE_				:  Any           =     list(zip(*apply_tesseract(load_image(_SCREAMING_SNAKE_CASE					) ,					_SCREAMING_SNAKE_CASE ,					''					)					)					)

        # This model should also work if `image` is set to None
        SCREAMING_SNAKE_CASE_				:  Tuple           =     dqa_pipeline({'image': None, 'word_boxes': word_boxes, 'question': question} ,					top_k=2					)
        self.assertEqual(
            nested_simplify(_SCREAMING_SNAKE_CASE ,					decimals=4					) ,					[
                {'score': 0.9999, 'answer': 'us-001', 'start': 16, 'end': 16},
                {'score': 0.9998, 'answer': 'us-001', 'start': 16, 'end': 16},
            ] ,					)

  @slow
  @require_torch
  def  UpperCAmelCase    (				self					):





        """simple docstring"""







        SCREAMING_SNAKE_CASE_				:  Optional[Any]           =     pipeline(
            'document-question-answering' ,					model='naver-clova-ix/donut-base-finetuned-docvqa' ,					tokenizer=AutoTokenizer.from_pretrained('naver-clova-ix/donut-base-finetuned-docvqa'					) ,					feature_extractor='naver-clova-ix/donut-base-finetuned-docvqa' ,					)

        SCREAMING_SNAKE_CASE_				:  Union[str, Any]           =     INVOICE_URL
        SCREAMING_SNAKE_CASE_				:  str           =     'What is the invoice number?'
        SCREAMING_SNAKE_CASE_				:  Tuple           =     dqa_pipeline(image=_SCREAMING_SNAKE_CASE ,					question=_SCREAMING_SNAKE_CASE ,					top_k=2					)
        self.assertEqual(nested_simplify(_SCREAMING_SNAKE_CASE ,					decimals=4					) ,					[{'answer': 'us-001'}]					)



  @require_tf
  @unittest.skip('Document question answering not implemented in TF'					)
  def  UpperCAmelCase    (				self					):





        """simple docstring"""







        pass









from typing import Any, Dict, List, Union

from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends
from .base import PIPELINE_INIT_ARGS, Pipeline


if is_vision_available():
    from ..image_utils import load_image


if is_torch_available():
    import torch

    from ..models.auto.modeling_auto import MODEL_FOR_OBJECT_DETECTION_MAPPING, MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING

lowerCAmelCase     :   Optional[int]						     =  logging.get_logger(__name__)


lowerCAmelCase     :   Optional[int]						     =  Dict[str, Any]
lowerCAmelCase     :   Any						     =  List[Prediction]
@add_end_docstrings(__magic_name__)
class  _A		(  __magic_name__):

  def __init__(				self ,					*_SCREAMING_SNAKE_CASE ,					**_SCREAMING_SNAKE_CASE					):





        """simple docstring"""







        super().__init__(*_SCREAMING_SNAKE_CASE ,					**_SCREAMING_SNAKE_CASE					)

        if self.framework == "tf":
              raise ValueError(f"The {self.__class__} is only available in PyTorch."					)

        requires_backends(self ,					'vision'					)
        self.check_model_type(
            dict(MODEL_FOR_OBJECT_DETECTION_MAPPING.items() + MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING.items()					)					)

  def  UpperCAmelCase    (				self ,					**_SCREAMING_SNAKE_CASE					):





        """simple docstring"""







        SCREAMING_SNAKE_CASE_				:  Any           =     {}
        if "threshold" in kwargs:
              SCREAMING_SNAKE_CASE_				:  List[str]           =     kwargs['threshold']
        return {}, {}, postprocess_kwargs

  def __call__(				self ,					*_SCREAMING_SNAKE_CASE ,					**_SCREAMING_SNAKE_CASE					):





        """simple docstring"""







        return super().__call__(*_SCREAMING_SNAKE_CASE ,					**_SCREAMING_SNAKE_CASE					)

  def  UpperCAmelCase    (				self ,					_SCREAMING_SNAKE_CASE					):





        """simple docstring"""







        SCREAMING_SNAKE_CASE_				:  Dict           =     load_image(_SCREAMING_SNAKE_CASE					)
        SCREAMING_SNAKE_CASE_				:  Union[str, Any]           =     torch.IntTensor([[image.height, image.width]]					)
        SCREAMING_SNAKE_CASE_				:  List[Any]           =     self.image_processor(images=[image] ,					return_tensors='pt'					)
        if self.tokenizer is not None:
              SCREAMING_SNAKE_CASE_				:  Tuple           =     self.tokenizer(text=inputs['words'] ,					boxes=inputs['boxes'] ,					return_tensors='pt'					)
        SCREAMING_SNAKE_CASE_				:  Optional[int]           =     target_size
        return inputs

  def  UpperCAmelCase    (				self ,					_SCREAMING_SNAKE_CASE					):





        """simple docstring"""







        SCREAMING_SNAKE_CASE_				:  Dict           =     model_inputs.pop('target_size'					)
        SCREAMING_SNAKE_CASE_				:  List[str]           =     self.model(**_SCREAMING_SNAKE_CASE					)
        SCREAMING_SNAKE_CASE_				:  Dict           =     outputs.__class__({'target_size': target_size, **outputs}					)
        if self.tokenizer is not None:
              SCREAMING_SNAKE_CASE_				:  str           =     model_inputs['bbox']
        return model_outputs

  def  UpperCAmelCase    (				self ,					_SCREAMING_SNAKE_CASE ,					_SCREAMING_SNAKE_CASE=0.9					):





        """simple docstring"""







        SCREAMING_SNAKE_CASE_				:  List[Any]           =     model_outputs['target_size']
        if self.tokenizer is not None:
              # This is a LayoutLMForTokenClassification variant.
              # The OCR got the boxes and the model classified the words.
              SCREAMING_SNAKE_CASE_       ,						SCREAMING_SNAKE_CASE_				:  Any           =     target_size[0].tolist()

              def unnormalize(_SCREAMING_SNAKE_CASE					):
                    return self._get_bounding_box(
                        torch.Tensor(
                            [
                                (width * bbox[0] / 1000),
                                (height * bbox[1] / 1000),
                                (width * bbox[2] / 1000),
                                (height * bbox[3] / 1000),
                            ]					)					)

              SCREAMING_SNAKE_CASE_       ,						SCREAMING_SNAKE_CASE_				:  Union[str, Any]           =     model_outputs['logits'].squeeze(0					).softmax(dim=-1					).max(dim=-1					)
              SCREAMING_SNAKE_CASE_				:  str           =     [self.model.config.idalabel[prediction] for prediction in classes.tolist()]
              SCREAMING_SNAKE_CASE_				:  List[Any]           =     [unnormalize(_SCREAMING_SNAKE_CASE					) for bbox in model_outputs['bbox'].squeeze(0					)]
              SCREAMING_SNAKE_CASE_				:  Optional[int]           =     ['score', 'label', 'box']
              SCREAMING_SNAKE_CASE_				:  Tuple           =     [dict(zip(_SCREAMING_SNAKE_CASE ,					_SCREAMING_SNAKE_CASE					)					) for vals in zip(scores.tolist() ,					_SCREAMING_SNAKE_CASE ,					_SCREAMING_SNAKE_CASE					) if vals[0] > threshold]
        else:
              # This is a regular ForObjectDetectionModel
              SCREAMING_SNAKE_CASE_				:  Dict           =     self.image_processor.post_process_object_detection(_SCREAMING_SNAKE_CASE ,					_SCREAMING_SNAKE_CASE ,					_SCREAMING_SNAKE_CASE					)
              SCREAMING_SNAKE_CASE_				:  int           =     raw_annotations[0]
              SCREAMING_SNAKE_CASE_				:  Optional[Any]           =     raw_annotation['scores']
              SCREAMING_SNAKE_CASE_				:  Any           =     raw_annotation['labels']
              SCREAMING_SNAKE_CASE_				:  Tuple           =     raw_annotation['boxes']

              SCREAMING_SNAKE_CASE_				:  Union[str, Any]           =     scores.tolist()
              SCREAMING_SNAKE_CASE_				:  Any           =     [self.model.config.idalabel[label.item()] for label in labels]
              SCREAMING_SNAKE_CASE_				:  Optional[int]           =     [self._get_bounding_box(_SCREAMING_SNAKE_CASE					) for box in boxes]

              # {"scores": [...], ...} --> [{"score":x, ...}, ...]
              SCREAMING_SNAKE_CASE_				:  str           =     ['score', 'label', 'box']
              SCREAMING_SNAKE_CASE_				:  Optional[int]           =     [
                  dict(zip(_SCREAMING_SNAKE_CASE ,					_SCREAMING_SNAKE_CASE					)					)
                  for vals in zip(raw_annotation['scores'] ,					raw_annotation['labels'] ,					raw_annotation['boxes']					)
              ]

        return annotation



  def  UpperCAmelCase    (				self ,					_SCREAMING_SNAKE_CASE					):





        """simple docstring"""







        if self.framework != "pt":
              raise ValueError('The ObjectDetectionPipeline is only available in PyTorch.'					)
        SCREAMING_SNAKE_CASE_       ,						SCREAMING_SNAKE_CASE_       ,						SCREAMING_SNAKE_CASE_       ,						SCREAMING_SNAKE_CASE_				:  List[Any]           =     box.int().tolist()
        SCREAMING_SNAKE_CASE_				:  Union[str, Any]           =     {
            'xmin': xmin,
            'ymin': ymin,
            'xmax': xmax,
            'ymax': ymax,
        }
        return bbox






