




"""simple docstring"""

import colorsys
import io

import cva
import matplotlib as mpl
import matplotlib.colors as mplc
import matplotlib.figure as mplfigure
import numpy as np
import torch
from matplotlib.backends.backend_agg import FigureCanvasAgg

from utils import img_tensorize


_lowerCamelCase	:      Any   =							1000

class 							lowercase   :







				def __init__(				self :       int   ,  _lowerCamelCase :       List[str]   ,  _lowerCamelCase :       Dict=1.2   ,  _lowerCamelCase :       List[Any]="g"   ,  _lowerCamelCase :       Optional[int]=0.5   ,  _lowerCamelCase :       Any="-"   ,  _lowerCamelCase :       Optional[Any]="test_out.jpg"   ,  _lowerCamelCase :       Optional[int]=True   ,  _lowerCamelCase :       Optional[int]=False   ,  _lowerCamelCase :       Union[str, Any]=None   ,  _lowerCamelCase :       Any=None   ,  _lowerCamelCase :       Optional[int]=0.7   ,  ):



					"""simple docstring"""

					if isinstance(_lowerCamelCase   ,  torch.Tensor							):
						A_	:					List[str]						 =		img.numpy().astype('''np.uint8'''							)
					if isinstance(_lowerCamelCase   ,  _lowerCamelCase							):
						A_	:					Dict						 =		img_tensorize(_lowerCamelCase							)
					assert isinstance(_lowerCamelCase   ,  np.ndarray							)

					A_ ,			A_	:					List[Any]						 =		img.shape[1], img.shape[0]
					A_	:					Optional[int]						 =		mplfigure.Figure(frameon=_lowerCamelCase							)
					A_	:					List[Any]						 =		fig.get_dpi()
					A_	:					Any						 =		(width * scale + 1E-2) / dpi
					A_	:					List[Any]						 =		(height * scale + 1E-2) / dpi
					fig.set_size_inches(_lowerCamelCase   ,  _lowerCamelCase							)
					A_	:					List[Any]						 =		fig.add_axes([0.0, 0.0, 1.0, 1.0]							)
					ax.axis('''off'''							)
					ax.set_xlim(0.0   ,  _lowerCamelCase							)
					ax.set_ylim(_lowerCamelCase							)

					A_	:					Optional[Any]						 =		saveas
					A_	:					Tuple						 =		rgb
					A_	:					Dict						 =		pynb
					A_	:					Any						 =		img
					A_	:					List[Any]						 =		edgecolor
					A_	:					Union[str, Any]						 =		0.5
					A_	:					List[Any]						 =		linestyle
					A_	:					int						 =		int(np.sqrt(min(_lowerCamelCase   ,  _lowerCamelCase							)							) * scale // 3							)
					A_	:					int						 =		width
					A_	:					int						 =		height
					A_	:					Dict						 =		scale
					A_	:					str						 =		fig
					A_	:					List[Any]						 =		ax
					A_	:					Dict						 =		pad
					A_	:					Dict						 =		idaobj
					A_	:					List[Any]						 =		idaattr
					A_	:					Optional[Any]						 =		FigureCanvasAgg(_lowerCamelCase							)







				def        a_	(				self :       List[str]   ,  _lowerCamelCase :       Tuple   ,  _lowerCamelCase :       Optional[Any]=None							):



					"""simple docstring"""

					if color is None:
						A_	:					str						 =		self.edgecolor
					((A_) ,			(A_) ,			(A_) ,			(A_))	:					Any						 =		box
					A_	:					Tuple						 =		xa - xa
					A_	:					str						 =		ya - ya
					self.ax.add_patch(
					    mpl.patches.Rectangle(
					        (xa, ya)   ,  _lowerCamelCase   ,  _lowerCamelCase   ,  fill=_lowerCamelCase   ,  edgecolor=_lowerCamelCase   ,  linewidth=self.font_size // 3   ,  alpha=self.alpha   ,  linestyle=self.linestyle   ,  )							)







				def        a_	(				self :       str   ,  _lowerCamelCase :       List[Any]   ,  _lowerCamelCase :       List[Any]=None   ,  _lowerCamelCase :       str=None   ,  _lowerCamelCase :       Optional[int]=None   ,  _lowerCamelCase :       str=None							):



					"""simple docstring"""

					if len(boxes.shape							) > 2:
						A_	:					Optional[Any]						 =		boxes[0]
					if len(obj_ids.shape							) > 1:
						A_	:					str						 =		obj_ids[0]
					if len(obj_scores.shape							) > 1:
						A_	:					Union[str, Any]						 =		obj_scores[0]
					if len(attr_ids.shape							) > 1:
						A_	:					Dict						 =		attr_ids[0]
					if len(attr_scores.shape							) > 1:
						A_	:					Dict						 =		attr_scores[0]
					if isinstance(_lowerCamelCase   ,  torch.Tensor							):
						A_	:					Optional[Any]						 =		boxes.numpy()
					if isinstance(_lowerCamelCase   ,  _lowerCamelCase							):
						A_	:					Dict						 =		np.array(_lowerCamelCase							)
					assert isinstance(_lowerCamelCase   ,  np.ndarray							)
					A_	:					List[Any]						 =		np.prod(boxes[:, 2:] - boxes[:, :2]   ,  axis=1							)
					A_	:					Tuple						 =		np.argsort(-areas							).tolist()
					A_	:					int						 =		boxes[sorted_idxs] if boxes is not None else None
					A_	:					Tuple						 =		obj_ids[sorted_idxs] if obj_ids is not None else None
					A_	:					Optional[int]						 =		obj_scores[sorted_idxs] if obj_scores is not None else None
					A_	:					int						 =		attr_ids[sorted_idxs] if attr_ids is not None else None
					A_	:					Any						 =		attr_scores[sorted_idxs] if attr_scores is not None else None

					A_	:					Optional[int]						 =		[self._random_color(maximum=1							) for _ in range(len(_lowerCamelCase							)							)]
					A_	:					List[Any]						 =		[assigned_colors[idx] for idx in sorted_idxs]
					if obj_ids is not None:
						A_	:					List[str]						 =		self._create_text_labels_attr(_lowerCamelCase   ,  _lowerCamelCase   ,  _lowerCamelCase   ,  _lowerCamelCase							)
						for i in range(len(_lowerCamelCase							)							):
							A_	:					Tuple						 =		assigned_colors[i]
							self.add_box(boxes[i]   ,  _lowerCamelCase							)
							self.draw_labels(labels[i]   ,  boxes[i]   ,  _lowerCamelCase							)







				def        a_	(				self :       List[Any]   ,  _lowerCamelCase :       Union[str, Any]   ,  _lowerCamelCase :       List[str]   ,  _lowerCamelCase :       str							):



					"""simple docstring"""

					A_ ,			A_ ,			A_ ,			A_	:					Dict						 =		box
					A_	:					Optional[int]						 =		(xa, ya)
					A_	:					Union[str, Any]						 =		(ya - ya) * (xa - xa)
					A_	:					int						 =		_SMALL_OBJ * self.scale
					if instance_area < small or ya - ya < 40 * self.scale:
						if ya >= self.height - 5:
							A_	:					List[Any]						 =		(xa, ya)
						else:
							A_	:					int						 =		(xa, ya)

					A_	:					List[Any]						 =		(ya - ya) / np.sqrt(self.height * self.width							)
					A_	:					str						 =		self._change_color_brightness(_lowerCamelCase   ,  brightness_factor=0.7							)
					A_	:					Dict						 =		np.clip((height_ratio - 0.02) / 0.08 + 1   ,  1.2   ,  2							)
					font_size *= 0.75 * self.font_size

					self.draw_text(
					    text=_lowerCamelCase   ,  position=_lowerCamelCase   ,  color=_lowerCamelCase   ,  )







				def        a_	(				self :       Optional[int]   ,  _lowerCamelCase :       Optional[Any]   ,  _lowerCamelCase :       Union[str, Any]   ,  _lowerCamelCase :       List[str]="g"   ,  _lowerCamelCase :       List[Any]="left"   ,  ):



					"""simple docstring"""

					A_	:					List[str]						 =		0
					A_	:					Any						 =		self.font_size
					A_	:					List[str]						 =		np.maximum(list(mplc.to_rgb(_lowerCamelCase							)							)   ,  0.2							)
					A_	:					Tuple						 =		max(0.8   ,  np.max(_lowerCamelCase							)							)
					A_	:					Union[str, Any]						 =		{
					    '''facecolor''': '''black''',
					    '''alpha''': self.alpha,
					    '''pad''': self.pad,
					    '''edgecolor''': '''none''',
					}
					A_ ,			A_	:					Union[str, Any]						 =		position
					self.ax.text(
					    _lowerCamelCase   ,  _lowerCamelCase   ,  _lowerCamelCase   ,  size=font_size * self.scale   ,  family='''sans-serif'''   ,  bbox=_lowerCamelCase   ,  verticalalignment='''top'''   ,  horizontalalignment=_lowerCamelCase   ,  color=_lowerCamelCase   ,  zorder=10   ,  rotation=_lowerCamelCase   ,  )







				def        a_	(				self :       Optional[Any]   ,  _lowerCamelCase :       List[Any]=None							):



					"""simple docstring"""

					if saveas is None:
						A_	:					Optional[Any]						 =		self.saveas
					if saveas.lower().endswith('''.jpg'''							) or saveas.lower().endswith('''.png'''							):
						cva.imwrite(
						    _lowerCamelCase   ,  self._get_buffer()[:, :, ::-1]   ,  )
					else:
						self.fig.savefig(_lowerCamelCase							)







				def        a_	(				self :       str   ,  _lowerCamelCase :       int   ,  _lowerCamelCase :       List[str]   ,  _lowerCamelCase :       Optional[int]   ,  _lowerCamelCase :       List[Any]							):



					"""simple docstring"""

					A_	:					Optional[int]						 =		[self.idaobj[i] for i in classes]
					A_	:					List[str]						 =		[self.idaattr[i] for i in attr_classes]
					A_	:					int						 =		[
					    F"""{label} {score:.2f} {attr} {attr_score:.2f}"""
					    for label, score, attr, attr_score in zip(_lowerCamelCase   ,  _lowerCamelCase   ,  _lowerCamelCase   ,  _lowerCamelCase							)
					]
					return labels







				def        a_	(				self :       List[str]   ,  _lowerCamelCase :       Any   ,  _lowerCamelCase :       str							):



					"""simple docstring"""

					A_	:					str						 =		[self.idaobj[i] for i in classes]
					if scores is not None:
						if labels is None:
							A_	:					Dict						 =		['''{:.0f}%'''.format(s * 1_00							) for s in scores]
						else:
							A_	:					Any						 =		['''{} {:.0f}%'''.format(_lowerCamelCase   ,  s * 1_00							) for li, s in zip(_lowerCamelCase   ,  _lowerCamelCase							)]
					return labels







				def        a_	(				self :       Any   ,  _lowerCamelCase :       int=2_55							):



					"""simple docstring"""

					A_	:					int						 =		np.random.randint(0   ,  len(_COLORS							)							)
					A_	:					Dict						 =		_COLORS[idx] * maximum
					if not self.rgb:
						A_	:					Optional[Any]						 =		ret[::-1]
					return ret







				def        a_	(				self :       Any							):



					"""simple docstring"""

					if not self.pynb:
						A_ ,			A_	:					Union[str, Any]						 =		self.canvas.print_to_buffer()
						if (width, height) != (self.width, self.height):
							A_	:					Any						 =		cva.resize(self.img   ,  (width, height)							)
						else:
							A_	:					int						 =		self.img
					else:
						A_	:					Union[str, Any]						 =		io.BytesIO()  # works for cairo backend
						self.canvas.print_rgba(_lowerCamelCase							)
						A_ ,			A_	:					str						 =		self.width, self.height
						A_	:					Tuple						 =		buf.getvalue()
						A_	:					int						 =		self.img

					A_	:					int						 =		np.frombuffer(_lowerCamelCase   ,  dtype='''uint8'''							)
					A_	:					str						 =		buffer.reshape(_lowerCamelCase   ,  _lowerCamelCase   ,  4							)
					A_ ,			A_	:					str						 =		np.split(_lowerCamelCase   ,  [3]   ,  axis=2							)

					try:
						import numexpr as ne  # fuse them with numexpr

						A_	:					Tuple						 =		ne.evaluate('''img * (1 - alpha / 255.0) + rgb * (alpha / 255.0)'''							)
					except ImportError:
						A_	:					str						 =		alpha.astype('''float32'''							) / 255.0
						A_	:					List[Any]						 =		img * (1 - alpha) + rgb * alpha

					return visualized_image.astype('''uint8'''							)







				def        a_	(				self :       Optional[int]   ,  _lowerCamelCase :       Union[str, Any]   ,  _lowerCamelCase :       Tuple							):



					"""simple docstring"""

					assert brightness_factor >= -1.0 and brightness_factor <= 1.0
					A_	:					Optional[Any]						 =		mplc.to_rgb(_lowerCamelCase							)
					A_	:					Union[str, Any]						 =		colorsys.rgb_to_hls(*mplc.to_rgb(_lowerCamelCase							)							)
					A_	:					Tuple						 =		polygon_color[1] + (brightness_factor * polygon_color[1])
					A_	:					Optional[Any]						 =		0.0 if modified_lightness < 0.0 else modified_lightness
					A_	:					Union[str, Any]						 =		1.0 if modified_lightness > 1.0 else modified_lightness
					A_	:					Optional[Any]						 =		colorsys.hls_to_rgb(polygon_color[0]   ,  _lowerCamelCase   ,  polygon_color[2]							)
					return modified_color
_lowerCamelCase	:      Dict   =							(
    np.array(
        [
            0.000,
            0.447,
            0.741,
            0.850,
            0.325,
            0.098,
            0.929,
            0.694,
            0.125,
            0.494,
            0.184,
            0.556,
            0.466,
            0.674,
            0.188,
            0.301,
            0.745,
            0.933,
            0.635,
            0.078,
            0.184,
            0.300,
            0.300,
            0.300,
            0.600,
            0.600,
            0.600,
            1.000,
            0.000,
            0.000,
            1.000,
            0.500,
            0.000,
            0.749,
            0.749,
            0.000,
            0.000,
            1.000,
            0.000,
            0.000,
            0.000,
            1.000,
            0.667,
            0.000,
            1.000,
            0.333,
            0.333,
            0.000,
            0.333,
            0.667,
            0.000,
            0.333,
            1.000,
            0.000,
            0.667,
            0.333,
            0.000,
            0.667,
            0.667,
            0.000,
            0.667,
            1.000,
            0.000,
            1.000,
            0.333,
            0.000,
            1.000,
            0.667,
            0.000,
            1.000,
            1.000,
            0.000,
            0.000,
            0.333,
            0.500,
            0.000,
            0.667,
            0.500,
            0.000,
            1.000,
            0.500,
            0.333,
            0.000,
            0.500,
            0.333,
            0.333,
            0.500,
            0.333,
            0.667,
            0.500,
            0.333,
            1.000,
            0.500,
            0.667,
            0.000,
            0.500,
            0.667,
            0.333,
            0.500,
            0.667,
            0.667,
            0.500,
            0.667,
            1.000,
            0.500,
            1.000,
            0.000,
            0.500,
            1.000,
            0.333,
            0.500,
            1.000,
            0.667,
            0.500,
            1.000,
            1.000,
            0.500,
            0.000,
            0.333,
            1.000,
            0.000,
            0.667,
            1.000,
            0.000,
            1.000,
            1.000,
            0.333,
            0.000,
            1.000,
            0.333,
            0.333,
            1.000,
            0.333,
            0.667,
            1.000,
            0.333,
            1.000,
            1.000,
            0.667,
            0.000,
            1.000,
            0.667,
            0.333,
            1.000,
            0.667,
            0.667,
            1.000,
            0.667,
            1.000,
            1.000,
            1.000,
            0.000,
            1.000,
            1.000,
            0.333,
            1.000,
            1.000,
            0.667,
            1.000,
            0.333,
            0.000,
            0.000,
            0.500,
            0.000,
            0.000,
            0.667,
            0.000,
            0.000,
            0.833,
            0.000,
            0.000,
            1.000,
            0.000,
            0.000,
            0.000,
            0.167,
            0.000,
            0.000,
            0.333,
            0.000,
            0.000,
            0.500,
            0.000,
            0.000,
            0.667,
            0.000,
            0.000,
            0.833,
            0.000,
            0.000,
            1.000,
            0.000,
            0.000,
            0.000,
            0.167,
            0.000,
            0.000,
            0.333,
            0.000,
            0.000,
            0.500,
            0.000,
            0.000,
            0.667,
            0.000,
            0.000,
            0.833,
            0.000,
            0.000,
            1.000,
            0.000,
            0.000,
            0.000,
            0.143,
            0.143,
            0.143,
            0.857,
            0.857,
            0.857,
            1.000,
            1.000,
            1.000,
        ]
    )
    .astype(np.floataa)
    .reshape(-1, 3)
)











"""simple docstring"""

import unittest

from transformers import (
    MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING,
    TF_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING,
    PreTrainedTokenizer,
    is_vision_available,
)
from transformers.pipelines import ImageClassificationPipeline, pipeline
from transformers.testing_utils import (
    is_pipeline_test,
    nested_simplify,
    require_tf,
    require_torch,
    require_torch_or_tf,
    require_vision,
    slow,
)

from .test_pipelines_common import ANY


if is_vision_available():
		from PIL import Image
else:

		class 							lowercase   :







						@staticmethod
						def        a_	(				*_lowerCamelCase :       Tuple   ,  **_lowerCamelCase :       str							):



							"""simple docstring"""

							pass

@is_pipeline_test
@require_torch_or_tf
@require_vision
class 							lowercase   (     unittest.TestCase):
				__lowerCAmelCase     :     str								= MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING
				__lowerCAmelCase     :     Union[str, Any]								= TF_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING







				def        a_	(				self :       Tuple   ,  _lowerCamelCase :       Any   ,  _lowerCamelCase :       str   ,  _lowerCamelCase :       Optional[Any]							):



					"""simple docstring"""

					A_	:					List[str]						 =		ImageClassificationPipeline(model=_lowerCamelCase   ,  image_processor=_lowerCamelCase   ,  top_k=2							)
					A_	:					Tuple						 =		[
					    Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''							),
					    '''http://images.cocodataset.org/val2017/000000039769.jpg''',
					]
					return image_classifier, examples







				def        a_	(				self :       Optional[Any]   ,  _lowerCamelCase :       Optional[int]   ,  _lowerCamelCase :       Optional[Any]							):



					"""simple docstring"""

					A_	:					int						 =		image_classifier('''./tests/fixtures/tests_samples/COCO/000000039769.png'''							)

					self.assertEqual(
					    _lowerCamelCase   ,  [
					        {'''score''': ANY(_lowerCamelCase							), '''label''': ANY(_lowerCamelCase							)},
					        {'''score''': ANY(_lowerCamelCase							), '''label''': ANY(_lowerCamelCase							)},
					    ]   ,  )

					import datasets

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

					# Accepts URL + PIL.Image + lists
					A_	:					Union[str, Any]						 =		image_classifier(
					    [
					        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'''],
					    ]							)
					self.assertEqual(
					    _lowerCamelCase   ,  [
					        [
					            {'''score''': ANY(_lowerCamelCase							), '''label''': ANY(_lowerCamelCase							)},
					            {'''score''': ANY(_lowerCamelCase							), '''label''': ANY(_lowerCamelCase							)},
					        ],
					        [
					            {'''score''': ANY(_lowerCamelCase							), '''label''': ANY(_lowerCamelCase							)},
					            {'''score''': ANY(_lowerCamelCase							), '''label''': ANY(_lowerCamelCase							)},
					        ],
					        [
					            {'''score''': ANY(_lowerCamelCase							), '''label''': ANY(_lowerCamelCase							)},
					            {'''score''': ANY(_lowerCamelCase							), '''label''': ANY(_lowerCamelCase							)},
					        ],
					        [
					            {'''score''': ANY(_lowerCamelCase							), '''label''': ANY(_lowerCamelCase							)},
					            {'''score''': ANY(_lowerCamelCase							), '''label''': ANY(_lowerCamelCase							)},
					        ],
					        [
					            {'''score''': ANY(_lowerCamelCase							), '''label''': ANY(_lowerCamelCase							)},
					            {'''score''': ANY(_lowerCamelCase							), '''label''': ANY(_lowerCamelCase							)},
					        ],
					    ]   ,  )







				@require_torch
				def        a_	(				self :       Dict							):



					"""simple docstring"""

					A_	:					Optional[int]						 =		'''hf-internal-testing/tiny-random-vit'''
					A_	:					Tuple						 =		pipeline('''image-classification'''   ,  model=_lowerCamelCase							)

					A_	:					Optional[int]						 =		image_classifier('''http://images.cocodataset.org/val2017/000000039769.jpg'''							)
					self.assertEqual(
					    nested_simplify(_lowerCamelCase   ,  decimals=4							)   ,  [{'''label''': '''LABEL_1''', '''score''': 0.574}, {'''label''': '''LABEL_0''', '''score''': 0.426}]   ,  )

					A_	:					str						 =		image_classifier(
					    [
					        '''http://images.cocodataset.org/val2017/000000039769.jpg''',
					        '''http://images.cocodataset.org/val2017/000000039769.jpg''',
					    ]   ,  top_k=2   ,  )
					self.assertEqual(
					    nested_simplify(_lowerCamelCase   ,  decimals=4							)   ,  [
					        [{'''label''': '''LABEL_1''', '''score''': 0.574}, {'''label''': '''LABEL_0''', '''score''': 0.426}],
					        [{'''label''': '''LABEL_1''', '''score''': 0.574}, {'''label''': '''LABEL_0''', '''score''': 0.426}],
					    ]   ,  )







				@require_tf
				def        a_	(				self :       Tuple							):



					"""simple docstring"""

					A_	:					List[str]						 =		'''hf-internal-testing/tiny-random-vit'''
					A_	:					Optional[int]						 =		pipeline('''image-classification'''   ,  model=_lowerCamelCase   ,  framework='''tf'''							)

					A_	:					Tuple						 =		image_classifier('''http://images.cocodataset.org/val2017/000000039769.jpg'''							)
					self.assertEqual(
					    nested_simplify(_lowerCamelCase   ,  decimals=4							)   ,  [{'''label''': '''LABEL_1''', '''score''': 0.574}, {'''label''': '''LABEL_0''', '''score''': 0.426}]   ,  )

					A_	:					Optional[Any]						 =		image_classifier(
					    [
					        '''http://images.cocodataset.org/val2017/000000039769.jpg''',
					        '''http://images.cocodataset.org/val2017/000000039769.jpg''',
					    ]   ,  top_k=2   ,  )
					self.assertEqual(
					    nested_simplify(_lowerCamelCase   ,  decimals=4							)   ,  [
					        [{'''label''': '''LABEL_1''', '''score''': 0.574}, {'''label''': '''LABEL_0''', '''score''': 0.426}],
					        [{'''label''': '''LABEL_1''', '''score''': 0.574}, {'''label''': '''LABEL_0''', '''score''': 0.426}],
					    ]   ,  )







				def        a_	(				self :       Dict							):



					"""simple docstring"""

					A_	:					Any						 =		PreTrainedTokenizer()

					# Assert that the pipeline can be initialized with a feature extractor that is not in any mapping
					A_	:					List[Any]						 =		pipeline(
					    '''image-classification'''   ,  model='''hf-internal-testing/tiny-random-vit'''   ,  tokenizer=_lowerCamelCase							)

					self.assertIs(image_classifier.tokenizer   ,  _lowerCamelCase							)







				@slow
				@require_torch
				def        a_	(				self :       List[str]							):



					"""simple docstring"""

					A_	:					List[Any]						 =		pipeline('''image-classification'''   ,  model='''deepmind/vision-perceiver-conv'''							)
					A_	:					Optional[Any]						 =		image_classifier('''http://images.cocodataset.org/val2017/000000039769.jpg'''							)
					self.assertEqual(
					    nested_simplify(_lowerCamelCase   ,  decimals=4							)   ,  [
					        {'''score''': 0.4385, '''label''': '''tabby, tabby cat'''},
					        {'''score''': 0.321, '''label''': '''tiger cat'''},
					        {'''score''': 0.0502, '''label''': '''Egyptian cat'''},
					        {'''score''': 0.0137, '''label''': '''crib, cot'''},
					        {'''score''': 0.007, '''label''': '''radiator'''},
					    ]   ,  )

					A_	:					Dict						 =		pipeline('''image-classification'''   ,  model='''deepmind/vision-perceiver-fourier'''							)
					A_	:					str						 =		image_classifier('''http://images.cocodataset.org/val2017/000000039769.jpg'''							)
					self.assertEqual(
					    nested_simplify(_lowerCamelCase   ,  decimals=4							)   ,  [
					        {'''score''': 0.5658, '''label''': '''tabby, tabby cat'''},
					        {'''score''': 0.1309, '''label''': '''tiger cat'''},
					        {'''score''': 0.0722, '''label''': '''Egyptian cat'''},
					        {'''score''': 0.0707, '''label''': '''remote control, remote'''},
					        {'''score''': 0.0082, '''label''': '''computer keyboard, keypad'''},
					    ]   ,  )

					A_	:					Optional[int]						 =		pipeline('''image-classification'''   ,  model='''deepmind/vision-perceiver-learned'''							)
					A_	:					int						 =		image_classifier('''http://images.cocodataset.org/val2017/000000039769.jpg'''							)
					self.assertEqual(
					    nested_simplify(_lowerCamelCase   ,  decimals=4							)   ,  [
					        {'''score''': 0.3022, '''label''': '''tabby, tabby cat'''},
					        {'''score''': 0.2362, '''label''': '''Egyptian cat'''},
					        {'''score''': 0.1856, '''label''': '''tiger cat'''},
					        {'''score''': 0.0324, '''label''': '''remote control, remote'''},
					        {'''score''': 0.0096, '''label''': '''quilt, comforter, comfort, puff'''},
					    ]   ,  )





