





from typing import TYPE_CHECKING

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


SCREAMING_SNAKE_CASE__       :			Dict			      =						{
    """configuration_mobilenet_v2""": [
        """MOBILENET_V2_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """MobileNetV2Config""",
        """MobileNetV2OnnxConfig""",
    ],
}

try:
  if not is_vision_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  SCREAMING_SNAKE_CASE__       :			Tuple			      =						["""MobileNetV2FeatureExtractor"""]
  SCREAMING_SNAKE_CASE__       :			Optional[int]			      =						["""MobileNetV2ImageProcessor"""]


try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  SCREAMING_SNAKE_CASE__       :			str			      =						[
      """MOBILENET_V2_PRETRAINED_MODEL_ARCHIVE_LIST""",
      """MobileNetV2ForImageClassification""",
      """MobileNetV2ForSemanticSegmentation""",
      """MobileNetV2Model""",
      """MobileNetV2PreTrainedModel""",
      """load_tf_weights_in_mobilenet_v2""",
  ]


if TYPE_CHECKING:
  from .configuration_mobilenet_va import (
      MOBILENET_V2_PRETRAINED_CONFIG_ARCHIVE_MAP,
      MobileNetVaConfig,
      MobileNetVaOnnxConfig,
  )

  try:
    if not is_vision_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .feature_extraction_mobilenet_va import MobileNetVaFeatureExtractor
    from .image_processing_mobilenet_va import MobileNetVaImageProcessor

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_mobilenet_va import (
        MOBILENET_V2_PRETRAINED_MODEL_ARCHIVE_LIST,
        MobileNetVaForImageClassification,
        MobileNetVaForSemanticSegmentation,
        MobileNetVaModel,
        MobileNetVaPreTrainedModel,
        load_tf_weights_in_mobilenet_va,
    )


else:
  import sys

  SCREAMING_SNAKE_CASE__       :			Union[str, Any]			      =						_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)








import PIL.Image
import PIL.ImageOps
from packaging import version
from PIL import Image


if version.parse(version.parse(PIL.__version__).base_version) >= version.parse("""9.1.0"""):
  SCREAMING_SNAKE_CASE__       :			int			      =						{
      """linear""": PIL.Image.Resampling.BILINEAR,
      """bilinear""": PIL.Image.Resampling.BILINEAR,
      """bicubic""": PIL.Image.Resampling.BICUBIC,
      """lanczos""": PIL.Image.Resampling.LANCZOS,
      """nearest""": PIL.Image.Resampling.NEAREST,
  }
else:
  SCREAMING_SNAKE_CASE__       :			Dict			      =						{
      """linear""": PIL.Image.LINEAR,
      """bilinear""": PIL.Image.BILINEAR,
      """bicubic""": PIL.Image.BICUBIC,
      """lanczos""": PIL.Image.LANCZOS,
      """nearest""": PIL.Image.NEAREST,
  }






def       _A  (      lowerCamelCase   ):
   a__	:						Optional[int]      		=  (images / 2 + 0.5).clamp(0							, 1   )
   a__	:						List[Any]      		=  images.cpu().permute(0							, 2							, 3							, 1   ).float().numpy()
   a__	:						int      		=  numpy_to_pil(lowerCamelCase   )
   return images






def       _A  (      lowerCamelCase   ):
   if images.ndim == 3:
      a__	:						Tuple      		=  images[None, ...]
   a__	:						Dict      		=  (images * 255).round().astype("uint8"   )
   if images.shape[-1] == 1:
      # special case for grayscale (single channel) images
      a__	:						str      		=  [Image.fromarray(image.squeeze()							, mode="L"   ) for image in images]
   else:
      a__	:						List[Any]      		=  [Image.fromarray(lowerCamelCase   ) for image in images]

   return pil_images

