Spaces:
Runtime error
Runtime error
first commit
Browse files
app.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
def diffusion(text,num_inference_steps,guidance_scale):
|
| 2 |
+
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler
|
| 3 |
+
|
| 4 |
+
model_id = "stabilityai/stable-diffusion-2-1"
|
| 5 |
+
|
| 6 |
+
# Use the DPMSolverMultistepScheduler (DPM-Solver++) scheduler here instead
|
| 7 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
| 8 |
+
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
|
| 9 |
+
pipe = pipe.to("cuda")
|
| 10 |
+
|
| 11 |
+
prompt = text
|
| 12 |
+
image = pipe(prompt,guidance_scale=guidance_scale, num_inference_steps=num_inference_steps).images[0]
|
| 13 |
+
return image
|
| 14 |
+
demo = gr.Interface(
|
| 15 |
+
diffusion,
|
| 16 |
+
[
|
| 17 |
+
"text"
|
| 18 |
+
gr.Slider(1, 100, value=50),
|
| 19 |
+
gr.Slider(1.0, 30.0, value=7.5)
|
| 20 |
+
],
|
| 21 |
+
"text",
|
| 22 |
+
|
| 23 |
+
)
|
| 24 |
+
if __name__ == "__main__":
|
| 25 |
+
demo.launch()
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
image.save("astronaut_rides_horse.png")
|