




'''simple docstring'''



from typing import Dict, List, Optional, Union

import numpy as np

from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
from ...image_transforms import (
    center_crop,
    convert_to_rgb,
    get_resize_output_image_size,
    normalize,
    rescale,
    resize,
    to_channel_dimension_format,
)
from ...image_utils import (
    OPENAI_CLIP_MEAN,
    OPENAI_CLIP_STD,
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, is_vision_available, logging


lowerCamelCase_			=						logging.get_logger(__name__)


if is_vision_available():
 import PIL







class 		lowercase_   (			A       ):


   """simple docstring"""

   lowerCamelCase_      =						['''pixel_values''']



   def __init__(   self :     Optional[int]  ,				__lowerCamelCase :     bool = True  ,				__lowerCamelCase :     Dict[str, int] = None  ,				__lowerCamelCase :     PILImageResampling = PILImageResampling.BICUBIC  ,				__lowerCamelCase :     bool = True  ,				__lowerCamelCase :     Dict[str, int] = None  ,				__lowerCamelCase :     bool = True  ,				__lowerCamelCase :     Union[int, float] = 1 / 2_5_5  ,				__lowerCamelCase :     bool = True  ,				__lowerCamelCase :     Optional[Union[float, List[float]]] = None  ,				__lowerCamelCase :     Optional[Union[float, List[float]]] = None  ,				__lowerCamelCase :     bool = True  ,				**__lowerCamelCase :     Optional[Any]  ,				):

      """simple docstring"""
      super().__init__(**__lowerCamelCase   )
      _SCREAMING_SNAKE_CASE	=				size if size is not None else {"shortest_edge": 2_2_4}
      _SCREAMING_SNAKE_CASE	=				get_size_dict(__lowerCamelCase  ,				default_to_square=__lowerCamelCase   )
      _SCREAMING_SNAKE_CASE	=				crop_size if crop_size is not None else {"height": 2_2_4, "width": 2_2_4}
      _SCREAMING_SNAKE_CASE	=				get_size_dict(__lowerCamelCase  ,				default_to_square=__lowerCamelCase  ,				param_name="crop_size"   )

      _SCREAMING_SNAKE_CASE	=				do_resize
      _SCREAMING_SNAKE_CASE	=				size
      _SCREAMING_SNAKE_CASE	=				resample
      _SCREAMING_SNAKE_CASE	=				do_center_crop
      _SCREAMING_SNAKE_CASE	=				crop_size
      _SCREAMING_SNAKE_CASE	=				do_rescale
      _SCREAMING_SNAKE_CASE	=				rescale_factor
      _SCREAMING_SNAKE_CASE	=				do_normalize
      _SCREAMING_SNAKE_CASE	=				image_mean if image_mean is not None else OPENAI_CLIP_MEAN
      _SCREAMING_SNAKE_CASE	=				image_std if image_std is not None else OPENAI_CLIP_STD
      _SCREAMING_SNAKE_CASE	=				do_convert_rgb



   def 							lowerCAmelCase_      (   self :     int  ,				__lowerCamelCase :     np.ndarray  ,				__lowerCamelCase :     Dict[str, int]  ,				__lowerCamelCase :     PILImageResampling = PILImageResampling.BICUBIC  ,				__lowerCamelCase :     Optional[Union[str, ChannelDimension]] = None  ,				**__lowerCamelCase :     int  ,				):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE	=				get_size_dict(__lowerCamelCase  ,				default_to_square=__lowerCamelCase   )
      if "shortest_edge" not in size:
         raise ValueError(F"""The `size` parameter must contain the key `shortest_edge`. Got {size.keys()}"""   )
      _SCREAMING_SNAKE_CASE	=				get_resize_output_image_size(__lowerCamelCase  ,				size=size["shortest_edge"]  ,				default_to_square=__lowerCamelCase   )
      return resize(__lowerCamelCase  ,				size=__lowerCamelCase  ,				resample=__lowerCamelCase  ,				data_format=__lowerCamelCase  ,				**__lowerCamelCase   )



   def 							lowerCAmelCase_      (   self :     Any  ,				__lowerCamelCase :     np.ndarray  ,				__lowerCamelCase :     Dict[str, int]  ,				__lowerCamelCase :     Optional[Union[str, ChannelDimension]] = None  ,				**__lowerCamelCase :     int  ,				):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE	=				get_size_dict(__lowerCamelCase   )
      if "height" not in size or "width" not in size:
         raise ValueError(F"""The `size` parameter must contain the keys (height, width). Got {size.keys()}"""   )
      return center_crop(__lowerCamelCase  ,				size=(size["height"], size["width"])  ,				data_format=__lowerCamelCase  ,				**__lowerCamelCase   )



   def 							lowerCAmelCase_      (   self :     Any  ,				__lowerCamelCase :     np.ndarray  ,				__lowerCamelCase :     Union[int, float]  ,				__lowerCamelCase :     Optional[Union[str, ChannelDimension]] = None  ,				**__lowerCamelCase :     str  ,				):

      """simple docstring"""
      return rescale(__lowerCamelCase  ,				scale=__lowerCamelCase  ,				data_format=__lowerCamelCase  ,				**__lowerCamelCase   )



   def 							lowerCAmelCase_      (   self :     List[Any]  ,				__lowerCamelCase :     np.ndarray  ,				__lowerCamelCase :     Union[float, List[float]]  ,				__lowerCamelCase :     Union[float, List[float]]  ,				__lowerCamelCase :     Optional[Union[str, ChannelDimension]] = None  ,				**__lowerCamelCase :     Tuple  ,				):

      """simple docstring"""
      return normalize(__lowerCamelCase  ,				mean=__lowerCamelCase  ,				std=__lowerCamelCase  ,				data_format=__lowerCamelCase  ,				**__lowerCamelCase   )



   def 							lowerCAmelCase_      (   self :     str  ,				__lowerCamelCase :     ImageInput  ,				__lowerCamelCase :     bool = None  ,				__lowerCamelCase :     Dict[str, int] = None  ,				__lowerCamelCase :     PILImageResampling = None  ,				__lowerCamelCase :     bool = None  ,				__lowerCamelCase :     int = None  ,				__lowerCamelCase :     bool = None  ,				__lowerCamelCase :     float = None  ,				__lowerCamelCase :     bool = None  ,				__lowerCamelCase :     Optional[Union[float, List[float]]] = None  ,				__lowerCamelCase :     Optional[Union[float, List[float]]] = None  ,				__lowerCamelCase :     bool = None  ,				__lowerCamelCase :     Optional[Union[str, TensorType]] = None  ,				__lowerCamelCase :     Optional[ChannelDimension] = ChannelDimension.FIRST  ,				**__lowerCamelCase :     str  ,				):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE	=				do_resize if do_resize is not None else self.do_resize
      _SCREAMING_SNAKE_CASE	=				size if size is not None else self.size
      _SCREAMING_SNAKE_CASE	=				get_size_dict(__lowerCamelCase  ,				param_name="size"  ,				default_to_square=__lowerCamelCase   )
      _SCREAMING_SNAKE_CASE	=				resample if resample is not None else self.resample
      _SCREAMING_SNAKE_CASE	=				do_center_crop if do_center_crop is not None else self.do_center_crop
      _SCREAMING_SNAKE_CASE	=				crop_size if crop_size is not None else self.crop_size
      _SCREAMING_SNAKE_CASE	=				get_size_dict(__lowerCamelCase  ,				param_name="crop_size"  ,				default_to_square=__lowerCamelCase   )
      _SCREAMING_SNAKE_CASE	=				do_rescale if do_rescale is not None else self.do_rescale
      _SCREAMING_SNAKE_CASE	=				rescale_factor if rescale_factor is not None else self.rescale_factor
      _SCREAMING_SNAKE_CASE	=				do_normalize if do_normalize is not None else self.do_normalize
      _SCREAMING_SNAKE_CASE	=				image_mean if image_mean is not None else self.image_mean
      _SCREAMING_SNAKE_CASE	=				image_std if image_std is not None else self.image_std
      _SCREAMING_SNAKE_CASE	=				do_convert_rgb if do_convert_rgb is not None else self.do_convert_rgb

      _SCREAMING_SNAKE_CASE	=				make_list_of_images(__lowerCamelCase   )

      if not valid_images(__lowerCamelCase   ):
         raise ValueError(
             "Invalid image type. Must be of type PIL.Image.Image, numpy.ndarray, "
             "torch.Tensor, tf.Tensor or jax.ndarray."   )

      if do_resize and size is None:
         raise ValueError("Size must be specified if do_resize is True."   )

      if do_center_crop and crop_size is None:
         raise ValueError("Crop size must be specified if do_center_crop is True."   )

      if do_rescale and rescale_factor is None:
         raise ValueError("Rescale factor must be specified if do_rescale is True."   )

      if do_normalize and (image_mean is None or image_std is None):
         raise ValueError("Image mean and std must be specified if do_normalize is True."   )

      # PIL RGBA images are converted to RGB
      if do_convert_rgb:
         _SCREAMING_SNAKE_CASE	=				[convert_to_rgb(__lowerCamelCase   ) for image in images]

      # All transformations expect numpy arrays.
      _SCREAMING_SNAKE_CASE	=				[to_numpy_array(__lowerCamelCase   ) for image in images]

      if do_resize:
         _SCREAMING_SNAKE_CASE	=				[self.resize(image=__lowerCamelCase  ,				size=__lowerCamelCase  ,				resample=__lowerCamelCase   ) for image in images]

      if do_center_crop:
         _SCREAMING_SNAKE_CASE	=				[self.center_crop(image=__lowerCamelCase  ,				size=__lowerCamelCase   ) for image in images]

      if do_rescale:
         _SCREAMING_SNAKE_CASE	=				[self.rescale(image=__lowerCamelCase  ,				scale=__lowerCamelCase   ) for image in images]

      if do_normalize:
         _SCREAMING_SNAKE_CASE	=				[self.normalize(image=__lowerCamelCase  ,				mean=__lowerCamelCase  ,				std=__lowerCamelCase   ) for image in images]

      _SCREAMING_SNAKE_CASE	=				[to_channel_dimension_format(__lowerCamelCase  ,				__lowerCamelCase   ) for image in images]

      _SCREAMING_SNAKE_CASE	=				{"pixel_values": images}
      return BatchFeature(data=__lowerCamelCase  ,				tensor_type=__lowerCamelCase   )







'''simple docstring'''



from collections import OrderedDict
from typing import List, Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


lowerCamelCase_			=						logging.get_logger(__name__)

lowerCamelCase_			=						{
    'google/efficientnet-b7': 'https://huggingface.co/google/efficientnet-b7/resolve/main/config.json',
}







class 		lowercase_   (			A       ):


   """simple docstring"""

   lowerCamelCase_      =						'''efficientnet'''



   def __init__(   self :     Optional[Any]  ,				__lowerCamelCase :     int = 3  ,				__lowerCamelCase :     int = 6_0_0  ,				__lowerCamelCase :     float = 2.0  ,				__lowerCamelCase :     float = 3.1  ,				__lowerCamelCase :     int = 8  ,				__lowerCamelCase :     List[int] = [3, 3, 5, 3, 5, 5, 3]  ,				__lowerCamelCase :     List[int] = [3_2, 1_6, 2_4, 4_0, 8_0, 1_1_2, 1_9_2]  ,				__lowerCamelCase :     List[int] = [1_6, 2_4, 4_0, 8_0, 1_1_2, 1_9_2, 3_2_0]  ,				__lowerCamelCase :     List[int] = []  ,				__lowerCamelCase :     List[int] = [1, 2, 2, 2, 1, 2, 1]  ,				__lowerCamelCase :     List[int] = [1, 2, 2, 3, 3, 4, 1]  ,				__lowerCamelCase :     List[int] = [1, 6, 6, 6, 6, 6, 6]  ,				__lowerCamelCase :     float = 0.2_5  ,				__lowerCamelCase :     str = "swish"  ,				__lowerCamelCase :     int = 2_5_6_0  ,				__lowerCamelCase :     str = "mean"  ,				__lowerCamelCase :     float = 0.0_2  ,				__lowerCamelCase :     float = 0.0_0_1  ,				__lowerCamelCase :     float = 0.9_9  ,				__lowerCamelCase :     float = 0.5  ,				__lowerCamelCase :     float = 0.2  ,				**__lowerCamelCase :     Tuple  ,				):

      """simple docstring"""
      super().__init__(**__lowerCamelCase   )

      _SCREAMING_SNAKE_CASE	=				num_channels
      _SCREAMING_SNAKE_CASE	=				image_size
      _SCREAMING_SNAKE_CASE	=				width_coefficient
      _SCREAMING_SNAKE_CASE	=				depth_coefficient
      _SCREAMING_SNAKE_CASE	=				depth_divisor
      _SCREAMING_SNAKE_CASE	=				kernel_sizes
      _SCREAMING_SNAKE_CASE	=				in_channels
      _SCREAMING_SNAKE_CASE	=				out_channels
      _SCREAMING_SNAKE_CASE	=				depthwise_padding
      _SCREAMING_SNAKE_CASE	=				strides
      _SCREAMING_SNAKE_CASE	=				num_block_repeats
      _SCREAMING_SNAKE_CASE	=				expand_ratios
      _SCREAMING_SNAKE_CASE	=				squeeze_expansion_ratio
      _SCREAMING_SNAKE_CASE	=				hidden_act
      _SCREAMING_SNAKE_CASE	=				hidden_dim
      _SCREAMING_SNAKE_CASE	=				pooling_type
      _SCREAMING_SNAKE_CASE	=				initializer_range
      _SCREAMING_SNAKE_CASE	=				batch_norm_eps
      _SCREAMING_SNAKE_CASE	=				batch_norm_momentum
      _SCREAMING_SNAKE_CASE	=				dropout_rate
      _SCREAMING_SNAKE_CASE	=				drop_connect_rate
      _SCREAMING_SNAKE_CASE	=				sum(__lowerCamelCase   ) * 4







class 		lowercase_   (			A       ):


   """simple docstring"""

   lowerCamelCase_      =						version.parse('''1.11'''       )



   @property
   def 							lowerCAmelCase_      (   self :     Optional[Any]   ):

      """simple docstring"""
      return OrderedDict(
          [
              ("pixel_values", {0: "batch", 1: "num_channels", 2: "height", 3: "width"}),
          ]   )



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

      """simple docstring"""
      return 1e-5

