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        UpperCamelCase						:





							@staticmethod
							def        A_							(*__UpperCamelCase			,     **__UpperCamelCase						)				->				int:
													pass

@is_pipeline_test
@require_vision
@require_timm
@require_torch
class        UpperCamelCase						(				unittest.TestCase				):
						a__		:Dict      =			MODEL_FOR_OBJECT_DETECTION_MAPPING





						def        A_							(self			,     __UpperCamelCase			,     __UpperCamelCase			,     __UpperCamelCase						)				->				str:
												UpperCamelCase_		:							Dict  =		ObjectDetectionPipeline(model=__UpperCamelCase			,     image_processor=__UpperCamelCase						)
												return object_detector, ["./tests/fixtures/tests_samples/COCO/000000039769.png"]





						def        A_							(self			,     __UpperCamelCase			,     __UpperCamelCase						)				->				List[str]:
												UpperCamelCase_		:							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

												UpperCamelCase_		:							Optional[Any]  =		datasets.load_dataset("""hf-internal-testing/fixtures_image_utils"""			,     """image"""			,     split="""test"""						)

												UpperCamelCase_		:							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"""],
												]
												UpperCamelCase_		:							Optional[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        A_							(self						)				->				List[Any]:
												pass





						@require_torch
						def        A_							(self						)				->				int:
												UpperCamelCase_		:							str  =		"""hf-internal-testing/tiny-detr-mobilenetsv3"""

												UpperCamelCase_		:							Tuple  =		AutoModelForObjectDetection.from_pretrained(__UpperCamelCase						)
												UpperCamelCase_		:							Dict  =		AutoFeatureExtractor.from_pretrained(__UpperCamelCase						)
												UpperCamelCase_		:							str  =		ObjectDetectionPipeline(model=__UpperCamelCase			,     feature_extractor=__UpperCamelCase						)

												UpperCamelCase_		:							Any  =		object_detector("""http://images.cocodataset.org/val2017/000000039769.jpg"""			,     threshold=0.0						)

												self.assertEqual(
												    nested_simplify(__UpperCamelCase			,     decimals=4						)			,     [
												        {"""score""": 0.3_376, """label""": """LABEL_0""", """box""": {"""xmin""": 159, """ymin""": 120, """xmax""": 480, """ymax""": 359}},
												        {"""score""": 0.3_376, """label""": """LABEL_0""", """box""": {"""xmin""": 159, """ymin""": 120, """xmax""": 480, """ymax""": 359}},
												    ]			,     )

												UpperCamelCase_		:							Optional[int]  =		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.3_376, """label""": """LABEL_0""", """box""": {"""xmin""": 159, """ymin""": 120, """xmax""": 480, """ymax""": 359}},
												            {"""score""": 0.3_376, """label""": """LABEL_0""", """box""": {"""xmin""": 159, """ymin""": 120, """xmax""": 480, """ymax""": 359}},
												        ],
												        [
												            {"""score""": 0.3_376, """label""": """LABEL_0""", """box""": {"""xmin""": 159, """ymin""": 120, """xmax""": 480, """ymax""": 359}},
												            {"""score""": 0.3_376, """label""": """LABEL_0""", """box""": {"""xmin""": 159, """ymin""": 120, """xmax""": 480, """ymax""": 359}},
												        ],
												    ]			,     )





						@require_torch
						@slow
						def        A_							(self						)				->				Dict:
												UpperCamelCase_		:							Any  =		"""facebook/detr-resnet-50"""

												UpperCamelCase_		:							Optional[Any]  =		AutoModelForObjectDetection.from_pretrained(__UpperCamelCase						)
												UpperCamelCase_		:							Dict  =		AutoFeatureExtractor.from_pretrained(__UpperCamelCase						)
												UpperCamelCase_		:							Union[str, Any]  =		ObjectDetectionPipeline(model=__UpperCamelCase			,     feature_extractor=__UpperCamelCase						)

												UpperCamelCase_		:							Any  =		object_detector("""http://images.cocodataset.org/val2017/000000039769.jpg"""						)
												self.assertEqual(
												    nested_simplify(__UpperCamelCase			,     decimals=4						)			,     [
												        {"""score""": 0.9_982, """label""": """remote""", """box""": {"""xmin""": 40, """ymin""": 70, """xmax""": 175, """ymax""": 117}},
												        {"""score""": 0.9_960, """label""": """remote""", """box""": {"""xmin""": 333, """ymin""": 72, """xmax""": 368, """ymax""": 187}},
												        {"""score""": 0.9_955, """label""": """couch""", """box""": {"""xmin""": 0, """ymin""": 1, """xmax""": 639, """ymax""": 473}},
												        {"""score""": 0.9_988, """label""": """cat""", """box""": {"""xmin""": 13, """ymin""": 52, """xmax""": 314, """ymax""": 470}},
												        {"""score""": 0.9_987, """label""": """cat""", """box""": {"""xmin""": 345, """ymin""": 23, """xmax""": 640, """ymax""": 368}},
												    ]			,     )

												UpperCamelCase_		:							Dict  =		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.9_982, """label""": """remote""", """box""": {"""xmin""": 40, """ymin""": 70, """xmax""": 175, """ymax""": 117}},
												            {"""score""": 0.9_960, """label""": """remote""", """box""": {"""xmin""": 333, """ymin""": 72, """xmax""": 368, """ymax""": 187}},
												            {"""score""": 0.9_955, """label""": """couch""", """box""": {"""xmin""": 0, """ymin""": 1, """xmax""": 639, """ymax""": 473}},
												            {"""score""": 0.9_988, """label""": """cat""", """box""": {"""xmin""": 13, """ymin""": 52, """xmax""": 314, """ymax""": 470}},
												            {"""score""": 0.9_987, """label""": """cat""", """box""": {"""xmin""": 345, """ymin""": 23, """xmax""": 640, """ymax""": 368}},
												        ],
												        [
												            {"""score""": 0.9_982, """label""": """remote""", """box""": {"""xmin""": 40, """ymin""": 70, """xmax""": 175, """ymax""": 117}},
												            {"""score""": 0.9_960, """label""": """remote""", """box""": {"""xmin""": 333, """ymin""": 72, """xmax""": 368, """ymax""": 187}},
												            {"""score""": 0.9_955, """label""": """couch""", """box""": {"""xmin""": 0, """ymin""": 1, """xmax""": 639, """ymax""": 473}},
												            {"""score""": 0.9_988, """label""": """cat""", """box""": {"""xmin""": 13, """ymin""": 52, """xmax""": 314, """ymax""": 470}},
												            {"""score""": 0.9_987, """label""": """cat""", """box""": {"""xmin""": 345, """ymin""": 23, """xmax""": 640, """ymax""": 368}},
												        ],
												    ]			,     )





						@require_torch
						@slow
						def        A_							(self						)				->				Dict:
												UpperCamelCase_		:							int  =		"""facebook/detr-resnet-50"""

												UpperCamelCase_		:							Tuple  =		pipeline("""object-detection"""			,     model=__UpperCamelCase						)

												UpperCamelCase_		:							Optional[int]  =		object_detector("""http://images.cocodataset.org/val2017/000000039769.jpg"""						)
												self.assertEqual(
												    nested_simplify(__UpperCamelCase			,     decimals=4						)			,     [
												        {"""score""": 0.9_982, """label""": """remote""", """box""": {"""xmin""": 40, """ymin""": 70, """xmax""": 175, """ymax""": 117}},
												        {"""score""": 0.9_960, """label""": """remote""", """box""": {"""xmin""": 333, """ymin""": 72, """xmax""": 368, """ymax""": 187}},
												        {"""score""": 0.9_955, """label""": """couch""", """box""": {"""xmin""": 0, """ymin""": 1, """xmax""": 639, """ymax""": 473}},
												        {"""score""": 0.9_988, """label""": """cat""", """box""": {"""xmin""": 13, """ymin""": 52, """xmax""": 314, """ymax""": 470}},
												        {"""score""": 0.9_987, """label""": """cat""", """box""": {"""xmin""": 345, """ymin""": 23, """xmax""": 640, """ymax""": 368}},
												    ]			,     )

												UpperCamelCase_		:							List[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.9_982, """label""": """remote""", """box""": {"""xmin""": 40, """ymin""": 70, """xmax""": 175, """ymax""": 117}},
												            {"""score""": 0.9_960, """label""": """remote""", """box""": {"""xmin""": 333, """ymin""": 72, """xmax""": 368, """ymax""": 187}},
												            {"""score""": 0.9_955, """label""": """couch""", """box""": {"""xmin""": 0, """ymin""": 1, """xmax""": 639, """ymax""": 473}},
												            {"""score""": 0.9_988, """label""": """cat""", """box""": {"""xmin""": 13, """ymin""": 52, """xmax""": 314, """ymax""": 470}},
												            {"""score""": 0.9_987, """label""": """cat""", """box""": {"""xmin""": 345, """ymin""": 23, """xmax""": 640, """ymax""": 368}},
												        ],
												        [
												            {"""score""": 0.9_982, """label""": """remote""", """box""": {"""xmin""": 40, """ymin""": 70, """xmax""": 175, """ymax""": 117}},
												            {"""score""": 0.9_960, """label""": """remote""", """box""": {"""xmin""": 333, """ymin""": 72, """xmax""": 368, """ymax""": 187}},
												            {"""score""": 0.9_955, """label""": """couch""", """box""": {"""xmin""": 0, """ymin""": 1, """xmax""": 639, """ymax""": 473}},
												            {"""score""": 0.9_988, """label""": """cat""", """box""": {"""xmin""": 13, """ymin""": 52, """xmax""": 314, """ymax""": 470}},
												            {"""score""": 0.9_987, """label""": """cat""", """box""": {"""xmin""": 345, """ymin""": 23, """xmax""": 640, """ymax""": 368}},
												        ],
												    ]			,     )





						@require_torch
						@slow
						def        A_							(self						)				->				Tuple:
												UpperCamelCase_		:							List[Any]  =		0.9_985
												UpperCamelCase_		:							Tuple  =		"""facebook/detr-resnet-50"""

												UpperCamelCase_		:							Tuple  =		pipeline("""object-detection"""			,     model=__UpperCamelCase						)

												UpperCamelCase_		:							Any  =		object_detector("""http://images.cocodataset.org/val2017/000000039769.jpg"""			,     threshold=__UpperCamelCase						)
												self.assertEqual(
												    nested_simplify(__UpperCamelCase			,     decimals=4						)			,     [
												        {"""score""": 0.9_988, """label""": """cat""", """box""": {"""xmin""": 13, """ymin""": 52, """xmax""": 314, """ymax""": 470}},
												        {"""score""": 0.9_987, """label""": """cat""", """box""": {"""xmin""": 345, """ymin""": 23, """xmax""": 640, """ymax""": 368}},
												    ]			,     )





						@require_torch
						@require_pytesseract
						@slow
						def        A_							(self						)				->				Optional[Any]:
												UpperCamelCase_		:							Optional[int]  =		"""Narsil/layoutlmv3-finetuned-funsd"""
												UpperCamelCase_		:							Dict  =		0.9_993

												UpperCamelCase_		:							Union[str, Any]  =		pipeline("""object-detection"""			,     model=__UpperCamelCase			,     threshold=__UpperCamelCase						)

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







