


# 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,
)



import unittest

import numpy as np

from diffusers import LMSDiscreteScheduler, OnnxStableDiffusionInpaintPipeline
from diffusers.utils.testing_utils import (
    is_onnx_available,
    load_image,
    nightly,
    require_onnxruntime,
    require_torch_gpu,
)

from ..test_pipelines_onnx_common import OnnxPipelineTesterMixin


if is_onnx_available():
   import onnxruntime as ort







class lowerCAmelCase_		(				lowerCamelCase__      ,		unittest.TestCase ):

 '''simple docstring'''

 pass







@nightly
@require_onnxruntime
@require_torch_gpu
class lowerCAmelCase_		(				unittest.TestCase ):

 '''simple docstring'''

 @property
 def 		UpperCamelCase__  (			self      ):
       return (
           "CUDAExecutionProvider",
           {
               "gpu_mem_limit": "15000000000",  # 15GB
               "arena_extend_strategy": "kSameAsRequested",
           },
       )



 @property
 def 		UpperCamelCase__  (			self      ):
       snake_case_ =   ort.SessionOptions()
       snake_case_ =   False
       return options



 def 		UpperCamelCase__  (			self      ):
       snake_case_ =   load_image(
           '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'''
           '''/in_paint/overture-creations-5sI6fQgYIuo.png'''      )
       snake_case_ =   load_image(
           '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'''
           '''/in_paint/overture-creations-5sI6fQgYIuo_mask.png'''      )
       snake_case_ =   OnnxStableDiffusionInpaintPipeline.from_pretrained(
           '''runwayml/stable-diffusion-inpainting'''	,   revision='''onnx'''	,   safety_checker=_UpperCAmelCase	,   feature_extractor=_UpperCAmelCase	,   provider=self.gpu_provider	,   sess_options=self.gpu_options	,   )
       pipe.set_progress_bar_config(disable=_UpperCAmelCase      )

       snake_case_ =   '''A red cat sitting on a park bench'''

       snake_case_ =   np.random.RandomState(0      )
       snake_case_ =   pipe(
           prompt=_UpperCAmelCase	,   image=_UpperCAmelCase	,   mask_image=_UpperCAmelCase	,   guidance_scale=7.5	,   num_inference_steps=10	,   generator=_UpperCAmelCase	,   output_type='''np'''	,   )
       snake_case_ =   output.images
       snake_case_ =   images[0, 2_55:2_58, 2_55:2_58, -1]

       assert images.shape == (1, 5_12, 5_12, 3)
       snake_case_ =   np.array([0.2_514, 0.3_007, 0.3_517, 0.1_790, 0.2_382, 0.3_167, 0.1_944, 0.2_273, 0.2_464]      )

       assert np.abs(image_slice.flatten() - expected_slice      ).max() < 1E-3





 def 		UpperCamelCase__  (			self      ):
       snake_case_ =   load_image(
           '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'''
           '''/in_paint/overture-creations-5sI6fQgYIuo.png'''      )
       snake_case_ =   load_image(
           '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'''
           '''/in_paint/overture-creations-5sI6fQgYIuo_mask.png'''      )
       snake_case_ =   LMSDiscreteScheduler.from_pretrained(
           '''runwayml/stable-diffusion-inpainting'''	,   subfolder='''scheduler'''	,   revision='''onnx'''      )
       snake_case_ =   OnnxStableDiffusionInpaintPipeline.from_pretrained(
           '''runwayml/stable-diffusion-inpainting'''	,   revision='''onnx'''	,   scheduler=_UpperCAmelCase	,   safety_checker=_UpperCAmelCase	,   feature_extractor=_UpperCAmelCase	,   provider=self.gpu_provider	,   sess_options=self.gpu_options	,   )
       pipe.set_progress_bar_config(disable=_UpperCAmelCase      )

       snake_case_ =   '''A red cat sitting on a park bench'''

       snake_case_ =   np.random.RandomState(0      )
       snake_case_ =   pipe(
           prompt=_UpperCAmelCase	,   image=_UpperCAmelCase	,   mask_image=_UpperCAmelCase	,   guidance_scale=7.5	,   num_inference_steps=20	,   generator=_UpperCAmelCase	,   output_type='''np'''	,   )
       snake_case_ =   output.images
       snake_case_ =   images[0, 2_55:2_58, 2_55:2_58, -1]

       assert images.shape == (1, 5_12, 5_12, 3)
       snake_case_ =   np.array([0.0_086, 0.0_077, 0.0_083, 0.0_093, 0.0_107, 0.0_139, 0.0_094, 0.0_097, 0.0_125]      )

       assert np.abs(image_slice.flatten() - expected_slice      ).max() < 1E-3