Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| import torch | |
| 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.float32) | |
| pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config) | |
| def diffusion(text,num_inference_steps,guidance_scale): | |
| prompt = text | |
| image = pipe(prompt,guidance_scale=guidance_scale, num_inference_steps=num_inference_steps).images[0] | |
| return image | |
| demo = gr.Interface( | |
| diffusion, | |
| [ | |
| gr.Textbox( | |
| label="prompt text", | |
| lines=3, | |
| ), | |
| gr.Slider(1, 100, value=50), | |
| gr.Slider(1.0, 30.0, value=7.5), | |
| ], | |
| "image", | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() | |
| image.save("astronaut_rides_horse.png") |