

import numpy as np
import torch
from imwatermark import WatermarkEncoder


# Copied from https://github.com/Stability-AI/generative-models/blob/613af104c6b85184091d42d374fef420eddb356d/scripts/demo/streamlit_helpers.py#L66
_UpperCAmelCase	:     Dict		       = 0b10_11_00_11_11_10_11_00_10_01_00_00_01_11_10_11_10_11_00_01_10_01_11_10
# bin(x)[2:] gives bits of x as str, use int to convert them to 0/1
_UpperCAmelCase	:     Any		       = [int(bit) for bit in bin(WATERMARK_MESSAGE)[2:]]







class 				lowercase       :




    def __init__(      self ):
           snake_case_           =					WATERMARK_BITS
           snake_case_           =					WatermarkEncoder()

           self.encoder.set_watermark('bits'   ,     self.watermark )




    def 					a							(      self   ,     snake_case ):
           # can't encode images that are smaller than 256
           if images.shape[-1] < 256:
                  return images

           snake_case_           =					(255 * (images / 2 + 0.5)).cpu().permute(0   ,     2   ,     3   ,     1 ).float().numpy()

           snake_case_           =					[self.encoder.encode(snake_case   ,     'dwtDct' ) for image in images]

           snake_case_           =					torch.from_numpy(np.array(snake_case ) ).permute(0   ,     3   ,     1   ,     2 )

           snake_case_           =					torch.clamp(2 * (images / 255 - 0.5)   ,     min=-1.0   ,     max=1.0 )
           return images







# NOTE: This file is deprecated and will be removed in a future version.
# It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works

from ...utils import deprecate
from ..controlnet.pipeline_flax_controlnet import FlaxStableDiffusionControlNetPipeline  # noqa: F401


deprecate(
    """stable diffusion controlnet""",
    """0.22.0""",
    """Importing `FlaxStableDiffusionControlNetPipeline` from diffusers.pipelines.stable_diffusion.flax_pipeline_stable_diffusion_controlnet is deprecated. Please import `from diffusers import FlaxStableDiffusionControlNetPipeline` instead.""",
    standard_warn=False,
    stacklevel=3,
)




