Create main.py
Browse files
main.py
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler
|
2 |
+
import torch
|
3 |
+
|
4 |
+
repo_id = "stabilityai/stable-diffusion-2-base"
|
5 |
+
pipe = DiffusionPipeline.from_pretrained(repo_id, torch_dtype=torch.float16, revision="fp16")
|
6 |
+
|
7 |
+
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
|
8 |
+
pipe = pipe.to("cuda")
|
9 |
+
|
10 |
+
prompt = "High quality photo of an astronaut riding a horse in space"
|
11 |
+
image = pipe(prompt, num_inference_steps=25).images[0]
|
12 |
+
image.save("astronaut.png")
|