





"""simple docstring"""





import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
						import torch

if is_vision_available():
						from PIL import Image

						from transformers import OwlViTImageProcessor





class 							_lowerCamelCase   (							unittest.TestCase			):


						def __init__(self ,				__a ,				__a=7 ,				__a=3 ,				__a=18 ,				__a=30 ,				__a=4_00 ,				__a=True ,				__a=None ,				__a=True ,				__a=None ,				__a=True ,				__a=[0.48145466, 0.4578275, 0.40821073] ,				__a=[0.26862954, 0.26130258, 0.27577711] ,				__a=True ,				)			-> Union[str, Any]:
								UpperCamelCase =						parent
								UpperCamelCase =						batch_size
								UpperCamelCase =						num_channels
								UpperCamelCase =						image_size
								UpperCamelCase =						min_resolution
								UpperCamelCase =						max_resolution
								UpperCamelCase =						do_resize
								UpperCamelCase =						size if size is not None else {"height": 18, "width": 18}
								UpperCamelCase =						do_center_crop
								UpperCamelCase =						crop_size if crop_size is not None else {"height": 18, "width": 18}
								UpperCamelCase =						do_normalize
								UpperCamelCase =						image_mean
								UpperCamelCase =						image_std
								UpperCamelCase =						do_convert_rgb




						def      snake_case_ (self		)			-> List[Any]:
								return {
								    "do_resize": self.do_resize,
								    "size": self.size,
								    "do_center_crop": self.do_center_crop,
								    "crop_size": self.crop_size,
								    "do_normalize": self.do_normalize,
								    "image_mean": self.image_mean,
								    "image_std": self.image_std,
								    "do_convert_rgb": self.do_convert_rgb,
								}





