Spaces:
Runtime error
Runtime error
File size: 915 Bytes
2a5dfa3 9ba3f39 2a5dfa3 eb37db0 2a5dfa3 eb37db0 2a5dfa3 6318220 2a5dfa3 6318220 2a5dfa3 eb37db0 2801e74 eb37db0 2801e74 eb37db0 aa130e8 eb37db0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
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") |