

"""simple docstring"""






import math
import os

import cva
import numpy as np

lowerCamelCase__			:					str							  =					255.0
def  UpperCamelCase   (     _lowerCAmelCase       :  float,					_lowerCAmelCase       :  float	)			->     float:
	_UpperCAmelCase      :							Any       =   np.mean((original - contrast) ** 2	)
	if mse == 0:
		return 100

	return 20 * math.logaa(PIXEL_MAX / math.sqrt(_lowerCAmelCase	)	)
def  UpperCamelCase   (     )			->     None:
	_UpperCAmelCase      :							Tuple       =   os.path.dirname(os.path.realpath(_lowerCAmelCase	)	)
	# Loading images (original image and compressed image)
	_UpperCAmelCase      :							Tuple       =   cva.imread(os.path.join(_lowerCAmelCase,					"""image_data/original_image.png"""	)	)
	_UpperCAmelCase      :							List[str]       =   cva.imread(os.path.join(_lowerCAmelCase,					"""image_data/compressed_image.png"""	),					1	)

	_UpperCAmelCase      :							List[Any]       =   cva.imread(os.path.join(_lowerCAmelCase,					"""image_data/PSNR-example-base.png"""	)	)
	_UpperCAmelCase      :							str       =   cva.imread(
	    os.path.join(_lowerCAmelCase,					"""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(_lowerCAmelCase,					_lowerCAmelCase	)} dB'''	)

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


if __name__ == "__main__":
							main()








"""simple docstring"""






from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_torch_available,
)


lowerCamelCase__			:					Union[str, Any]							  =					{
    '''configuration_unispeech_sat''': ['''UNISPEECH_SAT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''UniSpeechSatConfig'''],
}

try:
						if not is_torch_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						lowerCamelCase__			:					List[str]							  =					[
						    '''UNISPEECH_SAT_PRETRAINED_MODEL_ARCHIVE_LIST''',
						    '''UniSpeechSatForAudioFrameClassification''',
						    '''UniSpeechSatForCTC''',
						    '''UniSpeechSatForPreTraining''',
						    '''UniSpeechSatForSequenceClassification''',
						    '''UniSpeechSatForXVector''',
						    '''UniSpeechSatModel''',
						    '''UniSpeechSatPreTrainedModel''',
						]

if TYPE_CHECKING:
						from .configuration_unispeech_sat import UNISPEECH_SAT_PRETRAINED_CONFIG_ARCHIVE_MAP, UniSpeechSatConfig

						try:
												if not is_torch_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_unispeech_sat import (
												    UNISPEECH_SAT_PRETRAINED_MODEL_ARCHIVE_LIST,
												    UniSpeechSatForAudioFrameClassification,
												    UniSpeechSatForCTC,
												    UniSpeechSatForPreTraining,
												    UniSpeechSatForSequenceClassification,
												    UniSpeechSatForXVector,
												    UniSpeechSatModel,
												    UniSpeechSatPreTrainedModel,
												)

else:
						import sys

						lowerCamelCase__			:					Any							  =					_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)