from copy import deepcopy
from typing import Optional, Union

import numpy as np

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding
from ...utils import TensorType, is_tf_available, is_torch_available


if is_torch_available():
	import torch

if is_tf_available():
	import tensorflow as tf

class        UpperCamelCase						(				__a				):
						a__		:str      =			['''image_processor''']
						a__		:str      =			'''SamImageProcessor'''





						def __init__(self			,     __UpperCamelCase						)				->				int:
												super().__init__(__UpperCamelCase						)
												UpperCamelCase_		:							Any  =		self.image_processor
												UpperCamelCase_		:							int  =		-10
												UpperCamelCase_		:							Dict  =		self.image_processor.size["""longest_edge"""]





						def __call__(self			,     __UpperCamelCase=None			,     __UpperCamelCase=None			,     __UpperCamelCase=None			,     __UpperCamelCase=None			,     __UpperCamelCase = None			,     **__UpperCamelCase			,     )				->				BatchEncoding:
												UpperCamelCase_		:							int  =		self.image_processor(
												    __UpperCamelCase			,     return_tensors=__UpperCamelCase			,     **__UpperCamelCase			,     )

												# pop arguments that are not used in the foward but used nevertheless
												UpperCamelCase_		:							Optional[int]  =		encoding_image_processor["""original_sizes"""]

												if hasattr(__UpperCamelCase			,     """numpy"""						):  # Checks if Torch or TF tensor
																		UpperCamelCase_		:							Dict  =		original_sizes.numpy()

												UpperCamelCase_,UpperCamelCase_,UpperCamelCase_		:							str  =		self._check_and_preprocess_points(
												    input_points=__UpperCamelCase			,     input_labels=__UpperCamelCase			,     input_boxes=__UpperCamelCase			,     )

												UpperCamelCase_		:							List[str]  =		self._normalize_and_convert(
												    __UpperCamelCase			,     __UpperCamelCase			,     input_points=__UpperCamelCase			,     input_labels=__UpperCamelCase			,     input_boxes=__UpperCamelCase			,     return_tensors=__UpperCamelCase			,     )

												return encoding_image_processor





						def        A_							(self			,     __UpperCamelCase			,     __UpperCamelCase			,     __UpperCamelCase=None			,     __UpperCamelCase=None			,     __UpperCamelCase=None			,     __UpperCamelCase="pt"			,     )				->				Tuple:
												if input_points is not None:
																		if len(__UpperCamelCase						) != len(__UpperCamelCase						):
																								UpperCamelCase_		:							str  =		[
																								    self._normalize_coordinates(self.target_size			,     __UpperCamelCase			,     original_sizes[0]						) for point in input_points
																								]
																		else:
																								UpperCamelCase_		:							List[str]  =		[
																								    self._normalize_coordinates(self.target_size			,     __UpperCamelCase			,     __UpperCamelCase						)
																								    for point, original_size in zip(__UpperCamelCase			,     __UpperCamelCase						)
																								]
																		# check that all arrays have the same shape
																		if not all(point.shape == input_points[0].shape for point in input_points						):
																								if input_labels is not None:
																														UpperCamelCase_,UpperCamelCase_		:							Optional[Any]  =		self._pad_points_and_labels(__UpperCamelCase			,     __UpperCamelCase						)

																		UpperCamelCase_		:							Dict  =		np.array(__UpperCamelCase						)

												if input_labels is not None:
																		UpperCamelCase_		:							Optional[Any]  =		np.array(__UpperCamelCase						)

												if input_boxes is not None:
																		if len(__UpperCamelCase						) != len(__UpperCamelCase						):
																								UpperCamelCase_		:							Tuple  =		[
																								    self._normalize_coordinates(self.target_size			,     __UpperCamelCase			,     original_sizes[0]			,     is_bounding_box=__UpperCamelCase						)
																								    for box in input_boxes
																								]
																		else:
																								UpperCamelCase_		:							Any  =		[
																								    self._normalize_coordinates(self.target_size			,     __UpperCamelCase			,     __UpperCamelCase			,     is_bounding_box=__UpperCamelCase						)
																								    for box, original_size in zip(__UpperCamelCase			,     __UpperCamelCase						)
																								]
																		UpperCamelCase_		:							int  =		np.array(__UpperCamelCase						)

												if input_boxes is not None:
																		if return_tensors == "pt":
																								UpperCamelCase_		:							Union[str, Any]  =		torch.from_numpy(__UpperCamelCase						)
																								# boxes batch size of 1 by default
																								UpperCamelCase_		:							Any  =		input_boxes.unsqueeze(1						) if len(input_boxes.shape						) != 3 else input_boxes
																		elif return_tensors == "tf":
																								UpperCamelCase_		:							List[str]  =		tf.convert_to_tensor(__UpperCamelCase						)
																								# boxes batch size of 1 by default
																								UpperCamelCase_		:							Optional[int]  =		tf.expand_dims(__UpperCamelCase			,     1						) if len(input_boxes.shape						) != 3 else input_boxes
																		encoding_image_processor.update({"""input_boxes""": input_boxes}						)
												if input_points is not None:
																		if return_tensors == "pt":
																								UpperCamelCase_		:							Optional[Any]  =		torch.from_numpy(__UpperCamelCase						)
																								# point batch size of 1 by default
																								UpperCamelCase_		:							List[Any]  =		input_points.unsqueeze(1						) if len(input_points.shape						) != 4 else input_points
																		elif return_tensors == "tf":
																								UpperCamelCase_		:							Optional[Any]  =		tf.convert_to_tensor(__UpperCamelCase						)
																								# point batch size of 1 by default
																								UpperCamelCase_		:							Dict  =		tf.expand_dims(__UpperCamelCase			,     1						) if len(input_points.shape						) != 4 else input_points
																		encoding_image_processor.update({"""input_points""": input_points}						)
												if input_labels is not None:
																		if return_tensors == "pt":
																								UpperCamelCase_		:							Optional[int]  =		torch.from_numpy(__UpperCamelCase						)
																								# point batch size of 1 by default
																								UpperCamelCase_		:							Tuple  =		input_labels.unsqueeze(1						) if len(input_labels.shape						) != 3 else input_labels
																		elif return_tensors == "tf":
																								UpperCamelCase_		:							Optional[Any]  =		tf.convert_to_tensor(__UpperCamelCase						)
																								# point batch size of 1 by default
																								UpperCamelCase_		:							Dict  =		tf.expand_dims(__UpperCamelCase			,     1						) if len(input_labels.shape						) != 3 else input_labels
																		encoding_image_processor.update({"""input_labels""": input_labels}						)

												return encoding_image_processor





						def        A_							(self			,     __UpperCamelCase			,     __UpperCamelCase						)				->				Tuple:
												UpperCamelCase_		:							Union[str, Any]  =		max([point.shape[0] for point in input_points]						)
												UpperCamelCase_		:							Any  =		[]
												for i, point in enumerate(__UpperCamelCase						):
																		if point.shape[0] != expected_nb_points:
																								UpperCamelCase_		:							Optional[int]  =		np.concatenate(
																								    [point, np.zeros((expected_nb_points - point.shape[0], 2)						) + self.point_pad_value]			,     axis=0						)
																								UpperCamelCase_		:							Dict  =		np.append(input_labels[i]			,     [self.point_pad_value]						)
																		processed_input_points.append(__UpperCamelCase						)
												UpperCamelCase_		:							List[Any]  =		processed_input_points
												return input_points, input_labels





						def        A_							(self			,     __UpperCamelCase			,     __UpperCamelCase			,     __UpperCamelCase			,     __UpperCamelCase=False						)				->				np.ndarray:
												UpperCamelCase_,UpperCamelCase_		:							Optional[int]  =		original_size
												UpperCamelCase_,UpperCamelCase_		:							List[str]  =		self.image_processor._get_preprocess_shape(__UpperCamelCase			,     longest_edge=__UpperCamelCase						)
												UpperCamelCase_		:							str  =		deepcopy(__UpperCamelCase						).astype(__UpperCamelCase						)

												if is_bounding_box:
																		UpperCamelCase_		:							int  =		coords.reshape(-1			,     2			,     2						)

												UpperCamelCase_		:							Tuple  =		coords[..., 0] * (new_w / old_w)
												UpperCamelCase_		:							Optional[int]  =		coords[..., 1] * (new_h / old_h)

												if is_bounding_box:
																		UpperCamelCase_		:							Optional[Any]  =		coords.reshape(-1			,     4						)

												return coords





						def        A_							(self			,     __UpperCamelCase=None			,     __UpperCamelCase=None			,     __UpperCamelCase=None			,     )				->				List[str]:
												if input_points is not None:
																		if hasattr(__UpperCamelCase			,     """numpy"""						):  # Checks for TF or Torch tensor
																								UpperCamelCase_		:							int  =		input_points.numpy().tolist()

																		if not isinstance(__UpperCamelCase			,     __UpperCamelCase						) or not isinstance(input_points[0]			,     __UpperCamelCase						):
																								raise ValueError("""Input points must be a list of list of floating points."""						)
																		UpperCamelCase_		:							List[Any]  =		[np.array(__UpperCamelCase						) for input_point in input_points]
												else:
																		UpperCamelCase_		:							str  =		None

												if input_labels is not None:
																		if hasattr(__UpperCamelCase			,     """numpy"""						):
																								UpperCamelCase_		:							Any  =		input_labels.numpy().tolist()

																		if not isinstance(__UpperCamelCase			,     __UpperCamelCase						) or not isinstance(input_labels[0]			,     __UpperCamelCase						):
																								raise ValueError("""Input labels must be a list of list integers."""						)
																		UpperCamelCase_		:							List[str]  =		[np.array(__UpperCamelCase						) for label in input_labels]
												else:
																		UpperCamelCase_		:							List[str]  =		None

												if input_boxes is not None:
																		if hasattr(__UpperCamelCase			,     """numpy"""						):
																								UpperCamelCase_		:							Dict  =		input_boxes.numpy().tolist()

																		if (
																		    not isinstance(__UpperCamelCase			,     __UpperCamelCase						)
																		    or not isinstance(input_boxes[0]			,     __UpperCamelCase						)
																		    or not isinstance(input_boxes[0][0]			,     __UpperCamelCase						)
																		):
																								raise ValueError("""Input boxes must be a list of list of list of floating points."""						)
																		UpperCamelCase_		:							Tuple  =		[np.array(__UpperCamelCase						).astype(np.floataa						) for box in input_boxes]
												else:
																		UpperCamelCase_		:							List[str]  =		None

												return input_points, input_labels, input_boxes





						@property
						def        A_							(self						)				->				List[str]:
												UpperCamelCase_		:							str  =		self.image_processor.model_input_names
												return list(dict.fromkeys(__UpperCamelCase						)						)





						def        A_							(self			,     *__UpperCamelCase			,     **__UpperCamelCase						)				->				Optional[Any]:
												return self.image_processor.post_process_masks(*__UpperCamelCase			,     **__UpperCamelCase						)






