def diffusion(text,num_inference_steps,guidance_scale): from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler model_id = "stabilityai/stable-diffusion-2-1" # Use the DPMSolverMultistepScheduler (DPM-Solver++) scheduler here instead pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16) pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config) pipe = pipe.to("cuda") prompt = text image = pipe(prompt,guidance_scale=guidance_scale, num_inference_steps=num_inference_steps).images[0] return image demo = gr.Interface( diffusion, [ "text" gr.Slider(1, 100, value=50), gr.Slider(1.0, 30.0, value=7.5) ], "text", ) if __name__ == "__main__": demo.launch() image.save("astronaut_rides_horse.png")