Upload demo.py with huggingface_hub
Browse files
demo.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
|
3 |
+
from diffusers import DiffusionPipeline
|
4 |
+
import torch.nn as nn, torch, types
|
5 |
+
|
6 |
+
MODEL_DIR = "opendiffusionai/stablediffusionxl_t5"
|
7 |
+
|
8 |
+
|
9 |
+
pipe = DiffusionPipeline.from_pretrained(
|
10 |
+
MODEL_DIR, custom_pipeline=MODEL_DIR, use_safetensors=True,
|
11 |
+
torch_dtype=torch.bfloat16,
|
12 |
+
)
|
13 |
+
|
14 |
+
print("model initialized. Now moving to CUDA")
|
15 |
+
pipe.to("cuda")
|
16 |
+
|
17 |
+
print("Trying render now...")
|
18 |
+
|
19 |
+
images = pipe("a misty Tokyo alley at night",num_inference_steps=30).images
|
20 |
+
images[0].save("test.png")
|
21 |
+
|