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_flux.py
More file actions
57 lines (45 loc) · 1.64 KB
/
Copy pathtest_flux.py
File metadata and controls
57 lines (45 loc) · 1.64 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import os
import traceback
from stable_diffusion_cpp import StableDiffusion
DIFFUSION_MODEL_PATH = "C:\\stable-diffusion\\flux\\flux1-schnell-q3_k.gguf"
# DIFFUSION_MODEL_PATH = "C:\\stable-diffusion\\flux\\flux1-dev-q8_0.gguf"
T5XXL_PATH = "C:\\stable-diffusion\\flux\\t5xxl_q8_0.gguf"
CLIP_L_PATH = "C:\\stable-diffusion\\flux\\clip_l-q8_0.gguf"
VAE_PATH = "C:\\stable-diffusion\\flux\\ae-f16.gguf"
LORA_DIR = "C:\\stable-diffusion\\loras"
stable_diffusion = StableDiffusion(
diffusion_model_path=DIFFUSION_MODEL_PATH,
clip_l_path=CLIP_L_PATH,
t5xxl_path=T5XXL_PATH,
vae_path=VAE_PATH,
lora_model_dir=LORA_DIR,
vae_decode_only=True,
)
def callback(step: int, steps: int, time: float):
print("Completed step: {} of {}".format(step, steps))
try:
prompts = [
# {
# "add": "_lora",
# "prompt": "a lovely cat holding a sign says 'flux.cpp' <lora:realism_lora_comfy_converted:1>",
# }, # With LORA
{"add": "", "prompt": "a lovely cat holding a sign says 'flux.cpp'"}, # Without LORA
]
OUTPUT_DIR = "tests/outputs"
if not os.path.exists(OUTPUT_DIR):
os.makedirs(OUTPUT_DIR)
for prompt in prompts:
# Generate images
images = stable_diffusion.txt_to_img(
prompt=prompt["prompt"],
sample_steps=4,
cfg_scale=1.0,
sample_method="euler",
progress_callback=callback,
)
# Save images
for i, image in enumerate(images):
image.save(f"{OUTPUT_DIR}/flux{prompt['add']}_{i}.png")
except Exception as e:
traceback.print_exc()
print("Test - flux failed: ", e)