Commit
•
829c2a5
1
Parent(s):
41f09d3
Upload handler.py
Browse files- handler.py +66 -4
handler.py
CHANGED
@@ -6,23 +6,85 @@ from datetime import datetime
|
|
6 |
import argparse
|
7 |
from hyvideo.utils.file_utils import save_videos_grid
|
8 |
from hyvideo.inference import HunyuanVideoSampler
|
9 |
-
from hyvideo.config import parse_args
|
10 |
from hyvideo.constants import NEGATIVE_PROMPT
|
11 |
|
12 |
def get_default_args():
|
13 |
"""Create default arguments instead of parsing from command line"""
|
14 |
parser = argparse.ArgumentParser()
|
15 |
|
16 |
-
#
|
17 |
parser.add_argument("--model", type=str, default="HYVideo-T/2")
|
18 |
parser.add_argument("--model-resolution", type=str, default="720p", choices=["540p", "720p"])
|
19 |
parser.add_argument("--latent-channels", type=int, default=4)
|
20 |
parser.add_argument("--precision", type=str, default="bf16", choices=["bf16", "fp32", "fp16"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
parser.add_argument("--batch-size", type=int, default=1)
|
22 |
parser.add_argument("--infer-steps", type=int, default=50)
|
23 |
-
parser.add_argument("--
|
|
|
|
|
24 |
parser.add_argument("--save-path", type=str, default="outputs")
|
25 |
-
parser.add_argument("--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
# Parse with empty args list to avoid reading sys.argv
|
28 |
args = parser.parse_args([])
|
|
|
6 |
import argparse
|
7 |
from hyvideo.utils.file_utils import save_videos_grid
|
8 |
from hyvideo.inference import HunyuanVideoSampler
|
|
|
9 |
from hyvideo.constants import NEGATIVE_PROMPT
|
10 |
|
11 |
def get_default_args():
|
12 |
"""Create default arguments instead of parsing from command line"""
|
13 |
parser = argparse.ArgumentParser()
|
14 |
|
15 |
+
# Model configuration
|
16 |
parser.add_argument("--model", type=str, default="HYVideo-T/2")
|
17 |
parser.add_argument("--model-resolution", type=str, default="720p", choices=["540p", "720p"])
|
18 |
parser.add_argument("--latent-channels", type=int, default=4)
|
19 |
parser.add_argument("--precision", type=str, default="bf16", choices=["bf16", "fp32", "fp16"])
|
20 |
+
parser.add_argument("--rope-theta", type=float, default=10000)
|
21 |
+
|
22 |
+
# VAE settings
|
23 |
+
parser.add_argument("--vae", type=str, default="884-16c-hy")
|
24 |
+
parser.add_argument("--vae-precision", type=str, default="bf16", choices=["bf16", "fp32", "fp16"])
|
25 |
+
parser.add_argument("--vae-tiling", action="store_true")
|
26 |
+
|
27 |
+
# Text encoder settings
|
28 |
+
parser.add_argument("--text-encoder", type=str, default="clipL", choices=["clipL", "llm"])
|
29 |
+
parser.add_argument("--text-encoder-precision", type=str, default="bf16", choices=["bf16", "fp32", "fp16"])
|
30 |
+
parser.add_argument("--text-states-dim", type=int, default=1024)
|
31 |
+
parser.add_argument("--text-len", type=int, default=77)
|
32 |
+
parser.add_argument("--tokenizer", type=str, default="clipL", choices=["clipL", "llm"])
|
33 |
+
|
34 |
+
# Prompt template settings
|
35 |
+
parser.add_argument("--prompt-template", type=str, default="dit-llm-encode",
|
36 |
+
choices=["dit-llm-encode", "dit-llm-encode-video"])
|
37 |
+
parser.add_argument("--prompt-template-video", type=str, default="dit-llm-encode",
|
38 |
+
choices=["dit-llm-encode", "dit-llm-encode-video"])
|
39 |
+
|
40 |
+
# Additional text encoder settings
|
41 |
+
parser.add_argument("--hidden-state-skip-layer", type=int, default=0)
|
42 |
+
parser.add_argument("--apply-final-norm", action="store_true")
|
43 |
+
parser.add_argument("--text-encoder-2", type=str, default="clipL", choices=["clipL", "llm"])
|
44 |
+
parser.add_argument("--text-encoder-precision-2", type=str, default="bf16", choices=["bf16", "fp32", "fp16"])
|
45 |
+
parser.add_argument("--text-states-dim-2", type=int, default=1024)
|
46 |
+
parser.add_argument("--tokenizer-2", type=str, default="clipL", choices=["clipL", "llm"])
|
47 |
+
parser.add_argument("--text-len-2", type=int, default=77)
|
48 |
+
|
49 |
+
# Inference settings
|
50 |
+
parser.add_argument("--denoise-type", type=str, default="v-prediction")
|
51 |
+
parser.add_argument("--flow-shift", type=float, default=7.0)
|
52 |
+
parser.add_argument("--flow-reverse", action="store_true")
|
53 |
+
parser.add_argument("--flow-solver", type=str, default="euler")
|
54 |
+
parser.add_argument("--use-linear-quadratic-schedule", action="store_true")
|
55 |
+
parser.add_argument("--linear-schedule-end", type=float, default=0.0)
|
56 |
+
|
57 |
+
# Model paths and weights
|
58 |
+
parser.add_argument("--model-base", type=str, default=None)
|
59 |
+
parser.add_argument("--dit-weight", type=float, default=1.0)
|
60 |
+
parser.add_argument("--load-key", type=str, default=None)
|
61 |
+
|
62 |
+
# Hardware settings
|
63 |
+
parser.add_argument("--use-cpu-offload", action="store_true")
|
64 |
parser.add_argument("--batch-size", type=int, default=1)
|
65 |
parser.add_argument("--infer-steps", type=int, default=50)
|
66 |
+
parser.add_argument("--disable-autocast", action="store_true")
|
67 |
+
|
68 |
+
# Output settings
|
69 |
parser.add_argument("--save-path", type=str, default="outputs")
|
70 |
+
parser.add_argument("--save-path-suffix", type=str, default="")
|
71 |
+
parser.add_argument("--name-suffix", type=str, default="")
|
72 |
+
|
73 |
+
# Generation settings
|
74 |
+
parser.add_argument("--num-videos", type=int, default=1)
|
75 |
+
parser.add_argument("--video-size", nargs="+", type=int, default=None)
|
76 |
+
parser.add_argument("--video-length", type=int, default=129)
|
77 |
+
parser.add_argument("--prompt", type=str, default=None)
|
78 |
+
parser.add_argument("--seed-type", type=str, default="random", choices=["file", "random", "fixed", "auto"])
|
79 |
+
parser.add_argument("--seed", type=int, default=-1)
|
80 |
+
parser.add_argument("--neg-prompt", type=str, default="")
|
81 |
+
parser.add_argument("--cfg-scale", type=float, default=1.0)
|
82 |
+
parser.add_argument("--embedded-cfg-scale", type=float, default=6.0)
|
83 |
+
parser.add_argument("--reproduce", action="store_true")
|
84 |
+
|
85 |
+
# Additional degrees
|
86 |
+
parser.add_argument("--ulysses-degree", type=float, default=1.0)
|
87 |
+
parser.add_argument("--ring-degree", type=float, default=1.0)
|
88 |
|
89 |
# Parse with empty args list to avoid reading sys.argv
|
90 |
args = parser.parse_args([])
|