'''simple docstring'''




import math
import os

import cva
import numpy as np

_lowercase		:					Tuple													=		255.0




def 				lowerCamelCase      ( UpperCAmelCase__			:   float , UpperCAmelCase__			:   float					)     -> float:
							lowercase_   :     Any									=			np.mean((original - contrast) ** 2					)
							if mse == 0:
														return 100

							return 20 * math.logaa(PIXEL_MAX / math.sqrt(_UpperCamelCase					)					)




def 				lowerCamelCase      ( )     -> None:
							lowercase_   :     List[Any]									=			os.path.dirname(os.path.realpath(_UpperCamelCase					)					)
							# Loading images (original image and compressed image)
							lowercase_   :     str									=			cva.imread(os.path.join(_UpperCamelCase , """image_data/original_image.png"""					)					)
							lowercase_   :     int									=			cva.imread(os.path.join(_UpperCamelCase , """image_data/compressed_image.png"""					) , 1					)

							lowercase_   :     List[Any]									=			cva.imread(os.path.join(_UpperCamelCase , """image_data/PSNR-example-base.png"""					)					)
							lowercase_   :     Tuple									=			cva.imread(
							    os.path.join(_UpperCamelCase , """image_data/PSNR-example-comp-10.jpg"""					) , 1					)

							# Value expected: 29.73dB
							print("""-- First Test --"""					)
							print(F'''PSNR value is {peak_signal_to_noise_ratio(_UpperCamelCase , _UpperCamelCase					)} dB'''					)

							# # Value expected: 31.53dB (Wikipedia Example)
							print("""\n-- Second Test --"""					)
							print(F'''PSNR value is {peak_signal_to_noise_ratio(_UpperCamelCase , _UpperCamelCase					)} dB'''					)


if __name__ == "__main__":
						main()









'''simple docstring'''

from typing import TYPE_CHECKING

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


__lowercase:		Tuple    						=  {
    "configuration_imagegpt": ["IMAGEGPT_PRETRAINED_CONFIG_ARCHIVE_MAP", "ImageGPTConfig", "ImageGPTOnnxConfig"]
}

try:
       if not is_vision_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       __lowercase:		List[str]    						=  ["ImageGPTFeatureExtractor"]
       __lowercase:		Tuple    						=  ["ImageGPTImageProcessor"]

try:
       if not is_torch_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       __lowercase:		str    						=  [
           "IMAGEGPT_PRETRAINED_MODEL_ARCHIVE_LIST",
           "ImageGPTForCausalImageModeling",
           "ImageGPTForImageClassification",
           "ImageGPTModel",
           "ImageGPTPreTrainedModel",
           "load_tf_weights_in_imagegpt",
       ]


if TYPE_CHECKING:
       from .configuration_imagegpt import IMAGEGPT_PRETRAINED_CONFIG_ARCHIVE_MAP, ImageGPTConfig, ImageGPTOnnxConfig

       try:
              if not is_vision_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .feature_extraction_imagegpt import ImageGPTFeatureExtractor
              from .image_processing_imagegpt import ImageGPTImageProcessor

       try:
              if not is_torch_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_imagegpt import (
                  IMAGEGPT_PRETRAINED_MODEL_ARCHIVE_LIST,
                  ImageGPTForCausalImageModeling,
                  ImageGPTForImageClassification,
                  ImageGPTModel,
                  ImageGPTPreTrainedModel,
                  load_tf_weights_in_imagegpt,
              )

else:
       import sys

       __lowercase:		List[str]    						=  _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)