@require_torch
@require_vision
class 							_lowerCamelCase   (							_lowercase	,      unittest.TestCase			):
						UpperCAmelCase_			=      OwlViTImageProcessor if is_vision_available() else None


						def      snake_case_ (self		)			-> int:
								UpperCamelCase =						OwlViTImageProcessingTester(self		)


						@property
						def      snake_case_ (self		)			-> Optional[int]:
								return self.image_processor_tester.prepare_image_processor_dict()


						def      snake_case_ (self		)			-> Dict:
								UpperCamelCase =						self.image_processing_class(**self.image_processor_dict		)
								self.assertTrue(hasattr(__a ,				"do_resize"		)		)
								self.assertTrue(hasattr(__a ,				"size"		)		)
								self.assertTrue(hasattr(__a ,				"do_center_crop"		)		)
								self.assertTrue(hasattr(__a ,				"center_crop"		)		)
								self.assertTrue(hasattr(__a ,				"do_normalize"		)		)
								self.assertTrue(hasattr(__a ,				"image_mean"		)		)
								self.assertTrue(hasattr(__a ,				"image_std"		)		)
								self.assertTrue(hasattr(__a ,				"do_convert_rgb"		)		)


						def      snake_case_ (self		)			-> Union[str, Any]:
								UpperCamelCase =						self.image_processing_class.from_dict(self.image_processor_dict		)
								self.assertEqual(image_processor.size ,				{"height": 18, "width": 18}		)
								self.assertEqual(image_processor.crop_size ,				{"height": 18, "width": 18}		)

								UpperCamelCase =						self.image_processing_class.from_dict(self.image_processor_dict ,				size=42 ,				crop_size=84		)
								self.assertEqual(image_processor.size ,				{"height": 42, "width": 42}		)
								self.assertEqual(image_processor.crop_size ,				{"height": 84, "width": 84}		)


						def      snake_case_ (self		)			-> str:
								# Initialize image_processing
								UpperCamelCase =						self.image_processing_class(**self.image_processor_dict		)
								# create random PIL images
								UpperCamelCase =						prepare_image_inputs(self.image_processor_tester ,				equal_resolution=__a		)

								for image in image_inputs:
										self.assertIsInstance(__a ,				Image.Image		)

								# Test not batched input
								UpperCamelCase =						image_processing(image_inputs[0] ,				return_tensors="pt"		).pixel_values
								self.assertEqual(
								    encoded_images.shape ,				(
								        1,
								        self.image_processor_tester.num_channels,
								        self.image_processor_tester.crop_size["height"],
								        self.image_processor_tester.crop_size["width"],
								    ) ,				)

								# Test batched
								UpperCamelCase =						image_processing(__a ,				return_tensors="pt"		).pixel_values
								self.assertEqual(
								    encoded_images.shape ,				(
								        self.image_processor_tester.batch_size,
								        self.image_processor_tester.num_channels,
								        self.image_processor_tester.crop_size["height"],
								        self.image_processor_tester.crop_size["width"],
								    ) ,				)


						def      snake_case_ (self		)			-> Union[str, Any]:
								# Initialize image_processing
								UpperCamelCase =						self.image_processing_class(**self.image_processor_dict		)
								# create random numpy tensors
								UpperCamelCase =						prepare_image_inputs(self.image_processor_tester ,				equal_resolution=__a ,				numpify=__a		)
								for image in image_inputs:
										self.assertIsInstance(__a ,				np.ndarray		)

								# Test not batched input
								UpperCamelCase =						image_processing(image_inputs[0] ,				return_tensors="pt"		).pixel_values
								self.assertEqual(
								    encoded_images.shape ,				(
								        1,
								        self.image_processor_tester.num_channels,
								        self.image_processor_tester.crop_size["height"],
								        self.image_processor_tester.crop_size["width"],
								    ) ,				)

								# Test batched
								UpperCamelCase =						image_processing(__a ,				return_tensors="pt"		).pixel_values
								self.assertEqual(
								    encoded_images.shape ,				(
								        self.image_processor_tester.batch_size,
								        self.image_processor_tester.num_channels,
								        self.image_processor_tester.crop_size["height"],
								        self.image_processor_tester.crop_size["width"],
								    ) ,				)




						def      snake_case_ (self		)			-> List[str]:
								# Initialize image_processing
								UpperCamelCase =						self.image_processing_class(**self.image_processor_dict		)
								# create random PyTorch tensors
								UpperCamelCase =						prepare_image_inputs(self.image_processor_tester ,				equal_resolution=__a ,				torchify=__a		)
								for image in image_inputs:
										self.assertIsInstance(__a ,				torch.Tensor		)

								# Test not batched input
								UpperCamelCase =						image_processing(image_inputs[0] ,				return_tensors="pt"		).pixel_values
								self.assertEqual(
								    encoded_images.shape ,				(
								        1,
								        self.image_processor_tester.num_channels,
								        self.image_processor_tester.crop_size["height"],
								        self.image_processor_tester.crop_size["width"],
								    ) ,				)

								# Test batched
								UpperCamelCase =						image_processing(__a ,				return_tensors="pt"		).pixel_values
								self.assertEqual(
								    encoded_images.shape ,				(
								        self.image_processor_tester.batch_size,
								        self.image_processor_tester.num_channels,
								        self.image_processor_tester.crop_size["height"],
								        self.image_processor_tester.crop_size["width"],
								    ) ,				)













"""simple docstring"""





from ..utils import DummyObject, requires_backends





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Union[str, Any]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Any:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Dict:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Optional[Any]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Tuple:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Union[str, Any]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Optional[int]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Optional[Any]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Union[str, Any]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> int:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> List[Any]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Tuple:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Dict:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Any:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Optional[Any]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Dict:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Any:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Dict:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> List[str]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Tuple:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Tuple:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> int:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Optional[Any]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> int:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Tuple:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Tuple:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> str:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Optional[int]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Optional[Any]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Union[str, Any]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> int:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Any:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Dict:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Optional[int]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Optional[int]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Union[str, Any]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> int:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> List[Any]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Dict:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Dict:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> List[Any]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Optional[int]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Tuple:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> List[Any]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> List[str]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> str:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> int:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Dict:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> List[Any]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> List[str]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> int:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Optional[int]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> int:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> str:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> str:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> int:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Dict:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Dict:
								requires_backends(self ,				["tokenizers"]		)






