





"""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    _lowerCAmelCase  (	unittest.TestCase			):
       """simple docstring"""




       def __init__(       self       ,					__UpperCAmelCase       ,					__UpperCAmelCase=1_3       ,					__UpperCAmelCase=3       ,					__UpperCAmelCase=2_2_4       ,					__UpperCAmelCase=3_0       ,					__UpperCAmelCase=4_0_0       ,					__UpperCAmelCase=True       ,					__UpperCAmelCase=None       ,					__UpperCAmelCase=True       ,					__UpperCAmelCase=[0.5, 0.5, 0.5]       ,					__UpperCAmelCase=[0.5, 0.5, 0.5]       ,					):



         '''simple docstring'''

         lowerCAmelCase__     :str											=				size if size is not None else {'height': 1_8, 'width': 1_8}
         lowerCAmelCase__     :List[Any]											=				parent
         lowerCAmelCase__     :Union[str, Any]											=				batch_size
         lowerCAmelCase__     :Dict											=				num_channels
         lowerCAmelCase__     :str											=				image_size
         lowerCAmelCase__     :Any											=				min_resolution
         lowerCAmelCase__     :int											=				max_resolution
         lowerCAmelCase__     :Optional[int]											=				do_resize
         lowerCAmelCase__     :Union[str, Any]											=				size
         lowerCAmelCase__     :Any											=				do_normalize
         lowerCAmelCase__     :Any											=				image_mean
         lowerCAmelCase__     :Union[str, Any]											=				image_std






       def 	snake_case		(       self ):



         '''simple docstring'''

         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    _lowerCAmelCase  (	a_    ,  unittest.TestCase			):
       """simple docstring"""




       __magic_name__	:List[str]						    =   ViTImageProcessor if is_vision_available() else None






       def 	snake_case		(       self ):



         '''simple docstring'''

         lowerCAmelCase__     :Optional[int]											=				EfficientFormerImageProcessorTester(self )






       @property
       def 	snake_case		(       self ):



         '''simple docstring'''

         return self.image_proc_tester.prepare_image_processor_dict()






       def 	snake_case		(       self ):



         '''simple docstring'''

         lowerCAmelCase__     :Optional[int]											=				self.image_processing_class(**self.image_processor_dict )
         self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE       ,					'image_mean' ) )
         self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE       ,					'image_std' ) )
         self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE       ,					'do_normalize' ) )
         self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE       ,					'do_resize' ) )
         self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE       ,					'size' ) )






       def 	snake_case		(       self ):



         '''simple docstring'''

         pass






       def 	snake_case		(       self ):



         '''simple docstring'''

         lowerCAmelCase__     :List[str]											=				self.image_processing_class(**self.image_processor_dict )
         # create random PIL images
         lowerCAmelCase__     :Union[str, Any]											=				prepare_image_inputs(self.image_proc_tester       ,					equal_resolution=_SCREAMING_SNAKE_CASE )
         for image in image_inputs:
           self.assertIsInstance(_SCREAMING_SNAKE_CASE       ,					Image.Image )

         # Test not batched input
         lowerCAmelCase__     :int											=				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
         lowerCAmelCase__     :Optional[int]											=				image_processor(_SCREAMING_SNAKE_CASE       ,					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 ):



         '''simple docstring'''

         lowerCAmelCase__     :List[Any]											=				self.image_processing_class(**self.image_processor_dict )
         # create random numpy tensors
         lowerCAmelCase__     :Any											=				prepare_image_inputs(self.image_proc_tester       ,					equal_resolution=_SCREAMING_SNAKE_CASE       ,					numpify=_SCREAMING_SNAKE_CASE )
         for image in image_inputs:
           self.assertIsInstance(_SCREAMING_SNAKE_CASE       ,					np.ndarray )

         # Test not batched input
         lowerCAmelCase__     :List[str]											=				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
         lowerCAmelCase__     :str											=				image_processor(_SCREAMING_SNAKE_CASE       ,					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 ):



         '''simple docstring'''

         lowerCAmelCase__     :Optional[int]											=				self.image_processing_class(**self.image_processor_dict )
         # create random PyTorch tensors
         lowerCAmelCase__     :str											=				prepare_image_inputs(self.image_proc_tester       ,					equal_resolution=_SCREAMING_SNAKE_CASE       ,					torchify=_SCREAMING_SNAKE_CASE )
         for image in image_inputs:
           self.assertIsInstance(_SCREAMING_SNAKE_CASE       ,					torch.Tensor )

         # Test not batched input
         lowerCAmelCase__     :Union[str, Any]											=				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
         lowerCAmelCase__     :Union[str, Any]											=				image_processor(_SCREAMING_SNAKE_CASE       ,					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'''



from dataclasses import dataclass
from typing import List, Optional, Union

import numpy as np
import torch

from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available



@dataclass
class 				_snake_case					(   a_			):
  SCREAMING_SNAKE_CASE			:       Union[List[np.ndarray], torch.FloatTensor]


try:
     if not (is_transformers_available() and is_torch_available()):
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     from ...utils.dummy_torch_and_transformers_objects import *  # noqa F403
else:
     from .pipeline_text_to_video_synth import TextToVideoSDPipeline
     from .pipeline_text_to_video_synth_imgaimg import VideoToVideoSDPipeline  # noqa: F401
     from .pipeline_text_to_video_zero import TextToVideoZeroPipeline





