


import torch

from diffusers import DiffusionPipeline


class 		_SCREAMING_SNAKE_CASE     (						A     ):


     def __init__(  self							,					A_							,					A_    ):
       super().__init__()

       self.register_modules(unet=A_							,					scheduler=A_    )




     def __call__(  self    ):
       _UpperCAmelCase		:							Tuple							=     torch.randn(
           (1, self.unet.config.in_channels, self.unet.config.sample_size, self.unet.config.sample_size)							,					)
       _UpperCAmelCase		:							Dict							=     1

       _UpperCAmelCase		:							Dict							=     self.unet(A_							,					A_    ).sample
       _UpperCAmelCase		:							int							=     self.scheduler.step(A_							,					A_							,					A_    ).prev_sample

       _UpperCAmelCase		:							List[Any]							=     scheduler_output - scheduler_output + torch.ones_like(A_    )

       return result









from PIL import Image




def    a__    (		snake_case__					:							Image						,   snake_case__					:							int     ):
  _UpperCAmelCase		:							Optional[Any]							=     (259 * (level + 255)) / (255 * (259 - level))

  def contrast(snake_case__					:							int     ) -> int:
    return int(128 + factor * (c - 128)     )

  return img.point(snake_case__     )


if __name__ == "__main__":
 # Load image
 with Image.open('image_data/lena.jpg') as img:
  # Change contrast to 170
  SCREAMING_SNAKE_CASE__					:     int       =     change_contrast(img, 170)
  cont_img.save('image_data/lena_high_contrast.png', format='png')





