





'''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 ViTImageProcessor






class 				__snake_case     (					unittest.TestCase							):





	def __init__(		self      ,       UpperCamelCase_      ,       UpperCamelCase_=13      ,       UpperCamelCase_=3      ,       UpperCamelCase_=224      ,       UpperCamelCase_=30      ,       UpperCamelCase_=400      ,       UpperCamelCase_=True      ,       UpperCamelCase_=None      ,       UpperCamelCase_=True      ,       UpperCamelCase_=[0.5, 0.5, 0.5]      ,       UpperCamelCase_=[0.5, 0.5, 0.5]      ,       )      ->		Optional[Any]:
		snake_case__	       =   size if size is not None else {'height': 18, 'width': 18}
		snake_case__	       =   parent
		snake_case__	       =   batch_size
		snake_case__	       =   num_channels
		snake_case__	       =   image_size
		snake_case__	       =   min_resolution
		snake_case__	       =   max_resolution
		snake_case__	       =   do_resize
		snake_case__	       =   size
		snake_case__	       =   do_normalize
		snake_case__	       =   image_mean
		snake_case__	       =   image_std





	def   _snake_case   (		self		)      ->		Dict:
		return {
		    "image_mean": self.image_mean,
		    "image_std": self.image_std,
		    "do_normalize": self.do_normalize,
		    "do_resize": self.do_resize,
		    "size": self.size,
		}






@require_torch
@require_vision
class 				__snake_case     (					__magic_name__       ,       unittest.TestCase							):
	__lowerCAmelCase       						=  ViTImageProcessor if is_vision_available() else None





	def   _snake_case   (		self		)      ->		Optional[Any]:
		snake_case__	       =   EfficientFormerImageProcessorTester(self		)





	@property
	def   _snake_case   (		self		)      ->		Union[str, Any]:
		return self.image_proc_tester.prepare_image_processor_dict()





	def   _snake_case   (		self		)      ->		List[str]:
		snake_case__	       =   self.image_processing_class(**self.image_processor_dict		)
		self.assertTrue(hasattr(UpperCamelCase_      ,       'image_mean'		)		)
		self.assertTrue(hasattr(UpperCamelCase_      ,       'image_std'		)		)
		self.assertTrue(hasattr(UpperCamelCase_      ,       'do_normalize'		)		)
		self.assertTrue(hasattr(UpperCamelCase_      ,       'do_resize'		)		)
		self.assertTrue(hasattr(UpperCamelCase_      ,       'size'		)		)





	def   _snake_case   (		self		)      ->		Tuple:
		pass





	def   _snake_case   (		self		)      ->		Dict:
		# Initialize image_processor
		snake_case__	       =   self.image_processing_class(**self.image_processor_dict		)
		# create random PIL images
		snake_case__	       =   prepare_image_inputs(self.image_proc_tester      ,       equal_resolution=UpperCamelCase_		)
		for image in image_inputs:
			self.assertIsInstance(UpperCamelCase_      ,       Image.Image		)

		# Test not batched input
		snake_case__	       =   image_processor(image_inputs[0]      ,       return_tensors='pt'		).pixel_values
		self.assertEqual(
		    encoded_images.shape      ,       (
		        1,
		        self.image_proc_tester.num_channels,
		        self.image_proc_tester.size['height'],
		        self.image_proc_tester.size['width'],
		    )      ,       )

		# Test batched
		snake_case__	       =   image_processor(UpperCamelCase_      ,       return_tensors='pt'		).pixel_values
		self.assertEqual(
		    encoded_images.shape      ,       (
		        self.image_proc_tester.batch_size,
		        self.image_proc_tester.num_channels,
		        self.image_proc_tester.size['height'],
		        self.image_proc_tester.size['width'],
		    )      ,       )





	def   _snake_case   (		self		)      ->		List[str]:
		# Initialize image_processor
		snake_case__	       =   self.image_processing_class(**self.image_processor_dict		)
		# create random numpy tensors
		snake_case__	       =   prepare_image_inputs(self.image_proc_tester      ,       equal_resolution=UpperCamelCase_      ,       numpify=UpperCamelCase_		)
		for image in image_inputs:
			self.assertIsInstance(UpperCamelCase_      ,       np.ndarray		)

		# Test not batched input
		snake_case__	       =   image_processor(image_inputs[0]      ,       return_tensors='pt'		).pixel_values
		self.assertEqual(
		    encoded_images.shape      ,       (
		        1,
		        self.image_proc_tester.num_channels,
		        self.image_proc_tester.size['height'],
		        self.image_proc_tester.size['width'],
		    )      ,       )

		# Test batched
		snake_case__	       =   image_processor(UpperCamelCase_      ,       return_tensors='pt'		).pixel_values
		self.assertEqual(
		    encoded_images.shape      ,       (
		        self.image_proc_tester.batch_size,
		        self.image_proc_tester.num_channels,
		        self.image_proc_tester.size['height'],
		        self.image_proc_tester.size['width'],
		    )      ,       )





	def   _snake_case   (		self		)      ->		Tuple:
		# Initialize image_processor
		snake_case__	       =   self.image_processing_class(**self.image_processor_dict		)
		# create random PyTorch tensors
		snake_case__	       =   prepare_image_inputs(self.image_proc_tester      ,       equal_resolution=UpperCamelCase_      ,       torchify=UpperCamelCase_		)
		for image in image_inputs:
			self.assertIsInstance(UpperCamelCase_      ,       torch.Tensor		)

		# Test not batched input
		snake_case__	       =   image_processor(image_inputs[0]      ,       return_tensors='pt'		).pixel_values
		self.assertEqual(
		    encoded_images.shape      ,       (
		        1,
		        self.image_proc_tester.num_channels,
		        self.image_proc_tester.size['height'],
		        self.image_proc_tester.size['width'],
		    )      ,       )

		# Test batched
		snake_case__	       =   image_processor(UpperCamelCase_      ,       return_tensors='pt'		).pixel_values
		self.assertEqual(
		    encoded_images.shape      ,       (
		        self.image_proc_tester.batch_size,
		        self.image_proc_tester.num_channels,
		        self.image_proc_tester.size['height'],
		        self.image_proc_tester.size['width'],
		    )      ,       )










'''simple docstring'''




import warnings

from ...utils import logging
from .image_processing_perceiver import PerceiverImageProcessor


a__					:			int          =     logging.get_logger(__name__)






class 				__snake_case     (					__magic_name__							):





	def __init__(		self      ,       *UpperCamelCase_      ,       **UpperCamelCase_		)      ->		None:
		warnings.warn(
		    'The class PerceiverFeatureExtractor is deprecated and will be removed in version 5 of Transformers.'
		    ' Please use PerceiverImageProcessor instead.'      ,       UpperCamelCase_      ,       )
		super().__init__(*UpperCamelCase_      ,       **UpperCamelCase_		)



