
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
lowerCamelCase  =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
lowerCamelCase  =[int(bit) for bit in bin(WATERMARK_MESSAGE)[2:]]




class 					_lowerCamelCase			:





     """simple docstring"""







     def __init__(				self	)	-> List[Any]:




           """simple docstring"""







           UpperCamelCase__     : List[str]											=					WATERMARK_BITS
           UpperCamelCase__     : Union[str, Any]											=					WatermarkEncoder()

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






     def  __SCREAMING_SNAKE_CASE      (				self    ,    __SCREAMING_SNAKE_CASE	)	-> Optional[Any]:




           """simple docstring"""







           if images.shape[-1] < 2_5_6:
                 return images

           UpperCamelCase__     : Optional[Any]											=					(2_5_5 * (images / 2 + 0.5)).cpu().permute(0    ,    2    ,    3    ,    1	).float().numpy()

           UpperCamelCase__     : List[str]											=					[self.encoder.encode(__SCREAMING_SNAKE_CASE    ,    '''dwtDct'''	) for image in images]

           UpperCamelCase__     : int											=					torch.from_numpy(np.array(__SCREAMING_SNAKE_CASE	)	).permute(0    ,    3    ,    1    ,    2	)

           UpperCamelCase__     : Tuple											=					torch.clamp(2 * (images / 2_5_5 - 0.5)    ,    min=-1.0    ,    max=1.0	)
           return images




# limitations under the License.

# 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 .pipelines import DiffusionPipeline, ImagePipelineOutput  # noqa: F401
from .utils import deprecate


deprecate(
    "pipelines_utils",
    "0.22.0",
    "Importing `DiffusionPipeline` or `ImagePipelineOutput` from diffusers.pipeline_utils is deprecated. Please import from diffusers.pipelines.pipeline_utils instead.",
    standard_warn=False,
    stacklevel=3,
)


