import gradio as gr from diffusers import StableDiffusionInpaintPipeline import torch pipeline = StableDiffusionInpaintPipeline.from_pretrained( "runwayml/stable-diffusion-inpainting", torch_dtype=torch.float16, ) #pipeline = pipeline.to("cuda") def predict(mask_img): prompt = "a green frog, highly detailed, natural lighting" image = pipeline(prompt=prompt, num_inference_steps=35, image=mask_img["image"], mask_image=mask_img["mask"], guidance_scale=9).images[0] return image demo = gr.Interface( fn=predict, inputs=gr.Image(), outputs=gr.Image(), title="Stable Diffusion Inpainting" ) demo.launch()