forked from william-murray1204/stable-diffusion-cpp-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_sd3.py
More file actions
43 lines (33 loc) · 1.12 KB
/
Copy pathtest_sd3.py
File metadata and controls
43 lines (33 loc) · 1.12 KB
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
33
34
35
36
37
38
39
40
41
42
43
import os
import traceback
from stable_diffusion_cpp import StableDiffusion
MODEL_PATH = "C:\\stable-diffusion\\sd3.5\\sd3.5_large-q4_k_5_0.gguf"
CLIP_L_PATH = "C:\\stable-diffusion\\sd3.5\\clip_l.safetensors"
CLIP_G_PATH = "C:\\stable-diffusion\\sd3.5\\clip_g.safetensors"
T5XXL_PATH = "C:\\stable-diffusion\\sd3.5\\t5xxl_fp16.safetensors"
stable_diffusion = StableDiffusion(
model_path=MODEL_PATH,
clip_l_path=CLIP_L_PATH,
clip_g_path=CLIP_G_PATH,
t5xxl_path=T5XXL_PATH,
)
def callback(step: int, steps: int, time: float):
print("Completed step: {} of {}".format(step, steps))
try:
# Generate images
images = stable_diffusion.txt_to_img(
prompt="a lovely cat holding a sign says 'Stable diffusion 3.5 Large'",
height=832,
width=832,
cfg_scale=4.5,
sample_method="euler",
)
OUTPUT_DIR = "tests/outputs"
if not os.path.exists(OUTPUT_DIR):
os.makedirs(OUTPUT_DIR)
# Save images
for i, image in enumerate(images):
image.save(f"{OUTPUT_DIR}/sd3_{i}.png")
except Exception as e:
traceback.print_exc()
print("Test - sd3 failed: ", e)