

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


class 					lowerCAmelCase       ( unittest.TestCase				):







       def __init__(							self     :	Optional[int]  , __lowercase     :	Tuple  , __lowercase     :	str=13  , __lowercase     :	Union[str, Any]=3  , __lowercase     :	List[str]=18  , __lowercase     :	List[str]=30  , __lowercase     :	Tuple=400  , __lowercase     :	List[Any]=True  , __lowercase     :	Union[str, Any]=None  , __lowercase     :	Tuple=True  , __lowercase     :	int=[0.5, 0.5, 0.5]  , __lowercase     :	Union[str, Any]=[0.5, 0.5, 0.5]  , ):







            """simple docstring"""







            __lowercase     						=size if size is not None else {'height': 18, 'width': 18}
            __lowercase     						=parent
            __lowercase     						=batch_size
            __lowercase     						=num_channels
            __lowercase     						=image_size
            __lowercase     						=min_resolution
            __lowercase     						=max_resolution
            __lowercase     						=do_resize
            __lowercase     						=size
            __lowercase     						=do_normalize
            __lowercase     						=image_mean
            __lowercase     						=image_std







       def      snake_case				(							self     :	int ):







            """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				):
       lowerCAmelCase_				=	EfficientNetImageProcessor if is_vision_available() else None







       def      snake_case				(							self     :	int ):







            """simple docstring"""







            __lowercase     						=EfficientNetImageProcessorTester(self )







       @property
       def      snake_case				(							self     :	List[Any] ):







            """simple docstring"""







            return self.image_processor_tester.prepare_image_processor_dict()







       def      snake_case				(							self     :	int ):







            """simple docstring"""







            __lowercase     						=self.image_processing_class(**self.image_processor_dict )
            self.assertTrue(hasattr(__lowercase  , 'image_mean' ) )
            self.assertTrue(hasattr(__lowercase  , 'image_std' ) )
            self.assertTrue(hasattr(__lowercase  , 'do_normalize' ) )
            self.assertTrue(hasattr(__lowercase  , 'do_resize' ) )
            self.assertTrue(hasattr(__lowercase  , 'size' ) )







       def      snake_case				(							self     :	List[Any] ):







            """simple docstring"""







            __lowercase     						=self.image_processing_class.from_dict(self.image_processor_dict )
            self.assertEqual(image_processor.size  , {'height': 18, 'width': 18} )

            __lowercase     						=self.image_processing_class.from_dict(self.image_processor_dict  , size=42 )
            self.assertEqual(image_processor.size  , {'height': 42, 'width': 42} )







       def      snake_case				(							self     :	Optional[Any] ):







            """simple docstring"""







            __lowercase     						=self.image_processing_class(**self.image_processor_dict )
            # create random PIL images
            __lowercase     						=prepare_image_inputs(self.image_processor_tester  , equal_resolution=__lowercase )
            for image in image_inputs:
                 self.assertIsInstance(__lowercase  , Image.Image )

            # Test not batched input
            __lowercase     						=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.size['height'],
                    self.image_processor_tester.size['width'],
                )  , )

            # Test batched
            __lowercase     						=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.size['height'],
                    self.image_processor_tester.size['width'],
                )  , )







       def      snake_case				(							self     :	List[str] ):







            """simple docstring"""







            __lowercase     						=self.image_processing_class(**self.image_processor_dict )
            # create random numpy tensors
            __lowercase     						=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
            __lowercase     						=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.size['height'],
                    self.image_processor_tester.size['width'],
                )  , )

            # Test batched
            __lowercase     						=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.size['height'],
                    self.image_processor_tester.size['width'],
                )  , )







       def      snake_case				(							self     :	str ):







            """simple docstring"""







            __lowercase     						=self.image_processing_class(**self.image_processor_dict )
            # create random PyTorch tensors
            __lowercase     						=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
            __lowercase     						=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.size['height'],
                    self.image_processor_tester.size['width'],
                )  , )

            # Test batched
            __lowercase     						=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.size['height'],
                    self.image_processor_tester.size['width'],
                )  , )





'''simple docstring'''

from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


UpperCAmelCase							=					{
    '''configuration_videomae''': ['''VIDEOMAE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''VideoMAEConfig'''],
}

try:
       if not is_torch_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       UpperCAmelCase							=					[
           '''VIDEOMAE_PRETRAINED_MODEL_ARCHIVE_LIST''',
           '''VideoMAEForPreTraining''',
           '''VideoMAEModel''',
           '''VideoMAEPreTrainedModel''',
           '''VideoMAEForVideoClassification''',
       ]

try:
       if not is_vision_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       UpperCAmelCase							=					['''VideoMAEFeatureExtractor''']
       UpperCAmelCase							=					['''VideoMAEImageProcessor''']

if TYPE_CHECKING:
       from .configuration_videomae import VIDEOMAE_PRETRAINED_CONFIG_ARCHIVE_MAP, VideoMAEConfig

       try:
              if not is_torch_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_videomae import (
                  VIDEOMAE_PRETRAINED_MODEL_ARCHIVE_LIST,
                  VideoMAEForPreTraining,
                  VideoMAEForVideoClassification,
                  VideoMAEModel,
                  VideoMAEPreTrainedModel,
              )

       try:
              if not is_vision_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .feature_extraction_videomae import VideoMAEFeatureExtractor
              from .image_processing_videomae import VideoMAEImageProcessor

else:
       import sys

       UpperCAmelCase							=					_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)


