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_img2vid.py
More file actions
31 lines (19 loc) · 846 Bytes
/
Copy pathtest_img2vid.py
File metadata and controls
31 lines (19 loc) · 846 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
import os
import traceback
from stable_diffusion_cpp import StableDiffusion
MODEL_PATH = "C:\\stable-diffusion\\svd_xt.safetensors"
input_image = "assets\\input.png"
stable_diffusion = StableDiffusion(model_path=MODEL_PATH)
def callback(step: int, steps: int, time: float):
print("Completed step: {} of {}".format(step, steps))
try:
images = stable_diffusion.img_to_vid(image=input_image, progress_callback=callback)
OUTPUT_DIR = "tests/outputs"
if not os.path.exists(OUTPUT_DIR):
os.makedirs(OUTPUT_DIR)
for i, image in enumerate(images):
image.save(f"{OUTPUT_DIR}/img2vid_{i}.png")
except Exception as e:
traceback.print_exc()
print("Test - img2vid failed: ", e)
# !!!!!!!!!!!!!!!!!! NOT WORKING (waiting for support in https://github.com/leejet/stable-diffusion.cpp ) !!!!!!!!!!!!!!!!!!