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_vulkan.py
More file actions
37 lines (27 loc) · 944 Bytes
/
test_vulkan.py
File metadata and controls
37 lines (27 loc) · 944 Bytes
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
import os
import traceback
from stable_diffusion_cpp import StableDiffusion
MODEL_PATH = "C:\\stable-diffusion\\v1-5-pruned-emaonly.safetensors"
stable_diffusion = StableDiffusion(model_path=MODEL_PATH, wtype="f16", vae_tiling=True)
def callback(step: int, steps: int, time: float):
print("Completed step: {} of {}".format(step, steps))
try:
OUTPUT_DIR = "tests/outputs"
if not os.path.exists(OUTPUT_DIR):
os.makedirs(OUTPUT_DIR)
# Generate images
images = stable_diffusion.txt_to_img(
prompt="a fantasy character, detailed background, colorful",
sample_steps=20,
seed=42,
width=512,
height=512,
sample_method="euler",
progress_callback=callback,
)
# Save images
for i, image in enumerate(images):
image.save(f"{OUTPUT_DIR}/vulkan_{i}.png")
except Exception as e:
traceback.print_exc()
print("Test - txt2img failed: ", e)