




import math
import os

import cva
import numpy as np

a_ 		=  255.0




def        __SCREAMING_SNAKE_CASE (	lowercase_       ,  lowercase_   )							->						float:

    """simple docstring"""


    __UpperCamelCase			=    np.mean((original - contrast) ** 2   )
    if mse == 0:
        return 1_00

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




def        __SCREAMING_SNAKE_CASE (	)							->						None:

    """simple docstring"""


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

    __UpperCamelCase			=    cva.imread(os.path.join(lowercase_       ,  '''image_data/PSNR-example-base.png'''   )   )
    __UpperCamelCase			=    cva.imread(
        os.path.join(lowercase_       ,  '''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(lowercase_       ,  lowercase_   )} dB"   )

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


if __name__ == "__main__":
 main()














from ...utils import (
    OptionalDependencyNotAvailable,
    is_torch_available,
    is_transformers_available,
    is_transformers_version,
)


try:
		if not (is_transformers_available() and is_torch_available() and is_transformers_version('''>=''', '''4.27.0''')):
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		from ...utils.dummy_torch_and_transformers_objects import (
		    AudioLDMPipeline,
		)
else:
		from .pipeline_audioldm import AudioLDMPipeline

