Spaces:
No application file
No application file
Commit
·
e9994f8
1
Parent(s):
6eebe3e
Create Generation.py
Browse files- Generation.py +18 -0
Generation.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pip install --upgrade git+https://github.com/huggingface/diffusers.git transformers accelerate scipy
|
| 2 |
+
|
| 3 |
+
import torch
|
| 4 |
+
from diffusers import StableDiffusionPipeline, EulerDiscreteScheduler
|
| 5 |
+
torch.manual_seed(1000)
|
| 6 |
+
model_id = "stabilityai/stable-diffusion-2"
|
| 7 |
+
|
| 8 |
+
# Use the Euler scheduler here instead
|
| 9 |
+
scheduler = EulerDiscreteScheduler.from_pretrained(model_id, subfolder="scheduler")
|
| 10 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id, scheduler=scheduler, revision="fp16", torch_dtype=torch.float16)
|
| 11 |
+
pipe = pipe.to("cuda")
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
prompt = input()
|
| 15 |
+
image = pipe(prompt).images[0]
|
| 16 |
+
image.save("./image.png")
|
| 17 |
+
from IPython.display import Image
|
| 18 |
+
Image("./image.png")
|