
'''simple docstring'''







import unittest

import numpy as np

from diffusers import OnnxStableDiffusionInpaintPipelineLegacy
from diffusers.utils.testing_utils import (
    is_onnx_available,
    load_image,
    load_numpy,
    nightly,
    require_onnxruntime,
    require_torch_gpu,
)


if is_onnx_available():
							import onnxruntime as ort






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






					@property
					def 	_snake_case    (   self		):


											"""simple docstring"""





											return (
											    "CUDAExecutionProvider",
											    {
											        "gpu_mem_limit": "15000000000",  # 15GB
											        "arena_extend_strategy": "kSameAsRequested",
											    },
											)






					@property
					def 	_snake_case    (   self		):


											"""simple docstring"""





											lowercase_	:     Optional[int]													=       ort.SessionOptions()
											lowercase_	:     Any													=       False
											return options






					def 	_snake_case    (   self		):


											"""simple docstring"""





											lowercase_	:     List[Any]													=       load_image(
											    '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'''
											    '''/in_paint/overture-creations-5sI6fQgYIuo.png'''		)
											lowercase_	:     Union[str, Any]													=       load_image(
											    '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'''
											    '''/in_paint/overture-creations-5sI6fQgYIuo_mask.png'''		)
											lowercase_	:     Any													=       load_numpy(
											    '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'''
											    '''/in_paint/red_cat_sitting_on_a_park_bench_onnx.npy'''		)

											# using the PNDM scheduler by default
											lowercase_	:     Any													=       OnnxStableDiffusionInpaintPipelineLegacy.from_pretrained(
											    '''CompVis/stable-diffusion-v1-4'''				,							revision='''onnx'''				,							safety_checker=__SCREAMING_SNAKE_CASE				,							feature_extractor=__SCREAMING_SNAKE_CASE				,							provider=self.gpu_provider				,							sess_options=self.gpu_options				,							)
											pipe.set_progress_bar_config(disable=__SCREAMING_SNAKE_CASE		)

											lowercase_	:     List[Any]													=       '''A red cat sitting on a park bench'''

											lowercase_	:     Any													=       np.random.RandomState(0		)
											lowercase_	:     Dict													=       pipe(
											    prompt=__SCREAMING_SNAKE_CASE				,							image=__SCREAMING_SNAKE_CASE				,							mask_image=__SCREAMING_SNAKE_CASE				,							strength=0.75				,							guidance_scale=7.5				,							num_inference_steps=15				,							generator=__SCREAMING_SNAKE_CASE				,							output_type='''np'''				,							)

											lowercase_	:     str													=       output.images[0]

											assert image.shape == (5_12, 5_12, 3)
											assert np.abs(expected_image - image		).max() < 1E-2







'''simple docstring'''

a_  :				str						= """
# Transformers installation
! pip install transformers datasets
# To install from source instead of the last release, comment the command above and uncomment the following one.
# ! pip install git+https://github.com/huggingface/transformers.git
"""

a_  :				Any						= [{"""type""": """code""", """content""": INSTALL_CONTENT}]
a_  :				int						= {
    """{processor_class}""": """FakeProcessorClass""",
    """{model_class}""": """FakeModelClass""",
    """{object_class}""": """FakeObjectClass""",
}



