"""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   UpperCAmelCase__				(    unittest.TestCase			):


	"""simple docstring"""







	def __init__(			self       ,     _SCREAMING_SNAKE_CASE       ,     _SCREAMING_SNAKE_CASE=7       ,     _SCREAMING_SNAKE_CASE=3       ,     _SCREAMING_SNAKE_CASE=1_8       ,     _SCREAMING_SNAKE_CASE=3_0       ,     _SCREAMING_SNAKE_CASE=4_0_0       ,     _SCREAMING_SNAKE_CASE=True       ,     _SCREAMING_SNAKE_CASE=None       ,     _SCREAMING_SNAKE_CASE=True       ,     _SCREAMING_SNAKE_CASE=None       ,     _SCREAMING_SNAKE_CASE=True       ,     _SCREAMING_SNAKE_CASE=[0.4_8_1_4_5_4_6_6, 0.4_5_7_8_2_7_5, 0.4_0_8_2_1_0_7_3]       ,     _SCREAMING_SNAKE_CASE=[0.2_6_8_6_2_9_5_4, 0.2_6_1_3_0_2_5_8, 0.2_7_5_7_7_7_1_1]       ,     _SCREAMING_SNAKE_CASE=True       ,     )    ->	Union[str, Any]:
							a_							:			Optional[int]     		=					parent
							a_							:			Any     		=					batch_size
							a_							:			List[str]     		=					num_channels
							a_							:			Optional[Any]     		=					image_size
							a_							:			Tuple     		=					min_resolution
							a_							:			Any     		=					max_resolution
							a_							:			Dict     		=					do_resize
							a_							:			Dict     		=					size if size is not None else {'''height''': 1_8, '''width''': 1_8}
							a_							:			Dict     		=					do_center_crop
							a_							:			Optional[int]     		=					crop_size if crop_size is not None else {'''height''': 1_8, '''width''': 1_8}
							a_							:			int     		=					do_normalize
							a_							:			List[str]     		=					image_mean
							a_							:			Union[str, Any]     		=					image_std
							a_							:			Optional[Any]     		=					do_convert_rgb







	def       A    (			self )    ->	str:
							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   UpperCAmelCase__				(    __UpperCAmelCase,      unittest.TestCase			):


	"""simple docstring"""
	lowerCAmelCase__    :					List[str]						      =							OwlViTImageProcessor if is_vision_available() else None







	def       A    (			self )    ->	Tuple:
							a_							:			Any     		=					OwlViTImageProcessingTester(self )







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







	def       A    (			self )    ->	Any:
							a_							:			Optional[int]     		=					self.image_processing_class(**self.image_processor_dict )
							self.assertTrue(hasattr(lowercase_       ,     "do_resize" ) )
							self.assertTrue(hasattr(lowercase_       ,     "size" ) )
							self.assertTrue(hasattr(lowercase_       ,     "do_center_crop" ) )
							self.assertTrue(hasattr(lowercase_       ,     "center_crop" ) )
							self.assertTrue(hasattr(lowercase_       ,     "do_normalize" ) )
							self.assertTrue(hasattr(lowercase_       ,     "image_mean" ) )
							self.assertTrue(hasattr(lowercase_       ,     "image_std" ) )
							self.assertTrue(hasattr(lowercase_       ,     "do_convert_rgb" ) )







	def       A    (			self )    ->	Optional[Any]:
							a_							:			List[Any]     		=					self.image_processing_class.from_dict(self.image_processor_dict )
							self.assertEqual(image_processor.size       ,     {"height": 1_8, "width": 1_8} )
							self.assertEqual(image_processor.crop_size       ,     {"height": 1_8, "width": 1_8} )

							a_							:			str     		=					self.image_processing_class.from_dict(self.image_processor_dict       ,     size=4_2       ,     crop_size=8_4 )
							self.assertEqual(image_processor.size       ,     {"height": 4_2, "width": 4_2} )
							self.assertEqual(image_processor.crop_size       ,     {"height": 8_4, "width": 8_4} )







	def       A    (			self )    ->	Any:
							a_							:			Tuple     		=					self.image_processing_class(**self.image_processor_dict )
							# create random PIL images
							a_							:			Tuple     		=					prepare_image_inputs(self.image_processor_tester       ,     equal_resolution=lowercase_ )

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

							# Test not batched input
							a_							:			Optional[int]     		=					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
							a_							:			Any     		=					image_processing(lowercase_       ,     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       A    (			self )    ->	List[str]:
							a_							:			Optional[int]     		=					self.image_processing_class(**self.image_processor_dict )
							# create random numpy tensors
							a_							:			Tuple     		=					prepare_image_inputs(self.image_processor_tester       ,     equal_resolution=lowercase_       ,     numpify=lowercase_ )
							for image in image_inputs:
													self.assertIsInstance(lowercase_       ,     np.ndarray )

							# Test not batched input
							a_							:			List[str]     		=					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
							a_							:			List[Any]     		=					image_processing(lowercase_       ,     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       A    (			self )    ->	Dict:
							a_							:			Optional[Any]     		=					self.image_processing_class(**self.image_processor_dict )
							# create random PyTorch tensors
							a_							:			List[Any]     		=					prepare_image_inputs(self.image_processor_tester       ,     equal_resolution=lowercase_       ,     torchify=lowercase_ )
							for image in image_inputs:
													self.assertIsInstance(lowercase_       ,     torch.Tensor )

							# Test not batched input
							a_							:			List[str]     		=					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
							a_							:			Any     		=					image_processing(lowercase_       ,     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"""






import unittest

import torch

from diffusers import DDIMScheduler, TextToVideoZeroPipeline
from diffusers.utils import load_pt, require_torch_gpu, slow

from ..test_pipelines_common import assert_mean_pixel_difference
@slow
@require_torch_gpu
class   UpperCAmelCase__				(    unittest.TestCase			):


	"""simple docstring"""







	def       A    (			self )    ->	List[str]:
							a_							:			List[str]     		=					"runwayml/stable-diffusion-v1-5"
							a_							:			Optional[int]     		=					TextToVideoZeroPipeline.from_pretrained(_SCREAMING_SNAKE_CASE       ,     torch_dtype=torch.floataa ).to("cuda" )
							a_							:			Dict     		=					DDIMScheduler.from_config(pipe.scheduler.config )
							a_							:			Optional[Any]     		=					torch.Generator(device="cuda" ).manual_seed(0 )

							a_							:			List[Any]     		=					"A bear is playing a guitar on Times Square"
							a_							:			List[Any]     		=					pipe(prompt=_SCREAMING_SNAKE_CASE       ,     generator=_SCREAMING_SNAKE_CASE ).images

							a_							:			Optional[int]     		=					load_pt(
							    "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/text-to-video/A bear is playing a guitar on Times Square.pt" )

							assert_mean_pixel_difference(_SCREAMING_SNAKE_CASE       ,     _SCREAMING_SNAKE_CASE )




