forked from s9roll7/animatediff-cli-prompt-travel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
workflow_ama.py
executable file
·53 lines (42 loc) · 1.19 KB
/
workflow_ama.py
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
import glob
import logging
import os
import shutil
from pathlib import Path
from PIL import Image
from animatediff.ama import ama_init, ama_mask
from animatediff.consts import CONST_PROJECT_FILE, path_mgr
from animatediff.settings import get_project_setting
from animatediff.utils.tagger import get_labels
from animatediff.utils.util import extract_frames
logging.basicConfig(
level=logging.INFO,
)
def ama_info(project):
project_dir = path_mgr.projects / project
input_frames_dir = project_dir / CONST_PROJECT_FILE.input_frames
img = Image.open(input_frames_dir.joinpath("00000000.png"))
W, H = img.size
if W < H:
width = 512
height = int(512 * H / W)
else:
width = int(512 * W / H)
height = 512
length = len(glob.glob(os.path.join(input_frames_dir, "[0-9]*.png"), recursive=False))
return {
"length": length,
"width": width,
"height": height,
}
def main():
project = "999-video"
# step 01
# ama_init(project, path_mgr.repo / "temp" / "input.mp4")
# step 02
info = ama_info(project)
print(info)
ama_mask(project)
# ama_generate(project)
if __name__ == "__main__":
main()