



"""simple docstring"""






from dataclasses import dataclass
from typing import Callable, Optional

import datasets

@dataclass
class 			__SCREAMING_SNAKE_CASE      ( datasets.BuilderConfig  ):


					'''simple docstring'''





					_a       =				None
					_a       =				None
					_a       =				None



					def 						snake_case			(			self				:    Union[str, Any]	)->   Any:
								assert self.generator is not None, "generator must be specified"

								if self.gen_kwargs is None:
											lowerCamelCase__						:						int						      ={}





class 			__SCREAMING_SNAKE_CASE      ( datasets.GeneratorBasedBuilder  ):


					'''simple docstring'''





					_a       =				GeneratorConfig



					def 						snake_case			(			self				:    int	)->   int:
								return datasets.DatasetInfo(features=self.config.features	)



					def 						snake_case			(			self				:    List[Any],    lowerCamelCase				:    List[str]	)->   Union[str, Any]:
								return [datasets.SplitGenerator(name=datasets.Split.TRAIN,    gen_kwargs=self.config.gen_kwargs	)]




					def 						snake_case			(			self				:    Optional[int],    **lowerCamelCase				:    Dict	)->   Optional[Any]:
								for idx, ex in enumerate(self.config.generator(**lowerCamelCase	)	):
											yield idx, ex










"""simple docstring"""





import math
import os

import cva
import numpy as np

_lowercase						   =     2_55.0

def 		lowerCAmelCase				(			lowerCamelCase   ,      lowerCamelCase		):
						'''simple docstring'''


						snake_case__							:       Tuple				      =       np.mean((original - contrast) ** 2		)
						if mse == 0:
												return 100

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

def 		lowerCAmelCase				(			):
						'''simple docstring'''


						snake_case__							:       Any				      =       os.path.dirname(os.path.realpath(lowerCamelCase		)		)
						# Loading images (original image and compressed image)
						snake_case__							:       Any				      =       cva.imread(os.path.join(lowerCamelCase   ,      '''image_data/original_image.png'''		)		)
						snake_case__							:       Any				      =       cva.imread(os.path.join(lowerCamelCase   ,      '''image_data/compressed_image.png'''		)   ,      1		)

						snake_case__							:       Optional[Any]				      =       cva.imread(os.path.join(lowerCamelCase   ,      '''image_data/PSNR-example-base.png'''		)		)
						snake_case__							:       Tuple				      =       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()


