吴吴大庸
commited on
Commit
·
0a7f9b3
1
Parent(s):
eae9c33
initial upload
Browse files- app.py +597 -0
- configs/dit/inference/16x256x256.py +31 -0
- configs/dit/inference/1x256x256-class.py +31 -0
- configs/dit/inference/1x256x256.py +32 -0
- configs/dit/train/16x256x256.py +50 -0
- configs/dit/train/1x256x256.py +51 -0
- configs/latte/inference/16x256x256-class.py +30 -0
- configs/latte/inference/16x256x256.py +31 -0
- configs/latte/train/16x256x256.py +49 -0
- configs/opensora-v1-1/inference/sample-ref.py +70 -0
- configs/opensora-v1-1/inference/sample.py +43 -0
- configs/opensora-v1-1/train/benchmark.py +101 -0
- configs/opensora-v1-1/train/image.py +65 -0
- configs/opensora-v1-1/train/stage1.py +77 -0
- configs/opensora-v1-1/train/stage2.py +79 -0
- configs/opensora-v1-1/train/stage3.py +79 -0
- configs/opensora-v1-1/train/video.py +67 -0
- configs/opensora/inference/16x256x256.py +39 -0
- configs/opensora/inference/16x512x512.py +35 -0
- configs/opensora/inference/64x512x512.py +35 -0
- configs/opensora/train/16x256x256-mask.py +60 -0
- configs/opensora/train/16x256x256-spee.py +60 -0
- configs/opensora/train/16x256x256.py +53 -0
- configs/opensora/train/16x512x512.py +54 -0
- configs/opensora/train/360x512x512.py +61 -0
- configs/opensora/train/64x512x512-sp.py +54 -0
- configs/opensora/train/64x512x512.py +54 -0
- configs/pixart/inference/16x256x256.py +32 -0
- configs/pixart/inference/1x1024MS.py +34 -0
- configs/pixart/inference/1x256x256.py +33 -0
- configs/pixart/inference/1x512x512.py +39 -0
- configs/pixart/train/16x256x256.py +53 -0
- configs/pixart/train/1x512x512.py +54 -0
- configs/pixart/train/64x512x512.py +55 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1,597 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
"""
|
3 |
+
This script runs a Gradio App for the Open-Sora model.
|
4 |
+
|
5 |
+
Usage:
|
6 |
+
python demo.py <config-path>
|
7 |
+
"""
|
8 |
+
|
9 |
+
import argparse
|
10 |
+
import importlib
|
11 |
+
import os
|
12 |
+
import subprocess
|
13 |
+
import sys
|
14 |
+
import re
|
15 |
+
import json
|
16 |
+
import math
|
17 |
+
|
18 |
+
import spaces
|
19 |
+
import torch
|
20 |
+
|
21 |
+
import gradio as gr
|
22 |
+
from tempfile import NamedTemporaryFile
|
23 |
+
import datetime
|
24 |
+
|
25 |
+
|
26 |
+
|
27 |
+
MODEL_TYPES = ["v1.1-stage2", "v1.1-stage3"]
|
28 |
+
CONFIG_MAP = {
|
29 |
+
"v1.1-stage2": "configs/opensora-v1-1/inference/sample-ref.py",
|
30 |
+
"v1.1-stage3": "configs/opensora-v1-1/inference/sample-ref.py",
|
31 |
+
}
|
32 |
+
HF_STDIT_MAP = {
|
33 |
+
"v1.1-stage2": "hpcai-tech/OpenSora-STDiT-v2-stage2",
|
34 |
+
"v1.1-stage3": "hpcai-tech/OpenSora-STDiT-v2-stage3",
|
35 |
+
}
|
36 |
+
RESOLUTION_MAP = {
|
37 |
+
"144p": {
|
38 |
+
"16:9": (256, 144),
|
39 |
+
"9:16": (144, 256),
|
40 |
+
"4:3": (221, 165),
|
41 |
+
"3:4": (165, 221),
|
42 |
+
"1:1": (192, 192),
|
43 |
+
},
|
44 |
+
"240p": {
|
45 |
+
"16:9": (426, 240),
|
46 |
+
"9:16": (240, 426),
|
47 |
+
"4:3": (370, 278),
|
48 |
+
"3:4": (278, 370),
|
49 |
+
"1:1": (320, 320),
|
50 |
+
},
|
51 |
+
"360p": {
|
52 |
+
"16:9": (640, 360),
|
53 |
+
"9:16": (360, 640),
|
54 |
+
"4:3": (554, 416),
|
55 |
+
"3:4": (416, 554),
|
56 |
+
"1:1": (480, 480),
|
57 |
+
},
|
58 |
+
"480p": {
|
59 |
+
"16:9": (854, 480),
|
60 |
+
"9:16": (480, 854),
|
61 |
+
"4:3": (740, 555),
|
62 |
+
"3:4": (555, 740),
|
63 |
+
"1:1": (640, 640),
|
64 |
+
},
|
65 |
+
"720p": {
|
66 |
+
"16:9": (1280, 720),
|
67 |
+
"9:16": (720, 1280),
|
68 |
+
"4:3": (1108, 832),
|
69 |
+
"3:4": (832, 1110),
|
70 |
+
"1:1": (960, 960),
|
71 |
+
},
|
72 |
+
}
|
73 |
+
|
74 |
+
|
75 |
+
# ============================
|
76 |
+
# Utils
|
77 |
+
# ============================
|
78 |
+
def collect_references_batch(reference_paths, vae, image_size):
|
79 |
+
from opensora.datasets.utils import read_from_path
|
80 |
+
|
81 |
+
refs_x = []
|
82 |
+
for reference_path in reference_paths:
|
83 |
+
if reference_path is None:
|
84 |
+
refs_x.append([])
|
85 |
+
continue
|
86 |
+
ref_path = reference_path.split(";")
|
87 |
+
ref = []
|
88 |
+
for r_path in ref_path:
|
89 |
+
r = read_from_path(r_path, image_size, transform_name="resize_crop")
|
90 |
+
r_x = vae.encode(r.unsqueeze(0).to(vae.device, vae.dtype))
|
91 |
+
r_x = r_x.squeeze(0)
|
92 |
+
ref.append(r_x)
|
93 |
+
refs_x.append(ref)
|
94 |
+
# refs_x: [batch, ref_num, C, T, H, W]
|
95 |
+
return refs_x
|
96 |
+
|
97 |
+
|
98 |
+
def process_mask_strategy(mask_strategy):
|
99 |
+
mask_batch = []
|
100 |
+
mask_strategy = mask_strategy.split(";")
|
101 |
+
for mask in mask_strategy:
|
102 |
+
mask_group = mask.split(",")
|
103 |
+
assert len(mask_group) >= 1 and len(mask_group) <= 6, f"Invalid mask strategy: {mask}"
|
104 |
+
if len(mask_group) == 1:
|
105 |
+
mask_group.extend(["0", "0", "0", "1", "0"])
|
106 |
+
elif len(mask_group) == 2:
|
107 |
+
mask_group.extend(["0", "0", "1", "0"])
|
108 |
+
elif len(mask_group) == 3:
|
109 |
+
mask_group.extend(["0", "1", "0"])
|
110 |
+
elif len(mask_group) == 4:
|
111 |
+
mask_group.extend(["1", "0"])
|
112 |
+
elif len(mask_group) == 5:
|
113 |
+
mask_group.append("0")
|
114 |
+
mask_batch.append(mask_group)
|
115 |
+
return mask_batch
|
116 |
+
|
117 |
+
|
118 |
+
def apply_mask_strategy(z, refs_x, mask_strategys, loop_i):
|
119 |
+
masks = []
|
120 |
+
for i, mask_strategy in enumerate(mask_strategys):
|
121 |
+
mask = torch.ones(z.shape[2], dtype=torch.float, device=z.device)
|
122 |
+
if mask_strategy is None:
|
123 |
+
masks.append(mask)
|
124 |
+
continue
|
125 |
+
mask_strategy = process_mask_strategy(mask_strategy)
|
126 |
+
for mst in mask_strategy:
|
127 |
+
loop_id, m_id, m_ref_start, m_target_start, m_length, edit_ratio = mst
|
128 |
+
loop_id = int(loop_id)
|
129 |
+
if loop_id != loop_i:
|
130 |
+
continue
|
131 |
+
m_id = int(m_id)
|
132 |
+
m_ref_start = int(m_ref_start)
|
133 |
+
m_length = int(m_length)
|
134 |
+
m_target_start = int(m_target_start)
|
135 |
+
edit_ratio = float(edit_ratio)
|
136 |
+
ref = refs_x[i][m_id] # [C, T, H, W]
|
137 |
+
if m_ref_start < 0:
|
138 |
+
m_ref_start = ref.shape[1] + m_ref_start
|
139 |
+
if m_target_start < 0:
|
140 |
+
# z: [B, C, T, H, W]
|
141 |
+
m_target_start = z.shape[2] + m_target_start
|
142 |
+
z[i, :, m_target_start : m_target_start + m_length] = ref[:, m_ref_start : m_ref_start + m_length]
|
143 |
+
mask[m_target_start : m_target_start + m_length] = edit_ratio
|
144 |
+
masks.append(mask)
|
145 |
+
masks = torch.stack(masks)
|
146 |
+
return masks
|
147 |
+
|
148 |
+
|
149 |
+
def process_prompts(prompts, num_loop):
|
150 |
+
from opensora.models.text_encoder.t5 import text_preprocessing
|
151 |
+
|
152 |
+
ret_prompts = []
|
153 |
+
for prompt in prompts:
|
154 |
+
if prompt.startswith("|0|"):
|
155 |
+
prompt_list = prompt.split("|")[1:]
|
156 |
+
text_list = []
|
157 |
+
for i in range(0, len(prompt_list), 2):
|
158 |
+
start_loop = int(prompt_list[i])
|
159 |
+
text = prompt_list[i + 1]
|
160 |
+
text = text_preprocessing(text)
|
161 |
+
end_loop = int(prompt_list[i + 2]) if i + 2 < len(prompt_list) else num_loop
|
162 |
+
text_list.extend([text] * (end_loop - start_loop))
|
163 |
+
assert len(text_list) == num_loop, f"Prompt loop mismatch: {len(text_list)} != {num_loop}"
|
164 |
+
ret_prompts.append(text_list)
|
165 |
+
else:
|
166 |
+
prompt = text_preprocessing(prompt)
|
167 |
+
ret_prompts.append([prompt] * num_loop)
|
168 |
+
return ret_prompts
|
169 |
+
|
170 |
+
|
171 |
+
def extract_json_from_prompts(prompts):
|
172 |
+
additional_infos = []
|
173 |
+
ret_prompts = []
|
174 |
+
for prompt in prompts:
|
175 |
+
parts = re.split(r"(?=[{\[])", prompt)
|
176 |
+
assert len(parts) <= 2, f"Invalid prompt: {prompt}"
|
177 |
+
ret_prompts.append(parts[0])
|
178 |
+
if len(parts) == 1:
|
179 |
+
additional_infos.append({})
|
180 |
+
else:
|
181 |
+
additional_infos.append(json.loads(parts[1]))
|
182 |
+
return ret_prompts, additional_infos
|
183 |
+
|
184 |
+
|
185 |
+
# ============================
|
186 |
+
# Runtime Environment
|
187 |
+
# ============================
|
188 |
+
def install_dependencies(enable_optimization=False):
|
189 |
+
"""
|
190 |
+
Install the required dependencies for the demo if they are not already installed.
|
191 |
+
"""
|
192 |
+
|
193 |
+
def _is_package_available(name) -> bool:
|
194 |
+
try:
|
195 |
+
importlib.import_module(name)
|
196 |
+
return True
|
197 |
+
except (ImportError, ModuleNotFoundError):
|
198 |
+
return False
|
199 |
+
|
200 |
+
# flash attention is needed no matter optimization is enabled or not
|
201 |
+
# because Hugging Face transformers detects flash_attn is a dependency in STDiT
|
202 |
+
# thus, we need to install it no matter what
|
203 |
+
if not _is_package_available("flash_attn"):
|
204 |
+
subprocess.run(
|
205 |
+
f"{sys.executable} -m pip install flash-attn --no-build-isolation",
|
206 |
+
env={"FLASH_ATTENTION_SKIP_CUDA_BUILD": "TRUE"},
|
207 |
+
shell=True,
|
208 |
+
)
|
209 |
+
|
210 |
+
if enable_optimization:
|
211 |
+
# install apex for fused layernorm
|
212 |
+
if not _is_package_available("apex"):
|
213 |
+
subprocess.run(
|
214 |
+
f'{sys.executable} -m pip install -v --disable-pip-version-check --no-cache-dir --no-build-isolation --config-settings "--build-option=--cpp_ext" --config-settings "--build-option=--cuda_ext" git+https://github.com/NVIDIA/apex.git',
|
215 |
+
shell=True,
|
216 |
+
)
|
217 |
+
|
218 |
+
# install ninja
|
219 |
+
if not _is_package_available("ninja"):
|
220 |
+
subprocess.run(f"{sys.executable} -m pip install ninja", shell=True)
|
221 |
+
|
222 |
+
# install xformers
|
223 |
+
if not _is_package_available("xformers"):
|
224 |
+
subprocess.run(
|
225 |
+
f"{sys.executable} -m pip install -v -U git+https://github.com/facebookresearch/xformers.git@main#egg=xformers",
|
226 |
+
shell=True,
|
227 |
+
)
|
228 |
+
|
229 |
+
|
230 |
+
# ============================
|
231 |
+
# Model-related
|
232 |
+
# ============================
|
233 |
+
def read_config(config_path):
|
234 |
+
"""
|
235 |
+
Read the configuration file.
|
236 |
+
"""
|
237 |
+
from mmengine.config import Config
|
238 |
+
|
239 |
+
return Config.fromfile(config_path)
|
240 |
+
|
241 |
+
|
242 |
+
def build_models(model_type, config, enable_optimization=False):
|
243 |
+
"""
|
244 |
+
Build the models for the given model type and configuration.
|
245 |
+
"""
|
246 |
+
# build vae
|
247 |
+
from opensora.registry import MODELS, build_module
|
248 |
+
|
249 |
+
vae = build_module(config.vae, MODELS).cuda()
|
250 |
+
|
251 |
+
# build text encoder
|
252 |
+
text_encoder = build_module(config.text_encoder, MODELS) # T5 must be fp32
|
253 |
+
text_encoder.t5.model = text_encoder.t5.model.cuda()
|
254 |
+
|
255 |
+
# build stdit
|
256 |
+
# we load model from HuggingFace directly so that we don't need to
|
257 |
+
# handle model download logic in HuggingFace Space
|
258 |
+
from opensora.models.stdit.stdit2 import STDiT2
|
259 |
+
|
260 |
+
stdit = STDiT2.from_pretrained(
|
261 |
+
HF_STDIT_MAP[model_type],
|
262 |
+
enable_flash_attn=enable_optimization,
|
263 |
+
trust_remote_code=True,
|
264 |
+
).cuda()
|
265 |
+
|
266 |
+
# build scheduler
|
267 |
+
from opensora.registry import SCHEDULERS
|
268 |
+
|
269 |
+
scheduler = build_module(config.scheduler, SCHEDULERS)
|
270 |
+
|
271 |
+
# hack for classifier-free guidance
|
272 |
+
text_encoder.y_embedder = stdit.y_embedder
|
273 |
+
|
274 |
+
# move modelst to device
|
275 |
+
vae = vae.to(torch.bfloat16).eval()
|
276 |
+
text_encoder.t5.model = text_encoder.t5.model.eval() # t5 must be in fp32
|
277 |
+
stdit = stdit.to(torch.bfloat16).eval()
|
278 |
+
|
279 |
+
# clear cuda
|
280 |
+
torch.cuda.empty_cache()
|
281 |
+
return vae, text_encoder, stdit, scheduler
|
282 |
+
|
283 |
+
|
284 |
+
def parse_args():
|
285 |
+
parser = argparse.ArgumentParser()
|
286 |
+
parser.add_argument(
|
287 |
+
"--model-type",
|
288 |
+
default="v1.1-stage3",
|
289 |
+
choices=MODEL_TYPES,
|
290 |
+
help=f"The type of model to run for the Gradio App, can only be {MODEL_TYPES}",
|
291 |
+
)
|
292 |
+
parser.add_argument("--output", default="./outputs", type=str, help="The path to the output folder")
|
293 |
+
parser.add_argument("--port", default=None, type=int, help="The port to run the Gradio App on.")
|
294 |
+
parser.add_argument("--host", default=None, type=str, help="The host to run the Gradio App on.")
|
295 |
+
parser.add_argument("--share", action="store_true", help="Whether to share this gradio demo.")
|
296 |
+
parser.add_argument(
|
297 |
+
"--enable-optimization",
|
298 |
+
action="store_true",
|
299 |
+
help="Whether to enable optimization such as flash attention and fused layernorm",
|
300 |
+
)
|
301 |
+
return parser.parse_args()
|
302 |
+
|
303 |
+
|
304 |
+
# ============================
|
305 |
+
# Main Gradio Script
|
306 |
+
# ============================
|
307 |
+
# as `run_inference` needs to be wrapped by `spaces.GPU` and the input can only be the prompt text
|
308 |
+
# so we can't pass the models to `run_inference` as arguments.
|
309 |
+
# instead, we need to define them globally so that we can access these models inside `run_inference`
|
310 |
+
|
311 |
+
# read config
|
312 |
+
args = parse_args()
|
313 |
+
config = read_config(CONFIG_MAP[args.model_type])
|
314 |
+
|
315 |
+
# make outputs dir
|
316 |
+
os.makedirs(args.output, exist_ok=True)
|
317 |
+
|
318 |
+
# disable torch jit as it can cause failure in gradio SDK
|
319 |
+
# gradio sdk uses torch with cuda 11.3
|
320 |
+
torch.jit._state.disable()
|
321 |
+
|
322 |
+
# set up
|
323 |
+
install_dependencies(enable_optimization=args.enable_optimization)
|
324 |
+
|
325 |
+
# import after installation
|
326 |
+
from opensora.datasets import IMG_FPS, save_sample
|
327 |
+
from opensora.utils.misc import to_torch_dtype
|
328 |
+
|
329 |
+
# some global variables
|
330 |
+
dtype = to_torch_dtype(config.dtype)
|
331 |
+
device = torch.device("cuda")
|
332 |
+
|
333 |
+
# build model
|
334 |
+
vae, text_encoder, stdit, scheduler = build_models(args.model_type, config, enable_optimization=args.enable_optimization)
|
335 |
+
|
336 |
+
|
337 |
+
def run_inference(mode, prompt_text, resolution, aspect_ratio, length, reference_image, seed, sampling_steps, cfg_scale):
|
338 |
+
torch.manual_seed(seed)
|
339 |
+
with torch.inference_mode():
|
340 |
+
# ======================
|
341 |
+
# 1. Preparation
|
342 |
+
# ======================
|
343 |
+
# parse the inputs
|
344 |
+
resolution = RESOLUTION_MAP[resolution][aspect_ratio]
|
345 |
+
|
346 |
+
# gather args from config
|
347 |
+
num_frames = config.num_frames
|
348 |
+
frame_interval = config.frame_interval
|
349 |
+
fps = config.fps
|
350 |
+
condition_frame_length = config.condition_frame_length
|
351 |
+
|
352 |
+
# compute number of loops
|
353 |
+
if mode == "Text2Image":
|
354 |
+
num_frames = 1
|
355 |
+
num_loop = 1
|
356 |
+
else:
|
357 |
+
num_seconds = int(length.rstrip('s'))
|
358 |
+
if num_seconds <= 16:
|
359 |
+
num_frames = num_seconds * fps // frame_interval
|
360 |
+
num_loop = 1
|
361 |
+
else:
|
362 |
+
config.num_frames = 16
|
363 |
+
total_number_of_frames = num_seconds * fps / frame_interval
|
364 |
+
num_loop = math.ceil((total_number_of_frames - condition_frame_length) / (num_frames - condition_frame_length))
|
365 |
+
|
366 |
+
# prepare model args
|
367 |
+
if config.num_frames == 1:
|
368 |
+
fps = IMG_FPS
|
369 |
+
|
370 |
+
model_args = dict()
|
371 |
+
height_tensor = torch.tensor([resolution[0]], device=device, dtype=dtype)
|
372 |
+
width_tensor = torch.tensor([resolution[1]], device=device, dtype=dtype)
|
373 |
+
num_frames_tensor = torch.tensor([num_frames], device=device, dtype=dtype)
|
374 |
+
ar_tensor = torch.tensor([resolution[0] / resolution[1]], device=device, dtype=dtype)
|
375 |
+
fps_tensor = torch.tensor([fps], device=device, dtype=dtype)
|
376 |
+
model_args["height"] = height_tensor
|
377 |
+
model_args["width"] = width_tensor
|
378 |
+
model_args["num_frames"] = num_frames_tensor
|
379 |
+
model_args["ar"] = ar_tensor
|
380 |
+
model_args["fps"] = fps_tensor
|
381 |
+
|
382 |
+
# compute latent size
|
383 |
+
input_size = (num_frames, *resolution)
|
384 |
+
latent_size = vae.get_latent_size(input_size)
|
385 |
+
|
386 |
+
# process prompt
|
387 |
+
prompt_raw = [prompt_text]
|
388 |
+
prompt_raw, _ = extract_json_from_prompts(prompt_raw)
|
389 |
+
prompt_loops = process_prompts(prompt_raw, num_loop)
|
390 |
+
video_clips = []
|
391 |
+
|
392 |
+
# prepare mask strategy
|
393 |
+
if mode == "Text2Image":
|
394 |
+
mask_strategy = [None]
|
395 |
+
elif mode == "Text2Video":
|
396 |
+
if reference_image is not None:
|
397 |
+
mask_strategy = ['0']
|
398 |
+
else:
|
399 |
+
mask_strategy = [None]
|
400 |
+
else:
|
401 |
+
raise ValueError(f"Invalid mode: {mode}")
|
402 |
+
|
403 |
+
# =========================
|
404 |
+
# 2. Load reference images
|
405 |
+
# =========================
|
406 |
+
if mode == "Text2Image":
|
407 |
+
refs_x = collect_references_batch([None], vae, resolution)
|
408 |
+
elif mode == "Text2Video":
|
409 |
+
if reference_image is not None:
|
410 |
+
# save image to disk
|
411 |
+
from PIL import Image
|
412 |
+
im = Image.fromarray(reference_image)
|
413 |
+
|
414 |
+
with NamedTemporaryFile(suffix=".jpg") as temp_file:
|
415 |
+
im.save(temp_file.name)
|
416 |
+
refs_x = collect_references_batch([temp_file.name], vae, resolution)
|
417 |
+
else:
|
418 |
+
refs_x = collect_references_batch([None], vae, resolution)
|
419 |
+
else:
|
420 |
+
raise ValueError(f"Invalid mode: {mode}")
|
421 |
+
|
422 |
+
# 4.3. long video generation
|
423 |
+
for loop_i in range(num_loop):
|
424 |
+
# 4.4 sample in hidden space
|
425 |
+
batch_prompts = [prompt[loop_i] for prompt in prompt_loops]
|
426 |
+
z = torch.randn(len(batch_prompts), vae.out_channels, *latent_size, device=device, dtype=dtype)
|
427 |
+
|
428 |
+
# 4.5. apply mask strategy
|
429 |
+
masks = None
|
430 |
+
|
431 |
+
# if cfg.reference_path is not None:
|
432 |
+
if loop_i > 0:
|
433 |
+
ref_x = vae.encode(video_clips[-1])
|
434 |
+
for j, refs in enumerate(refs_x):
|
435 |
+
if refs is None:
|
436 |
+
refs_x[j] = [ref_x[j]]
|
437 |
+
else:
|
438 |
+
refs.append(ref_x[j])
|
439 |
+
if mask_strategy[j] is None:
|
440 |
+
mask_strategy[j] = ""
|
441 |
+
else:
|
442 |
+
mask_strategy[j] += ";"
|
443 |
+
mask_strategy[
|
444 |
+
j
|
445 |
+
] += f"{loop_i},{len(refs)-1},-{condition_frame_length},0,{condition_frame_length}"
|
446 |
+
|
447 |
+
masks = apply_mask_strategy(z, refs_x, mask_strategy, loop_i)
|
448 |
+
|
449 |
+
# 4.6. diffusion sampling
|
450 |
+
# hack to update num_sampling_steps and cfg_scale
|
451 |
+
scheduler_kwargs = config.scheduler.copy()
|
452 |
+
scheduler_kwargs.pop('type')
|
453 |
+
scheduler_kwargs['num_sampling_steps'] = sampling_steps
|
454 |
+
scheduler_kwargs['cfg_scale'] = cfg_scale
|
455 |
+
|
456 |
+
scheduler.__init__(
|
457 |
+
**scheduler_kwargs
|
458 |
+
)
|
459 |
+
samples = scheduler.sample(
|
460 |
+
stdit,
|
461 |
+
text_encoder,
|
462 |
+
z=z,
|
463 |
+
prompts=batch_prompts,
|
464 |
+
device=device,
|
465 |
+
additional_args=model_args,
|
466 |
+
mask=masks, # scheduler must support mask
|
467 |
+
)
|
468 |
+
samples = vae.decode(samples.to(dtype))
|
469 |
+
video_clips.append(samples)
|
470 |
+
|
471 |
+
# 4.7. save video
|
472 |
+
if loop_i == num_loop - 1:
|
473 |
+
video_clips_list = [
|
474 |
+
video_clips[0][0]] + [video_clips[i][0][:, config.condition_frame_length :]
|
475 |
+
for i in range(1, num_loop)
|
476 |
+
]
|
477 |
+
video = torch.cat(video_clips_list, dim=1)
|
478 |
+
current_datetime = datetime.datetime.now()
|
479 |
+
timestamp = current_datetime.timestamp()
|
480 |
+
save_path = os.path.join(args.output, f"output_{timestamp}")
|
481 |
+
saved_path = save_sample(video, save_path=save_path, fps=config.fps // config.frame_interval)
|
482 |
+
return saved_path
|
483 |
+
|
484 |
+
@spaces.GPU(duration=200)
|
485 |
+
def run_image_inference(prompt_text, resolution, aspect_ratio, length, reference_image, seed, sampling_steps, cfg_scale):
|
486 |
+
return run_inference("Text2Image", prompt_text, resolution, aspect_ratio, length, reference_image, seed, sampling_steps, cfg_scale)
|
487 |
+
|
488 |
+
@spaces.GPU(duration=200)
|
489 |
+
def run_video_inference(prompt_text, resolution, aspect_ratio, length, reference_image, seed, sampling_steps, cfg_scale):
|
490 |
+
return run_inference("Text2Video", prompt_text, resolution, aspect_ratio, length, reference_image, seed, sampling_steps, cfg_scale)
|
491 |
+
|
492 |
+
|
493 |
+
def main():
|
494 |
+
# create demo
|
495 |
+
with gr.Blocks() as demo:
|
496 |
+
with gr.Row():
|
497 |
+
with gr.Column():
|
498 |
+
gr.HTML(
|
499 |
+
"""
|
500 |
+
<div style='text-align: center;'>
|
501 |
+
<p align="center">
|
502 |
+
<img src="https://github.com/hpcaitech/Open-Sora/raw/main/assets/readme/icon.png" width="250"/>
|
503 |
+
</p>
|
504 |
+
<div style="display: flex; gap: 10px; justify-content: center;">
|
505 |
+
<a href="https://github.com/hpcaitech/Open-Sora/stargazers"><img src="https://img.shields.io/github/stars/hpcaitech/Open-Sora?style=social"></a>
|
506 |
+
<a href="https://hpcaitech.github.io/Open-Sora/"><img src="https://img.shields.io/badge/Gallery-View-orange?logo=&"></a>
|
507 |
+
<a href="https://discord.gg/kZakZzrSUT"><img src="https://img.shields.io/badge/Discord-join-blueviolet?logo=discord&"></a>
|
508 |
+
<a href="https://join.slack.com/t/colossalaiworkspace/shared_invite/zt-247ipg9fk-KRRYmUl~u2ll2637WRURVA"><img src="https://img.shields.io/badge/Slack-ColossalAI-blueviolet?logo=slack&"></a>
|
509 |
+
<a href="https://twitter.com/yangyou1991/status/1769411544083996787?s=61&t=jT0Dsx2d-MS5vS9rNM5e5g"><img src="https://img.shields.io/badge/Twitter-Discuss-blue?logo=twitter&"></a>
|
510 |
+
<a href="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/WeChat.png"><img src="https://img.shields.io/badge/微信-小助手加群-green?logo=wechat&"></a>
|
511 |
+
<a href="https://hpc-ai.com/blog/open-sora-v1.0"><img src="https://img.shields.io/badge/Open_Sora-Blog-blue"></a>
|
512 |
+
</div>
|
513 |
+
<h1 style='margin-top: 5px;'>Open-Sora: Democratizing Efficient Video Production for All</h1>
|
514 |
+
</div>
|
515 |
+
"""
|
516 |
+
)
|
517 |
+
|
518 |
+
with gr.Row():
|
519 |
+
with gr.Column():
|
520 |
+
prompt_text = gr.Textbox(
|
521 |
+
label="Prompt",
|
522 |
+
placeholder="Describe your video here",
|
523 |
+
lines=4,
|
524 |
+
)
|
525 |
+
resolution = gr.Radio(
|
526 |
+
choices=["144p", "240p", "360p", "480p", "720p"],
|
527 |
+
value="240p",
|
528 |
+
label="Resolution",
|
529 |
+
)
|
530 |
+
aspect_ratio = gr.Radio(
|
531 |
+
choices=["9:16", "16:9", "3:4", "4:3", "1:1"],
|
532 |
+
value="9:16",
|
533 |
+
label="Aspect Ratio (H:W)",
|
534 |
+
)
|
535 |
+
length = gr.Radio(
|
536 |
+
choices=["2s", "4s", "8s", "16s"],
|
537 |
+
value="2s",
|
538 |
+
label="Video Length (only effective for video generation)",
|
539 |
+
info="8s may fail as Hugging Face ZeroGPU has the limitation of max 200 seconds inference time."
|
540 |
+
)
|
541 |
+
|
542 |
+
with gr.Row():
|
543 |
+
seed = gr.Slider(
|
544 |
+
value=1024,
|
545 |
+
minimum=1,
|
546 |
+
maximum=2048,
|
547 |
+
step=1,
|
548 |
+
label="Seed"
|
549 |
+
)
|
550 |
+
|
551 |
+
sampling_steps = gr.Slider(
|
552 |
+
value=100,
|
553 |
+
minimum=1,
|
554 |
+
maximum=200,
|
555 |
+
step=1,
|
556 |
+
label="Sampling steps"
|
557 |
+
)
|
558 |
+
cfg_scale = gr.Slider(
|
559 |
+
value=7.0,
|
560 |
+
minimum=0.0,
|
561 |
+
maximum=10.0,
|
562 |
+
step=0.1,
|
563 |
+
label="CFG Scale"
|
564 |
+
)
|
565 |
+
|
566 |
+
reference_image = gr.Image(
|
567 |
+
label="Reference Image (Optional)",
|
568 |
+
)
|
569 |
+
|
570 |
+
with gr.Column():
|
571 |
+
output_video = gr.Video(
|
572 |
+
label="Output Video",
|
573 |
+
height="100%"
|
574 |
+
)
|
575 |
+
|
576 |
+
with gr.Row():
|
577 |
+
image_gen_button = gr.Button("Generate image")
|
578 |
+
video_gen_button = gr.Button("Generate video")
|
579 |
+
|
580 |
+
|
581 |
+
image_gen_button.click(
|
582 |
+
fn=run_image_inference,
|
583 |
+
inputs=[prompt_text, resolution, aspect_ratio, length, reference_image, seed, sampling_steps, cfg_scale],
|
584 |
+
outputs=reference_image
|
585 |
+
)
|
586 |
+
video_gen_button.click(
|
587 |
+
fn=run_video_inference,
|
588 |
+
inputs=[prompt_text, resolution, aspect_ratio, length, reference_image, seed, sampling_steps, cfg_scale],
|
589 |
+
outputs=output_video
|
590 |
+
)
|
591 |
+
|
592 |
+
# launch
|
593 |
+
demo.launch(server_port=args.port, server_name=args.host, share=args.share)
|
594 |
+
|
595 |
+
|
596 |
+
if __name__ == "__main__":
|
597 |
+
main()
|
configs/dit/inference/16x256x256.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
num_frames = 16
|
2 |
+
fps = 8
|
3 |
+
image_size = (256, 256)
|
4 |
+
|
5 |
+
# Define model
|
6 |
+
model = dict(
|
7 |
+
type="DiT-XL/2",
|
8 |
+
condition="text",
|
9 |
+
from_pretrained="PRETRAINED_MODEL",
|
10 |
+
)
|
11 |
+
vae = dict(
|
12 |
+
type="VideoAutoencoderKL",
|
13 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
14 |
+
)
|
15 |
+
text_encoder = dict(
|
16 |
+
type="clip",
|
17 |
+
from_pretrained="openai/clip-vit-base-patch32",
|
18 |
+
model_max_length=77,
|
19 |
+
)
|
20 |
+
scheduler = dict(
|
21 |
+
type="dpm-solver",
|
22 |
+
num_sampling_steps=20,
|
23 |
+
cfg_scale=4.0,
|
24 |
+
)
|
25 |
+
dtype = "bf16"
|
26 |
+
|
27 |
+
# Others
|
28 |
+
batch_size = 2
|
29 |
+
seed = 42
|
30 |
+
prompt_path = "./assets/texts/ucf101_labels.txt"
|
31 |
+
save_dir = "./samples/samples/"
|
configs/dit/inference/1x256x256-class.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
num_frames = 1
|
2 |
+
fps = 1
|
3 |
+
image_size = (256, 256)
|
4 |
+
|
5 |
+
# Define model
|
6 |
+
model = dict(
|
7 |
+
type="DiT-XL/2",
|
8 |
+
no_temporal_pos_emb=True,
|
9 |
+
condition="label_1000",
|
10 |
+
from_pretrained="DiT-XL-2-256x256.pt",
|
11 |
+
)
|
12 |
+
vae = dict(
|
13 |
+
type="VideoAutoencoderKL",
|
14 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
15 |
+
)
|
16 |
+
text_encoder = dict(
|
17 |
+
type="classes",
|
18 |
+
num_classes=1000,
|
19 |
+
)
|
20 |
+
scheduler = dict(
|
21 |
+
type="dpm-solver",
|
22 |
+
num_sampling_steps=20,
|
23 |
+
cfg_scale=4.0,
|
24 |
+
)
|
25 |
+
dtype = "bf16"
|
26 |
+
|
27 |
+
# Others
|
28 |
+
batch_size = 2
|
29 |
+
seed = 42
|
30 |
+
prompt_path = "./assets/texts/imagenet_id.txt"
|
31 |
+
save_dir = "./samples/samples/"
|
configs/dit/inference/1x256x256.py
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
num_frames = 1
|
2 |
+
fps = 1
|
3 |
+
image_size = (256, 256)
|
4 |
+
|
5 |
+
# Define model
|
6 |
+
model = dict(
|
7 |
+
type="DiT-XL/2",
|
8 |
+
no_temporal_pos_emb=True,
|
9 |
+
condition="text",
|
10 |
+
from_pretrained="PRETRAINED_MODEL",
|
11 |
+
)
|
12 |
+
vae = dict(
|
13 |
+
type="VideoAutoencoderKL",
|
14 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
15 |
+
)
|
16 |
+
text_encoder = dict(
|
17 |
+
type="clip",
|
18 |
+
from_pretrained="openai/clip-vit-base-patch32",
|
19 |
+
model_max_length=77,
|
20 |
+
)
|
21 |
+
scheduler = dict(
|
22 |
+
type="dpm-solver",
|
23 |
+
num_sampling_steps=20,
|
24 |
+
cfg_scale=4.0,
|
25 |
+
)
|
26 |
+
dtype = "bf16"
|
27 |
+
|
28 |
+
# Others
|
29 |
+
batch_size = 2
|
30 |
+
seed = 42
|
31 |
+
prompt_path = "./assets/texts/imagenet_labels.txt"
|
32 |
+
save_dir = "./samples/samples/"
|
configs/dit/train/16x256x256.py
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Define dataset
|
2 |
+
dataset = dict(
|
3 |
+
type="VideoTextDataset",
|
4 |
+
data_path=None,
|
5 |
+
num_frames=16,
|
6 |
+
frame_interval=3,
|
7 |
+
image_size=(256, 256),
|
8 |
+
)
|
9 |
+
|
10 |
+
# Define acceleration
|
11 |
+
num_workers = 4
|
12 |
+
dtype = "bf16"
|
13 |
+
grad_checkpoint = True
|
14 |
+
plugin = "zero2"
|
15 |
+
sp_size = 1
|
16 |
+
|
17 |
+
# Define model
|
18 |
+
model = dict(
|
19 |
+
type="DiT-XL/2",
|
20 |
+
from_pretrained="DiT-XL-2-256x256.pt",
|
21 |
+
enable_flash_attn=True,
|
22 |
+
enable_layernorm_kernel=True,
|
23 |
+
)
|
24 |
+
vae = dict(
|
25 |
+
type="VideoAutoencoderKL",
|
26 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
27 |
+
)
|
28 |
+
text_encoder = dict(
|
29 |
+
type="clip",
|
30 |
+
from_pretrained="openai/clip-vit-base-patch32",
|
31 |
+
model_max_length=77,
|
32 |
+
)
|
33 |
+
scheduler = dict(
|
34 |
+
type="iddpm",
|
35 |
+
timestep_respacing="",
|
36 |
+
)
|
37 |
+
|
38 |
+
# Others
|
39 |
+
seed = 42
|
40 |
+
outputs = "outputs"
|
41 |
+
wandb = False
|
42 |
+
|
43 |
+
epochs = 1000
|
44 |
+
log_every = 10
|
45 |
+
ckpt_every = 1000
|
46 |
+
load = None
|
47 |
+
|
48 |
+
batch_size = 8
|
49 |
+
lr = 2e-5
|
50 |
+
grad_clip = 1.0
|
configs/dit/train/1x256x256.py
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Define dataset
|
2 |
+
dataset = dict(
|
3 |
+
type="VideoTextDataset",
|
4 |
+
data_path=None,
|
5 |
+
num_frames=1,
|
6 |
+
frame_interval=1,
|
7 |
+
image_size=(256, 256),
|
8 |
+
transform_name="center",
|
9 |
+
)
|
10 |
+
|
11 |
+
# Define acceleration
|
12 |
+
num_workers = 4
|
13 |
+
dtype = "bf16"
|
14 |
+
grad_checkpoint = False
|
15 |
+
plugin = "zero2"
|
16 |
+
sp_size = 1
|
17 |
+
|
18 |
+
# Define model
|
19 |
+
model = dict(
|
20 |
+
type="DiT-XL/2",
|
21 |
+
no_temporal_pos_emb=True,
|
22 |
+
enable_flash_attn=True,
|
23 |
+
enable_layernorm_kernel=True,
|
24 |
+
)
|
25 |
+
vae = dict(
|
26 |
+
type="VideoAutoencoderKL",
|
27 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
28 |
+
)
|
29 |
+
text_encoder = dict(
|
30 |
+
type="clip",
|
31 |
+
from_pretrained="openai/clip-vit-base-patch32",
|
32 |
+
model_max_length=77,
|
33 |
+
)
|
34 |
+
scheduler = dict(
|
35 |
+
type="iddpm",
|
36 |
+
timestep_respacing="",
|
37 |
+
)
|
38 |
+
|
39 |
+
# Others
|
40 |
+
seed = 42
|
41 |
+
outputs = "outputs"
|
42 |
+
wandb = False
|
43 |
+
|
44 |
+
epochs = 1000
|
45 |
+
log_every = 10
|
46 |
+
ckpt_every = 1000
|
47 |
+
load = None
|
48 |
+
|
49 |
+
batch_size = 128
|
50 |
+
lr = 1e-4 # according to DiT repo
|
51 |
+
grad_clip = 1.0
|
configs/latte/inference/16x256x256-class.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
num_frames = 16
|
2 |
+
fps = 8
|
3 |
+
image_size = (256, 256)
|
4 |
+
|
5 |
+
# Define model
|
6 |
+
model = dict(
|
7 |
+
type="Latte-XL/2",
|
8 |
+
condition="label_101",
|
9 |
+
from_pretrained="Latte-XL-2-256x256-ucf101.pt",
|
10 |
+
)
|
11 |
+
vae = dict(
|
12 |
+
type="VideoAutoencoderKL",
|
13 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
14 |
+
)
|
15 |
+
text_encoder = dict(
|
16 |
+
type="classes",
|
17 |
+
num_classes=101,
|
18 |
+
)
|
19 |
+
scheduler = dict(
|
20 |
+
type="dpm-solver",
|
21 |
+
num_sampling_steps=20,
|
22 |
+
cfg_scale=4.0,
|
23 |
+
)
|
24 |
+
dtype = "bf16"
|
25 |
+
|
26 |
+
# Others
|
27 |
+
batch_size = 2
|
28 |
+
seed = 42
|
29 |
+
prompt_path = "./assets/texts/ucf101_id.txt"
|
30 |
+
save_dir = "./samples/samples/"
|
configs/latte/inference/16x256x256.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
num_frames = 16
|
2 |
+
fps = 8
|
3 |
+
image_size = (256, 256)
|
4 |
+
|
5 |
+
# Define model
|
6 |
+
model = dict(
|
7 |
+
type="Latte-XL/2",
|
8 |
+
condition="text",
|
9 |
+
from_pretrained="PRETRAINED_MODEL",
|
10 |
+
)
|
11 |
+
vae = dict(
|
12 |
+
type="VideoAutoencoderKL",
|
13 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
14 |
+
)
|
15 |
+
text_encoder = dict(
|
16 |
+
type="clip",
|
17 |
+
from_pretrained="openai/clip-vit-base-patch32",
|
18 |
+
model_max_length=77,
|
19 |
+
)
|
20 |
+
scheduler = dict(
|
21 |
+
type="dpm-solver",
|
22 |
+
num_sampling_steps=20,
|
23 |
+
cfg_scale=4.0,
|
24 |
+
)
|
25 |
+
dtype = "bf16"
|
26 |
+
|
27 |
+
# Others
|
28 |
+
batch_size = 2
|
29 |
+
seed = 42
|
30 |
+
prompt_path = "./assets/texts/ucf101_labels.txt"
|
31 |
+
save_dir = "./samples/samples/"
|
configs/latte/train/16x256x256.py
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Define dataset
|
2 |
+
dataset = dict(
|
3 |
+
type="VideoTextDataset",
|
4 |
+
data_path=None,
|
5 |
+
num_frames=16,
|
6 |
+
frame_interval=3,
|
7 |
+
image_size=(256, 256),
|
8 |
+
)
|
9 |
+
|
10 |
+
# Define acceleration
|
11 |
+
num_workers = 4
|
12 |
+
dtype = "bf16"
|
13 |
+
grad_checkpoint = True
|
14 |
+
plugin = "zero2"
|
15 |
+
sp_size = 1
|
16 |
+
|
17 |
+
# Define model
|
18 |
+
model = dict(
|
19 |
+
type="Latte-XL/2",
|
20 |
+
enable_flash_attn=True,
|
21 |
+
enable_layernorm_kernel=True,
|
22 |
+
)
|
23 |
+
vae = dict(
|
24 |
+
type="VideoAutoencoderKL",
|
25 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
26 |
+
)
|
27 |
+
text_encoder = dict(
|
28 |
+
type="clip",
|
29 |
+
from_pretrained="openai/clip-vit-base-patch32",
|
30 |
+
model_max_length=77,
|
31 |
+
)
|
32 |
+
scheduler = dict(
|
33 |
+
type="iddpm",
|
34 |
+
timestep_respacing="",
|
35 |
+
)
|
36 |
+
|
37 |
+
# Others
|
38 |
+
seed = 42
|
39 |
+
outputs = "outputs"
|
40 |
+
wandb = False
|
41 |
+
|
42 |
+
epochs = 1000
|
43 |
+
log_every = 10
|
44 |
+
ckpt_every = 1000
|
45 |
+
load = None
|
46 |
+
|
47 |
+
batch_size = 8
|
48 |
+
lr = 2e-5
|
49 |
+
grad_clip = 1.0
|
configs/opensora-v1-1/inference/sample-ref.py
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
num_frames = 16
|
2 |
+
frame_interval = 3
|
3 |
+
fps = 24
|
4 |
+
image_size = (240, 426)
|
5 |
+
multi_resolution = "STDiT2"
|
6 |
+
|
7 |
+
# Condition
|
8 |
+
prompt_path = None
|
9 |
+
prompt = [
|
10 |
+
"A car driving on the ocean.",
|
11 |
+
'Drone view of waves crashing against the rugged cliffs along Big Sur\'s garay point beach. The crashing blue waters create white-tipped waves, while the golden light of the setting sun illuminates the rocky shore. A small island with a lighthouse sits in the distance, and green shrubbery covers the cliff\'s edge. The steep drop from the road down to the beach is a dramatic feat, with the cliff\'s edges jutting out over the sea. This is a view that captures the raw beauty of the coast and the rugged landscape of the Pacific Coast Highway.{"reference_path": "assets/images/condition/cliff.png", "mask_strategy": "0"}',
|
12 |
+
"In an ornate, historical hall, a massive tidal wave peaks and begins to crash. Two surfers, seizing the moment, skillfully navigate the face of the wave.",
|
13 |
+
]
|
14 |
+
|
15 |
+
loop = 2
|
16 |
+
condition_frame_length = 4
|
17 |
+
# (
|
18 |
+
# loop id, [the loop index of the condition image or video]
|
19 |
+
# reference id, [the index of the condition image or video in the reference_path]
|
20 |
+
# reference start, [the start frame of the condition image or video]
|
21 |
+
# target start, [the location to insert]
|
22 |
+
# length, [the number of frames to insert]
|
23 |
+
# edit_ratio [the edit rate of the condition image or video]
|
24 |
+
# )
|
25 |
+
# See https://github.com/hpcaitech/Open-Sora/blob/main/docs/config.md#advanced-inference-config for more details
|
26 |
+
# See https://github.com/hpcaitech/Open-Sora/blob/main/docs/commands.md#inference-with-open-sora-11 for more examples
|
27 |
+
mask_strategy = [
|
28 |
+
"0,0,0,0,8,0.3",
|
29 |
+
None,
|
30 |
+
"0",
|
31 |
+
]
|
32 |
+
reference_path = [
|
33 |
+
"https://cdn.openai.com/tmp/s/interp/d0.mp4",
|
34 |
+
None,
|
35 |
+
"assets/images/condition/wave.png",
|
36 |
+
]
|
37 |
+
|
38 |
+
# Define model
|
39 |
+
model = dict(
|
40 |
+
type="STDiT2-XL/2",
|
41 |
+
from_pretrained="hpcai-tech/OpenSora-STDiT-v2-stage3",
|
42 |
+
input_sq_size=512,
|
43 |
+
qk_norm=True,
|
44 |
+
enable_flash_attn=True,
|
45 |
+
enable_layernorm_kernel=True,
|
46 |
+
)
|
47 |
+
vae = dict(
|
48 |
+
type="VideoAutoencoderKL",
|
49 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
50 |
+
cache_dir=None, # "/mnt/hdd/cached_models",
|
51 |
+
micro_batch_size=4,
|
52 |
+
)
|
53 |
+
text_encoder = dict(
|
54 |
+
type="t5",
|
55 |
+
from_pretrained="DeepFloyd/t5-v1_1-xxl",
|
56 |
+
cache_dir=None, # "/mnt/hdd/cached_models",
|
57 |
+
model_max_length=200,
|
58 |
+
)
|
59 |
+
scheduler = dict(
|
60 |
+
type="iddpm",
|
61 |
+
num_sampling_steps=100,
|
62 |
+
cfg_scale=7.0,
|
63 |
+
cfg_channel=3, # or None
|
64 |
+
)
|
65 |
+
dtype = "bf16"
|
66 |
+
|
67 |
+
# Others
|
68 |
+
batch_size = 1
|
69 |
+
seed = 42
|
70 |
+
save_dir = "./samples/samples/"
|
configs/opensora-v1-1/inference/sample.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
num_frames = 16
|
2 |
+
frame_interval = 3
|
3 |
+
fps = 24
|
4 |
+
image_size = (240, 426)
|
5 |
+
multi_resolution = "STDiT2"
|
6 |
+
|
7 |
+
# Define model
|
8 |
+
model = dict(
|
9 |
+
type="STDiT2-XL/2",
|
10 |
+
from_pretrained="hpcai-tech/OpenSora-STDiT-v2-stage3",
|
11 |
+
input_sq_size=512,
|
12 |
+
qk_norm=True,
|
13 |
+
enable_flash_attn=True,
|
14 |
+
enable_layernorm_kernel=True,
|
15 |
+
)
|
16 |
+
vae = dict(
|
17 |
+
type="VideoAutoencoderKL",
|
18 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
19 |
+
cache_dir=None, # "/mnt/hdd/cached_models",
|
20 |
+
micro_batch_size=4,
|
21 |
+
)
|
22 |
+
text_encoder = dict(
|
23 |
+
type="t5",
|
24 |
+
from_pretrained="DeepFloyd/t5-v1_1-xxl",
|
25 |
+
cache_dir=None, # "/mnt/hdd/cached_models",
|
26 |
+
model_max_length=200,
|
27 |
+
)
|
28 |
+
scheduler = dict(
|
29 |
+
type="iddpm",
|
30 |
+
num_sampling_steps=100,
|
31 |
+
cfg_scale=7.0,
|
32 |
+
cfg_channel=3, # or None
|
33 |
+
)
|
34 |
+
dtype = "bf16"
|
35 |
+
|
36 |
+
# Condition
|
37 |
+
prompt_path = "./assets/texts/t2v_samples.txt"
|
38 |
+
prompt = None # prompt has higher priority than prompt_path
|
39 |
+
|
40 |
+
# Others
|
41 |
+
batch_size = 1
|
42 |
+
seed = 42
|
43 |
+
save_dir = "./samples/samples/"
|
configs/opensora-v1-1/train/benchmark.py
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# this file is only for batch size search and is not used for training
|
2 |
+
|
3 |
+
# Define dataset
|
4 |
+
dataset = dict(
|
5 |
+
type="VariableVideoTextDataset",
|
6 |
+
data_path=None,
|
7 |
+
num_frames=None,
|
8 |
+
frame_interval=3,
|
9 |
+
image_size=(None, None),
|
10 |
+
transform_name="resize_crop",
|
11 |
+
)
|
12 |
+
|
13 |
+
# bucket config format:
|
14 |
+
# 1. { resolution: {num_frames: (prob, batch_size)} }, in this case batch_size is ignored when searching
|
15 |
+
# 2. { resolution: {num_frames: (prob, (max_batch_size, ))} }, batch_size is searched in the range [batch_size_start, max_batch_size), batch_size_start is configured via CLI
|
16 |
+
# 3. { resolution: {num_frames: (prob, (min_batch_size, max_batch_size))} }, batch_size is searched in the range [min_batch_size, max_batch_size)
|
17 |
+
# 4. { resolution: {num_frames: (prob, (min_batch_size, max_batch_size, step_size))} }, batch_size is searched in the range [min_batch_size, max_batch_size) with step_size (grid search)
|
18 |
+
# 5. { resolution: {num_frames: (0.0, None)} }, this bucket will not be used
|
19 |
+
|
20 |
+
bucket_config = {
|
21 |
+
# == manual search ==
|
22 |
+
# "240p": {128: (1.0, 2)}, # 4.28s/it
|
23 |
+
# "240p": {64: (1.0, 4)},
|
24 |
+
# "240p": {32: (1.0, 8)}, # 4.6s/it
|
25 |
+
# "240p": {16: (1.0, 16)}, # 4.6s/it
|
26 |
+
# "480p": {16: (1.0, 4)}, # 4.6s/it
|
27 |
+
# "720p": {16: (1.0, 2)}, # 5.89s/it
|
28 |
+
# "256": {1: (1.0, 256)}, # 4.5s/it
|
29 |
+
# "512": {1: (1.0, 96)}, # 4.7s/it
|
30 |
+
# "512": {1: (1.0, 128)}, # 6.3s/it
|
31 |
+
# "480p": {1: (1.0, 50)}, # 4.0s/it
|
32 |
+
# "1024": {1: (1.0, 32)}, # 6.8s/it
|
33 |
+
# "1024": {1: (1.0, 20)}, # 4.3s/it
|
34 |
+
# "1080p": {1: (1.0, 16)}, # 8.6s/it
|
35 |
+
# "1080p": {1: (1.0, 8)}, # 4.4s/it
|
36 |
+
# == stage 2 ==
|
37 |
+
# "240p": {
|
38 |
+
# 16: (1.0, (2, 32)),
|
39 |
+
# 32: (1.0, (2, 16)),
|
40 |
+
# 64: (1.0, (2, 8)),
|
41 |
+
# 128: (1.0, (2, 6)),
|
42 |
+
# },
|
43 |
+
# "256": {1: (1.0, (128, 300))},
|
44 |
+
# "512": {1: (0.5, (64, 128))},
|
45 |
+
# "480p": {1: (0.4, (32, 128)), 16: (0.4, (2, 32)), 32: (0.0, None)},
|
46 |
+
# "720p": {16: (0.1, (2, 16)), 32: (0.0, None)}, # No examples now
|
47 |
+
# "1024": {1: (0.3, (8, 64))},
|
48 |
+
# "1080p": {1: (0.3, (2, 32))},
|
49 |
+
# == stage 3 ==
|
50 |
+
"720p": {1: (20, 40), 32: (0.5, (2, 4)), 64: (0.5, (1, 1))},
|
51 |
+
}
|
52 |
+
|
53 |
+
|
54 |
+
# Define acceleration
|
55 |
+
num_workers = 4
|
56 |
+
num_bucket_build_workers = 16
|
57 |
+
dtype = "bf16"
|
58 |
+
grad_checkpoint = True
|
59 |
+
plugin = "zero2"
|
60 |
+
sp_size = 1
|
61 |
+
|
62 |
+
# Define model
|
63 |
+
model = dict(
|
64 |
+
type="STDiT2-XL/2",
|
65 |
+
from_pretrained=None,
|
66 |
+
input_sq_size=512, # pretrained model is trained on 512x512
|
67 |
+
qk_norm=True,
|
68 |
+
enable_flash_attn=True,
|
69 |
+
enable_layernorm_kernel=True,
|
70 |
+
)
|
71 |
+
vae = dict(
|
72 |
+
type="VideoAutoencoderKL",
|
73 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
74 |
+
micro_batch_size=4,
|
75 |
+
local_files_only=True,
|
76 |
+
)
|
77 |
+
text_encoder = dict(
|
78 |
+
type="t5",
|
79 |
+
from_pretrained="DeepFloyd/t5-v1_1-xxl",
|
80 |
+
model_max_length=200,
|
81 |
+
shardformer=True,
|
82 |
+
local_files_only=True,
|
83 |
+
)
|
84 |
+
scheduler = dict(
|
85 |
+
type="iddpm",
|
86 |
+
timestep_respacing="",
|
87 |
+
)
|
88 |
+
|
89 |
+
# Others
|
90 |
+
seed = 42
|
91 |
+
outputs = "outputs"
|
92 |
+
wandb = False
|
93 |
+
|
94 |
+
epochs = 1000
|
95 |
+
log_every = 10
|
96 |
+
ckpt_every = 1000
|
97 |
+
load = None
|
98 |
+
|
99 |
+
batch_size = None
|
100 |
+
lr = 2e-5
|
101 |
+
grad_clip = 1.0
|
configs/opensora-v1-1/train/image.py
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Define dataset
|
2 |
+
dataset = dict(
|
3 |
+
type="VariableVideoTextDataset",
|
4 |
+
data_path=None,
|
5 |
+
num_frames=None,
|
6 |
+
frame_interval=3,
|
7 |
+
image_size=(None, None),
|
8 |
+
transform_name="resize_crop",
|
9 |
+
)
|
10 |
+
bucket_config = { # 6s/it
|
11 |
+
"256": {1: (1.0, 256)},
|
12 |
+
"512": {1: (1.0, 80)},
|
13 |
+
"480p": {1: (1.0, 52)},
|
14 |
+
"1024": {1: (1.0, 20)},
|
15 |
+
"1080p": {1: (1.0, 8)},
|
16 |
+
}
|
17 |
+
|
18 |
+
# Define acceleration
|
19 |
+
num_workers = 4
|
20 |
+
num_bucket_build_workers = 16
|
21 |
+
dtype = "bf16"
|
22 |
+
grad_checkpoint = True
|
23 |
+
plugin = "zero2"
|
24 |
+
sp_size = 1
|
25 |
+
|
26 |
+
# Define model
|
27 |
+
model = dict(
|
28 |
+
type="STDiT2-XL/2",
|
29 |
+
from_pretrained=None,
|
30 |
+
input_sq_size=512, # pretrained model is trained on 512x512
|
31 |
+
qk_norm=True,
|
32 |
+
enable_flash_attn=True,
|
33 |
+
enable_layernorm_kernel=True,
|
34 |
+
)
|
35 |
+
vae = dict(
|
36 |
+
type="VideoAutoencoderKL",
|
37 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
38 |
+
micro_batch_size=4,
|
39 |
+
local_files_only=True,
|
40 |
+
)
|
41 |
+
text_encoder = dict(
|
42 |
+
type="t5",
|
43 |
+
from_pretrained="DeepFloyd/t5-v1_1-xxl",
|
44 |
+
model_max_length=200,
|
45 |
+
shardformer=True,
|
46 |
+
local_files_only=True,
|
47 |
+
)
|
48 |
+
scheduler = dict(
|
49 |
+
type="iddpm",
|
50 |
+
timestep_respacing="",
|
51 |
+
)
|
52 |
+
|
53 |
+
# Others
|
54 |
+
seed = 42
|
55 |
+
outputs = "outputs"
|
56 |
+
wandb = False
|
57 |
+
|
58 |
+
epochs = 1000
|
59 |
+
log_every = 10
|
60 |
+
ckpt_every = 500
|
61 |
+
load = None
|
62 |
+
|
63 |
+
batch_size = 10 # only for logging
|
64 |
+
lr = 2e-5
|
65 |
+
grad_clip = 1.0
|
configs/opensora-v1-1/train/stage1.py
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Define dataset
|
2 |
+
dataset = dict(
|
3 |
+
type="VariableVideoTextDataset",
|
4 |
+
data_path=None,
|
5 |
+
num_frames=None,
|
6 |
+
frame_interval=3,
|
7 |
+
image_size=(None, None),
|
8 |
+
transform_name="resize_crop",
|
9 |
+
)
|
10 |
+
# IMG: 1024 (20%) 512 (30%) 256 (50%) drop (50%)
|
11 |
+
bucket_config = { # 1s/it
|
12 |
+
"144p": {1: (0.5, 48), 16: (1.0, 6), 32: (1.0, 3), 96: (1.0, 1)},
|
13 |
+
"256": {1: (0.5, 24), 16: (0.5, 3), 48: (0.5, 1), 64: (0.0, None)},
|
14 |
+
"240p": {16: (0.3, 2), 32: (0.3, 1), 64: (0.0, None)},
|
15 |
+
"512": {1: (0.4, 12)},
|
16 |
+
"1024": {1: (0.3, 3)},
|
17 |
+
}
|
18 |
+
mask_ratios = {
|
19 |
+
"mask_no": 0.75,
|
20 |
+
"mask_quarter_random": 0.025,
|
21 |
+
"mask_quarter_head": 0.025,
|
22 |
+
"mask_quarter_tail": 0.025,
|
23 |
+
"mask_quarter_head_tail": 0.05,
|
24 |
+
"mask_image_random": 0.025,
|
25 |
+
"mask_image_head": 0.025,
|
26 |
+
"mask_image_tail": 0.025,
|
27 |
+
"mask_image_head_tail": 0.05,
|
28 |
+
}
|
29 |
+
|
30 |
+
# Define acceleration
|
31 |
+
num_workers = 8
|
32 |
+
num_bucket_build_workers = 16
|
33 |
+
dtype = "bf16"
|
34 |
+
grad_checkpoint = False
|
35 |
+
plugin = "zero2"
|
36 |
+
sp_size = 1
|
37 |
+
|
38 |
+
# Define model
|
39 |
+
model = dict(
|
40 |
+
type="STDiT2-XL/2",
|
41 |
+
from_pretrained=None,
|
42 |
+
input_sq_size=512, # pretrained model is trained on 512x512
|
43 |
+
qk_norm=True,
|
44 |
+
enable_flash_attn=True,
|
45 |
+
enable_layernorm_kernel=True,
|
46 |
+
)
|
47 |
+
vae = dict(
|
48 |
+
type="VideoAutoencoderKL",
|
49 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
50 |
+
micro_batch_size=4,
|
51 |
+
local_files_only=True,
|
52 |
+
)
|
53 |
+
text_encoder = dict(
|
54 |
+
type="t5",
|
55 |
+
from_pretrained="DeepFloyd/t5-v1_1-xxl",
|
56 |
+
model_max_length=200,
|
57 |
+
shardformer=True,
|
58 |
+
local_files_only=True,
|
59 |
+
)
|
60 |
+
scheduler = dict(
|
61 |
+
type="iddpm",
|
62 |
+
timestep_respacing="",
|
63 |
+
)
|
64 |
+
|
65 |
+
# Others
|
66 |
+
seed = 42
|
67 |
+
outputs = "outputs"
|
68 |
+
wandb = False
|
69 |
+
|
70 |
+
epochs = 1000
|
71 |
+
log_every = 10
|
72 |
+
ckpt_every = 500
|
73 |
+
load = None
|
74 |
+
|
75 |
+
batch_size = None
|
76 |
+
lr = 2e-5
|
77 |
+
grad_clip = 1.0
|
configs/opensora-v1-1/train/stage2.py
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Define dataset
|
2 |
+
dataset = dict(
|
3 |
+
type="VariableVideoTextDataset",
|
4 |
+
data_path=None,
|
5 |
+
num_frames=None,
|
6 |
+
frame_interval=3,
|
7 |
+
image_size=(None, None),
|
8 |
+
transform_name="resize_crop",
|
9 |
+
)
|
10 |
+
bucket_config = { # 7s/it
|
11 |
+
"144p": {1: (1.0, 48), 16: (1.0, 17), 32: (1.0, 9), 64: (1.0, 4), 128: (1.0, 1)},
|
12 |
+
"256": {1: (0.8, 254), 16: (0.5, 17), 32: (0.5, 9), 64: (0.5, 4), 128: (0.5, 1)},
|
13 |
+
"240p": {1: (0.1, 20), 16: (0.9, 17), 32: (0.8, 9), 64: (0.8, 4), 128: (0.8, 2)},
|
14 |
+
"512": {1: (0.5, 86), 16: (0.2, 4), 32: (0.2, 2), 64: (0.2, 1), 128: (0.0, None)},
|
15 |
+
"480p": {1: (0.4, 54), 16: (0.4, 4), 32: (0.0, None)},
|
16 |
+
"720p": {1: (0.1, 20), 16: (0.1, 2), 32: (0.0, None)},
|
17 |
+
"1024": {1: (0.3, 20)},
|
18 |
+
"1080p": {1: (0.4, 8)},
|
19 |
+
}
|
20 |
+
mask_ratios = {
|
21 |
+
"mask_no": 0.75,
|
22 |
+
"mask_quarter_random": 0.025,
|
23 |
+
"mask_quarter_head": 0.025,
|
24 |
+
"mask_quarter_tail": 0.025,
|
25 |
+
"mask_quarter_head_tail": 0.05,
|
26 |
+
"mask_image_random": 0.025,
|
27 |
+
"mask_image_head": 0.025,
|
28 |
+
"mask_image_tail": 0.025,
|
29 |
+
"mask_image_head_tail": 0.05,
|
30 |
+
}
|
31 |
+
|
32 |
+
# Define acceleration
|
33 |
+
num_workers = 8
|
34 |
+
num_bucket_build_workers = 16
|
35 |
+
dtype = "bf16"
|
36 |
+
grad_checkpoint = True
|
37 |
+
plugin = "zero2"
|
38 |
+
sp_size = 1
|
39 |
+
|
40 |
+
# Define model
|
41 |
+
model = dict(
|
42 |
+
type="STDiT2-XL/2",
|
43 |
+
from_pretrained=None,
|
44 |
+
input_sq_size=512, # pretrained model is trained on 512x512
|
45 |
+
qk_norm=True,
|
46 |
+
enable_flash_attn=True,
|
47 |
+
enable_layernorm_kernel=True,
|
48 |
+
)
|
49 |
+
vae = dict(
|
50 |
+
type="VideoAutoencoderKL",
|
51 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
52 |
+
micro_batch_size=4,
|
53 |
+
local_files_only=True,
|
54 |
+
)
|
55 |
+
text_encoder = dict(
|
56 |
+
type="t5",
|
57 |
+
from_pretrained="DeepFloyd/t5-v1_1-xxl",
|
58 |
+
model_max_length=200,
|
59 |
+
shardformer=True,
|
60 |
+
local_files_only=True,
|
61 |
+
)
|
62 |
+
scheduler = dict(
|
63 |
+
type="iddpm",
|
64 |
+
timestep_respacing="",
|
65 |
+
)
|
66 |
+
|
67 |
+
# Others
|
68 |
+
seed = 42
|
69 |
+
outputs = "outputs"
|
70 |
+
wandb = False
|
71 |
+
|
72 |
+
epochs = 1000
|
73 |
+
log_every = 10
|
74 |
+
ckpt_every = 500
|
75 |
+
load = None
|
76 |
+
|
77 |
+
batch_size = None
|
78 |
+
lr = 2e-5
|
79 |
+
grad_clip = 1.0
|
configs/opensora-v1-1/train/stage3.py
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Define dataset
|
2 |
+
dataset = dict(
|
3 |
+
type="VariableVideoTextDataset",
|
4 |
+
data_path=None,
|
5 |
+
num_frames=None,
|
6 |
+
frame_interval=3,
|
7 |
+
image_size=(None, None),
|
8 |
+
transform_name="resize_crop",
|
9 |
+
)
|
10 |
+
bucket_config = { # 13s/it
|
11 |
+
"144p": {1: (1.0, 200), 16: (1.0, 36), 32: (1.0, 18), 64: (1.0, 9), 128: (1.0, 4)},
|
12 |
+
"256": {1: (0.8, 200), 16: (0.5, 22), 32: (0.5, 11), 64: (0.5, 6), 128: (0.8, 4)},
|
13 |
+
"240p": {1: (0.8, 200), 16: (0.5, 22), 32: (0.5, 10), 64: (0.5, 6), 128: (0.5, 3)},
|
14 |
+
"360p": {1: (0.5, 120), 16: (0.5, 9), 32: (0.5, 4), 64: (0.5, 2), 128: (0.5, 1)},
|
15 |
+
"512": {1: (0.5, 120), 16: (0.5, 9), 32: (0.5, 4), 64: (0.5, 2), 128: (0.8, 1)},
|
16 |
+
"480p": {1: (0.4, 80), 16: (0.6, 6), 32: (0.6, 3), 64: (0.6, 1), 128: (0.0, None)},
|
17 |
+
"720p": {1: (0.4, 40), 16: (0.6, 3), 32: (0.6, 1), 96: (0.0, None)},
|
18 |
+
"1024": {1: (0.3, 40)},
|
19 |
+
}
|
20 |
+
mask_ratios = {
|
21 |
+
"mask_no": 0.75,
|
22 |
+
"mask_quarter_random": 0.025,
|
23 |
+
"mask_quarter_head": 0.025,
|
24 |
+
"mask_quarter_tail": 0.025,
|
25 |
+
"mask_quarter_head_tail": 0.05,
|
26 |
+
"mask_image_random": 0.025,
|
27 |
+
"mask_image_head": 0.025,
|
28 |
+
"mask_image_tail": 0.025,
|
29 |
+
"mask_image_head_tail": 0.05,
|
30 |
+
}
|
31 |
+
|
32 |
+
# Define acceleration
|
33 |
+
num_workers = 8
|
34 |
+
num_bucket_build_workers = 16
|
35 |
+
dtype = "bf16"
|
36 |
+
grad_checkpoint = True
|
37 |
+
plugin = "zero2"
|
38 |
+
sp_size = 1
|
39 |
+
|
40 |
+
# Define model
|
41 |
+
model = dict(
|
42 |
+
type="STDiT2-XL/2",
|
43 |
+
from_pretrained=None,
|
44 |
+
input_sq_size=512, # pretrained model is trained on 512x512
|
45 |
+
qk_norm=True,
|
46 |
+
enable_flash_attn=True,
|
47 |
+
enable_layernorm_kernel=True,
|
48 |
+
)
|
49 |
+
vae = dict(
|
50 |
+
type="VideoAutoencoderKL",
|
51 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
52 |
+
micro_batch_size=4,
|
53 |
+
local_files_only=True,
|
54 |
+
)
|
55 |
+
text_encoder = dict(
|
56 |
+
type="t5",
|
57 |
+
from_pretrained="DeepFloyd/t5-v1_1-xxl",
|
58 |
+
model_max_length=200,
|
59 |
+
shardformer=True,
|
60 |
+
local_files_only=True,
|
61 |
+
)
|
62 |
+
scheduler = dict(
|
63 |
+
type="iddpm",
|
64 |
+
timestep_respacing="",
|
65 |
+
)
|
66 |
+
|
67 |
+
# Others
|
68 |
+
seed = 42
|
69 |
+
outputs = "outputs"
|
70 |
+
wandb = False
|
71 |
+
|
72 |
+
epochs = 1000
|
73 |
+
log_every = 10
|
74 |
+
ckpt_every = 500
|
75 |
+
load = None
|
76 |
+
|
77 |
+
batch_size = None
|
78 |
+
lr = 2e-5
|
79 |
+
grad_clip = 1.0
|
configs/opensora-v1-1/train/video.py
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Define dataset
|
2 |
+
dataset = dict(
|
3 |
+
type="VariableVideoTextDataset",
|
4 |
+
data_path=None,
|
5 |
+
num_frames=None,
|
6 |
+
frame_interval=3,
|
7 |
+
image_size=(None, None),
|
8 |
+
transform_name="resize_crop",
|
9 |
+
)
|
10 |
+
bucket_config = { # 6s/it
|
11 |
+
"240p": {16: (1.0, 16), 32: (1.0, 8), 64: (1.0, 4), 128: (1.0, 2)},
|
12 |
+
"256": {1: (1.0, 256)},
|
13 |
+
"512": {1: (0.5, 80)},
|
14 |
+
"480p": {1: (0.4, 52), 16: (0.4, 4), 32: (0.0, None)},
|
15 |
+
"720p": {16: (0.1, 2), 32: (0.0, None)}, # No examples now
|
16 |
+
"1024": {1: (0.3, 20)},
|
17 |
+
"1080p": {1: (0.3, 8)},
|
18 |
+
}
|
19 |
+
|
20 |
+
# Define acceleration
|
21 |
+
num_workers = 4
|
22 |
+
num_bucket_build_workers = 16
|
23 |
+
dtype = "bf16"
|
24 |
+
grad_checkpoint = True
|
25 |
+
plugin = "zero2"
|
26 |
+
sp_size = 1
|
27 |
+
|
28 |
+
# Define model
|
29 |
+
model = dict(
|
30 |
+
type="STDiT2-XL/2",
|
31 |
+
from_pretrained=None,
|
32 |
+
input_sq_size=512, # pretrained model is trained on 512x512
|
33 |
+
qk_norm=True,
|
34 |
+
enable_flash_attn=True,
|
35 |
+
enable_layernorm_kernel=True,
|
36 |
+
)
|
37 |
+
vae = dict(
|
38 |
+
type="VideoAutoencoderKL",
|
39 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
40 |
+
micro_batch_size=4,
|
41 |
+
local_files_only=True,
|
42 |
+
)
|
43 |
+
text_encoder = dict(
|
44 |
+
type="t5",
|
45 |
+
from_pretrained="DeepFloyd/t5-v1_1-xxl",
|
46 |
+
model_max_length=200,
|
47 |
+
shardformer=True,
|
48 |
+
local_files_only=True,
|
49 |
+
)
|
50 |
+
scheduler = dict(
|
51 |
+
type="iddpm",
|
52 |
+
timestep_respacing="",
|
53 |
+
)
|
54 |
+
|
55 |
+
# Others
|
56 |
+
seed = 42
|
57 |
+
outputs = "outputs"
|
58 |
+
wandb = False
|
59 |
+
|
60 |
+
epochs = 1000
|
61 |
+
log_every = 10
|
62 |
+
ckpt_every = 500
|
63 |
+
load = None
|
64 |
+
|
65 |
+
batch_size = 10 # only for logging
|
66 |
+
lr = 2e-5
|
67 |
+
grad_clip = 1.0
|
configs/opensora/inference/16x256x256.py
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
num_frames = 16
|
2 |
+
fps = 24 // 3
|
3 |
+
image_size = (256, 256)
|
4 |
+
|
5 |
+
# Define model
|
6 |
+
model = dict(
|
7 |
+
type="STDiT-XL/2",
|
8 |
+
space_scale=0.5,
|
9 |
+
time_scale=1.0,
|
10 |
+
enable_flash_attn=True,
|
11 |
+
enable_layernorm_kernel=True,
|
12 |
+
from_pretrained="PRETRAINED_MODEL",
|
13 |
+
)
|
14 |
+
vae = dict(
|
15 |
+
type="VideoAutoencoderKL",
|
16 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
17 |
+
micro_batch_size=4,
|
18 |
+
)
|
19 |
+
text_encoder = dict(
|
20 |
+
type="t5",
|
21 |
+
from_pretrained="DeepFloyd/t5-v1_1-xxl",
|
22 |
+
model_max_length=120,
|
23 |
+
)
|
24 |
+
scheduler = dict(
|
25 |
+
type="iddpm",
|
26 |
+
num_sampling_steps=100,
|
27 |
+
cfg_scale=7.0,
|
28 |
+
cfg_channel=3, # or None
|
29 |
+
)
|
30 |
+
dtype = "bf16"
|
31 |
+
|
32 |
+
# Condition
|
33 |
+
prompt_path = "./assets/texts/t2v_samples.txt"
|
34 |
+
prompt = None # prompt has higher priority than prompt_path
|
35 |
+
|
36 |
+
# Others
|
37 |
+
batch_size = 1
|
38 |
+
seed = 42
|
39 |
+
save_dir = "./samples/samples/"
|
configs/opensora/inference/16x512x512.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
num_frames = 16
|
2 |
+
fps = 24 // 3
|
3 |
+
image_size = (512, 512)
|
4 |
+
|
5 |
+
# Define model
|
6 |
+
model = dict(
|
7 |
+
type="STDiT-XL/2",
|
8 |
+
space_scale=1.0,
|
9 |
+
time_scale=1.0,
|
10 |
+
enable_flash_attn=True,
|
11 |
+
enable_layernorm_kernel=True,
|
12 |
+
from_pretrained="PRETRAINED_MODEL",
|
13 |
+
)
|
14 |
+
vae = dict(
|
15 |
+
type="VideoAutoencoderKL",
|
16 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
17 |
+
micro_batch_size=2,
|
18 |
+
)
|
19 |
+
text_encoder = dict(
|
20 |
+
type="t5",
|
21 |
+
from_pretrained="DeepFloyd/t5-v1_1-xxl",
|
22 |
+
model_max_length=120,
|
23 |
+
)
|
24 |
+
scheduler = dict(
|
25 |
+
type="iddpm",
|
26 |
+
num_sampling_steps=100,
|
27 |
+
cfg_scale=7.0,
|
28 |
+
)
|
29 |
+
dtype = "bf16"
|
30 |
+
|
31 |
+
# Others
|
32 |
+
batch_size = 2
|
33 |
+
seed = 42
|
34 |
+
prompt_path = "./assets/texts/t2v_samples.txt"
|
35 |
+
save_dir = "./samples/samples/"
|
configs/opensora/inference/64x512x512.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
num_frames = 64
|
2 |
+
fps = 24 // 2
|
3 |
+
image_size = (512, 512)
|
4 |
+
|
5 |
+
# Define model
|
6 |
+
model = dict(
|
7 |
+
type="STDiT-XL/2",
|
8 |
+
space_scale=1.0,
|
9 |
+
time_scale=2 / 3,
|
10 |
+
enable_flash_attn=True,
|
11 |
+
enable_layernorm_kernel=True,
|
12 |
+
from_pretrained="PRETRAINED_MODEL",
|
13 |
+
)
|
14 |
+
vae = dict(
|
15 |
+
type="VideoAutoencoderKL",
|
16 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
17 |
+
micro_batch_size=128,
|
18 |
+
)
|
19 |
+
text_encoder = dict(
|
20 |
+
type="t5",
|
21 |
+
from_pretrained="DeepFloyd/t5-v1_1-xxl",
|
22 |
+
model_max_length=120,
|
23 |
+
)
|
24 |
+
scheduler = dict(
|
25 |
+
type="iddpm",
|
26 |
+
num_sampling_steps=100,
|
27 |
+
cfg_scale=7.0,
|
28 |
+
)
|
29 |
+
dtype = "bf16"
|
30 |
+
|
31 |
+
# Others
|
32 |
+
batch_size = 1
|
33 |
+
seed = 42
|
34 |
+
prompt_path = "./assets/texts/t2v_samples.txt"
|
35 |
+
save_dir = "./samples/samples/"
|
configs/opensora/train/16x256x256-mask.py
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Define dataset
|
2 |
+
dataset = dict(
|
3 |
+
type="VideoTextDataset",
|
4 |
+
data_path=None,
|
5 |
+
num_frames=16,
|
6 |
+
frame_interval=3,
|
7 |
+
image_size=(256, 256),
|
8 |
+
)
|
9 |
+
|
10 |
+
# Define acceleration
|
11 |
+
num_workers = 4
|
12 |
+
dtype = "bf16"
|
13 |
+
grad_checkpoint = True
|
14 |
+
plugin = "zero2"
|
15 |
+
sp_size = 1
|
16 |
+
|
17 |
+
# Define model
|
18 |
+
model = dict(
|
19 |
+
type="STDiT-XL/2",
|
20 |
+
space_scale=0.5,
|
21 |
+
time_scale=1.0,
|
22 |
+
from_pretrained="PixArt-XL-2-512x512.pth",
|
23 |
+
enable_flash_attn=True,
|
24 |
+
enable_layernorm_kernel=True,
|
25 |
+
)
|
26 |
+
mask_ratios = {
|
27 |
+
"mask_no": 0.7,
|
28 |
+
"mask_random": 0.15,
|
29 |
+
"mask_head": 0.05,
|
30 |
+
"mask_tail": 0.05,
|
31 |
+
"mask_head_tail": 0.05,
|
32 |
+
}
|
33 |
+
vae = dict(
|
34 |
+
type="VideoAutoencoderKL",
|
35 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
36 |
+
)
|
37 |
+
text_encoder = dict(
|
38 |
+
type="t5",
|
39 |
+
from_pretrained="DeepFloyd/t5-v1_1-xxl",
|
40 |
+
model_max_length=120,
|
41 |
+
shardformer=True,
|
42 |
+
)
|
43 |
+
scheduler = dict(
|
44 |
+
type="iddpm",
|
45 |
+
timestep_respacing="",
|
46 |
+
)
|
47 |
+
|
48 |
+
# Others
|
49 |
+
seed = 42
|
50 |
+
outputs = "outputs"
|
51 |
+
wandb = False
|
52 |
+
|
53 |
+
epochs = 1000
|
54 |
+
log_every = 10
|
55 |
+
ckpt_every = 1000
|
56 |
+
load = None
|
57 |
+
|
58 |
+
batch_size = 8
|
59 |
+
lr = 2e-5
|
60 |
+
grad_clip = 1.0
|
configs/opensora/train/16x256x256-spee.py
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Define dataset
|
2 |
+
dataset = dict(
|
3 |
+
type="VideoTextDataset",
|
4 |
+
data_path=None,
|
5 |
+
num_frames=16,
|
6 |
+
frame_interval=3,
|
7 |
+
image_size=(256, 256),
|
8 |
+
)
|
9 |
+
|
10 |
+
# Define acceleration
|
11 |
+
num_workers = 4
|
12 |
+
dtype = "bf16"
|
13 |
+
grad_checkpoint = True
|
14 |
+
plugin = "zero2"
|
15 |
+
sp_size = 1
|
16 |
+
|
17 |
+
# Define model
|
18 |
+
model = dict(
|
19 |
+
type="STDiT-XL/2",
|
20 |
+
space_scale=0.5,
|
21 |
+
time_scale=1.0,
|
22 |
+
from_pretrained="PixArt-XL-2-512x512.pth",
|
23 |
+
enable_flash_attn=True,
|
24 |
+
enable_layernorm_kernel=True,
|
25 |
+
)
|
26 |
+
mask_ratios = {
|
27 |
+
"mask_no": 0.5,
|
28 |
+
"mask_random": 0.29,
|
29 |
+
"mask_head": 0.07,
|
30 |
+
"mask_tail": 0.07,
|
31 |
+
"mask_head_tail": 0.07,
|
32 |
+
}
|
33 |
+
vae = dict(
|
34 |
+
type="VideoAutoencoderKL",
|
35 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
36 |
+
)
|
37 |
+
text_encoder = dict(
|
38 |
+
type="t5",
|
39 |
+
from_pretrained="DeepFloyd/t5-v1_1-xxl",
|
40 |
+
model_max_length=120,
|
41 |
+
shardformer=True,
|
42 |
+
)
|
43 |
+
scheduler = dict(
|
44 |
+
type="iddpm-speed",
|
45 |
+
timestep_respacing="",
|
46 |
+
)
|
47 |
+
|
48 |
+
# Others
|
49 |
+
seed = 42
|
50 |
+
outputs = "outputs"
|
51 |
+
wandb = False
|
52 |
+
|
53 |
+
epochs = 1000
|
54 |
+
log_every = 10
|
55 |
+
ckpt_every = 1000
|
56 |
+
load = None
|
57 |
+
|
58 |
+
batch_size = 8
|
59 |
+
lr = 2e-5
|
60 |
+
grad_clip = 1.0
|
configs/opensora/train/16x256x256.py
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Define dataset
|
2 |
+
dataset = dict(
|
3 |
+
type="VideoTextDataset",
|
4 |
+
data_path=None,
|
5 |
+
num_frames=16,
|
6 |
+
frame_interval=3,
|
7 |
+
image_size=(256, 256),
|
8 |
+
)
|
9 |
+
|
10 |
+
# Define acceleration
|
11 |
+
num_workers = 4
|
12 |
+
dtype = "bf16"
|
13 |
+
grad_checkpoint = True
|
14 |
+
plugin = "zero2"
|
15 |
+
sp_size = 1
|
16 |
+
|
17 |
+
# Define model
|
18 |
+
model = dict(
|
19 |
+
type="STDiT-XL/2",
|
20 |
+
space_scale=0.5,
|
21 |
+
time_scale=1.0,
|
22 |
+
from_pretrained="PixArt-XL-2-512x512.pth",
|
23 |
+
enable_flash_attn=True,
|
24 |
+
enable_layernorm_kernel=True,
|
25 |
+
)
|
26 |
+
vae = dict(
|
27 |
+
type="VideoAutoencoderKL",
|
28 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
29 |
+
)
|
30 |
+
text_encoder = dict(
|
31 |
+
type="t5",
|
32 |
+
from_pretrained="DeepFloyd/t5-v1_1-xxl",
|
33 |
+
model_max_length=120,
|
34 |
+
shardformer=True,
|
35 |
+
)
|
36 |
+
scheduler = dict(
|
37 |
+
type="iddpm",
|
38 |
+
timestep_respacing="",
|
39 |
+
)
|
40 |
+
|
41 |
+
# Others
|
42 |
+
seed = 42
|
43 |
+
outputs = "outputs"
|
44 |
+
wandb = False
|
45 |
+
|
46 |
+
epochs = 1000
|
47 |
+
log_every = 10
|
48 |
+
ckpt_every = 1000
|
49 |
+
load = None
|
50 |
+
|
51 |
+
batch_size = 8
|
52 |
+
lr = 2e-5
|
53 |
+
grad_clip = 1.0
|
configs/opensora/train/16x512x512.py
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Define dataset
|
2 |
+
dataset = dict(
|
3 |
+
type="VideoTextDataset",
|
4 |
+
data_path=None,
|
5 |
+
num_frames=16,
|
6 |
+
frame_interval=3,
|
7 |
+
image_size=(512, 512),
|
8 |
+
)
|
9 |
+
|
10 |
+
# Define acceleration
|
11 |
+
num_workers = 4
|
12 |
+
dtype = "bf16"
|
13 |
+
grad_checkpoint = True
|
14 |
+
plugin = "zero2"
|
15 |
+
sp_size = 1
|
16 |
+
|
17 |
+
# Define model
|
18 |
+
model = dict(
|
19 |
+
type="STDiT-XL/2",
|
20 |
+
space_scale=1.0,
|
21 |
+
time_scale=1.0,
|
22 |
+
from_pretrained=None,
|
23 |
+
enable_flash_attn=True,
|
24 |
+
enable_layernorm_kernel=True,
|
25 |
+
)
|
26 |
+
vae = dict(
|
27 |
+
type="VideoAutoencoderKL",
|
28 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
29 |
+
micro_batch_size=128,
|
30 |
+
)
|
31 |
+
text_encoder = dict(
|
32 |
+
type="t5",
|
33 |
+
from_pretrained="DeepFloyd/t5-v1_1-xxl",
|
34 |
+
model_max_length=120,
|
35 |
+
shardformer=True,
|
36 |
+
)
|
37 |
+
scheduler = dict(
|
38 |
+
type="iddpm",
|
39 |
+
timestep_respacing="",
|
40 |
+
)
|
41 |
+
|
42 |
+
# Others
|
43 |
+
seed = 42
|
44 |
+
outputs = "outputs"
|
45 |
+
wandb = False
|
46 |
+
|
47 |
+
epochs = 1000
|
48 |
+
log_every = 10
|
49 |
+
ckpt_every = 500
|
50 |
+
load = None
|
51 |
+
|
52 |
+
batch_size = 8
|
53 |
+
lr = 2e-5
|
54 |
+
grad_clip = 1.0
|
configs/opensora/train/360x512x512.py
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Define dataset
|
2 |
+
dataset = dict(
|
3 |
+
type="VideoTextDataset",
|
4 |
+
data_path=None,
|
5 |
+
num_frames=360,
|
6 |
+
frame_interval=3,
|
7 |
+
image_size=(512, 512),
|
8 |
+
)
|
9 |
+
|
10 |
+
# Define acceleration
|
11 |
+
num_workers = 4
|
12 |
+
dtype = "bf16"
|
13 |
+
grad_checkpoint = True
|
14 |
+
plugin = "zero2"
|
15 |
+
sp_size = 1
|
16 |
+
|
17 |
+
# Define acceleration
|
18 |
+
dtype = "bf16"
|
19 |
+
grad_checkpoint = True
|
20 |
+
plugin = "zero2-seq"
|
21 |
+
sp_size = 2
|
22 |
+
|
23 |
+
# Define model
|
24 |
+
model = dict(
|
25 |
+
type="STDiT-XL/2",
|
26 |
+
space_scale=1.0,
|
27 |
+
time_scale=2 / 3,
|
28 |
+
from_pretrained=None,
|
29 |
+
enable_flash_attn=True,
|
30 |
+
enable_layernorm_kernel=True,
|
31 |
+
enable_sequence_parallelism=True, # enable sq here
|
32 |
+
)
|
33 |
+
vae = dict(
|
34 |
+
type="VideoAutoencoderKL",
|
35 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
36 |
+
micro_batch_size=128,
|
37 |
+
)
|
38 |
+
text_encoder = dict(
|
39 |
+
type="t5",
|
40 |
+
from_pretrained="DeepFloyd/t5-v1_1-xxl",
|
41 |
+
model_max_length=120,
|
42 |
+
shardformer=True,
|
43 |
+
)
|
44 |
+
scheduler = dict(
|
45 |
+
type="iddpm",
|
46 |
+
timestep_respacing="",
|
47 |
+
)
|
48 |
+
|
49 |
+
# Others
|
50 |
+
seed = 42
|
51 |
+
outputs = "outputs"
|
52 |
+
wandb = False
|
53 |
+
|
54 |
+
epochs = 1000
|
55 |
+
log_every = 10
|
56 |
+
ckpt_every = 250
|
57 |
+
load = None
|
58 |
+
|
59 |
+
batch_size = 1
|
60 |
+
lr = 2e-5
|
61 |
+
grad_clip = 1.0
|
configs/opensora/train/64x512x512-sp.py
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Define dataset
|
2 |
+
dataset = dict(
|
3 |
+
type="VideoTextDataset",
|
4 |
+
data_path=None,
|
5 |
+
num_frames=16,
|
6 |
+
frame_interval=3,
|
7 |
+
image_size=(512, 512),
|
8 |
+
)
|
9 |
+
|
10 |
+
# Define acceleration
|
11 |
+
num_workers = 4
|
12 |
+
dtype = "bf16"
|
13 |
+
grad_checkpoint = True
|
14 |
+
plugin = "zero2"
|
15 |
+
sp_size = 2
|
16 |
+
|
17 |
+
# Define model
|
18 |
+
model = dict(
|
19 |
+
type="STDiT-XL/2",
|
20 |
+
space_scale=1.0,
|
21 |
+
time_scale=2 / 3,
|
22 |
+
from_pretrained=None,
|
23 |
+
enable_flash_attn=True,
|
24 |
+
enable_layernorm_kernel=True,
|
25 |
+
enable_sequence_parallelism=True, # enable sq here
|
26 |
+
)
|
27 |
+
vae = dict(
|
28 |
+
type="VideoAutoencoderKL",
|
29 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
30 |
+
)
|
31 |
+
text_encoder = dict(
|
32 |
+
type="t5",
|
33 |
+
from_pretrained="DeepFloyd/t5-v1_1-xxl",
|
34 |
+
model_max_length=120,
|
35 |
+
shardformer=True,
|
36 |
+
)
|
37 |
+
scheduler = dict(
|
38 |
+
type="iddpm",
|
39 |
+
timestep_respacing="",
|
40 |
+
)
|
41 |
+
|
42 |
+
# Others
|
43 |
+
seed = 42
|
44 |
+
outputs = "outputs"
|
45 |
+
wandb = False
|
46 |
+
|
47 |
+
epochs = 1000
|
48 |
+
log_every = 10
|
49 |
+
ckpt_every = 1000
|
50 |
+
load = None
|
51 |
+
|
52 |
+
batch_size = 1
|
53 |
+
lr = 2e-5
|
54 |
+
grad_clip = 1.0
|
configs/opensora/train/64x512x512.py
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Define dataset
|
2 |
+
dataset = dict(
|
3 |
+
type="VideoTextDataset",
|
4 |
+
data_path=None,
|
5 |
+
num_frames=64,
|
6 |
+
frame_interval=3,
|
7 |
+
image_size=(512, 512),
|
8 |
+
)
|
9 |
+
|
10 |
+
# Define acceleration
|
11 |
+
num_workers = 4
|
12 |
+
dtype = "bf16"
|
13 |
+
grad_checkpoint = True
|
14 |
+
plugin = "zero2"
|
15 |
+
sp_size = 1
|
16 |
+
|
17 |
+
# Define model
|
18 |
+
model = dict(
|
19 |
+
type="STDiT-XL/2",
|
20 |
+
space_scale=1.0,
|
21 |
+
time_scale=2 / 3,
|
22 |
+
from_pretrained=None,
|
23 |
+
enable_flash_attn=True,
|
24 |
+
enable_layernorm_kernel=True,
|
25 |
+
)
|
26 |
+
vae = dict(
|
27 |
+
type="VideoAutoencoderKL",
|
28 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
29 |
+
micro_batch_size=64,
|
30 |
+
)
|
31 |
+
text_encoder = dict(
|
32 |
+
type="t5",
|
33 |
+
from_pretrained="DeepFloyd/t5-v1_1-xxl",
|
34 |
+
model_max_length=120,
|
35 |
+
shardformer=True,
|
36 |
+
)
|
37 |
+
scheduler = dict(
|
38 |
+
type="iddpm",
|
39 |
+
timestep_respacing="",
|
40 |
+
)
|
41 |
+
|
42 |
+
# Others
|
43 |
+
seed = 42
|
44 |
+
outputs = "outputs"
|
45 |
+
wandb = False
|
46 |
+
|
47 |
+
epochs = 1000
|
48 |
+
log_every = 10
|
49 |
+
ckpt_every = 250
|
50 |
+
load = None
|
51 |
+
|
52 |
+
batch_size = 4
|
53 |
+
lr = 2e-5
|
54 |
+
grad_clip = 1.0
|
configs/pixart/inference/16x256x256.py
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
num_frames = 16
|
2 |
+
fps = 8
|
3 |
+
image_size = (256, 256)
|
4 |
+
|
5 |
+
# Define model
|
6 |
+
model = dict(
|
7 |
+
type="PixArt-XL/2",
|
8 |
+
space_scale=0.5,
|
9 |
+
time_scale=1.0,
|
10 |
+
from_pretrained="outputs/098-F16S3-PixArt-XL-2/epoch7-global_step30000/model_ckpt.pt",
|
11 |
+
)
|
12 |
+
vae = dict(
|
13 |
+
type="VideoAutoencoderKL",
|
14 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
15 |
+
)
|
16 |
+
text_encoder = dict(
|
17 |
+
type="t5",
|
18 |
+
from_pretrained="DeepFloyd/t5-v1_1-xxl",
|
19 |
+
model_max_length=120,
|
20 |
+
)
|
21 |
+
scheduler = dict(
|
22 |
+
type="dpm-solver",
|
23 |
+
num_sampling_steps=20,
|
24 |
+
cfg_scale=7.0,
|
25 |
+
)
|
26 |
+
dtype = "bf16"
|
27 |
+
|
28 |
+
# Others
|
29 |
+
batch_size = 2
|
30 |
+
seed = 42
|
31 |
+
prompt_path = "./assets/texts/t2v_samples.txt"
|
32 |
+
save_dir = "./samples/samples/"
|
configs/pixart/inference/1x1024MS.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
num_frames = 1
|
2 |
+
fps = 1
|
3 |
+
image_size = (1920, 512)
|
4 |
+
multi_resolution = "PixArtMS"
|
5 |
+
|
6 |
+
# Define model
|
7 |
+
model = dict(
|
8 |
+
type="PixArtMS-XL/2",
|
9 |
+
space_scale=2.0,
|
10 |
+
time_scale=1.0,
|
11 |
+
no_temporal_pos_emb=True,
|
12 |
+
from_pretrained="PixArt-XL-2-1024-MS.pth",
|
13 |
+
)
|
14 |
+
vae = dict(
|
15 |
+
type="VideoAutoencoderKL",
|
16 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
17 |
+
)
|
18 |
+
text_encoder = dict(
|
19 |
+
type="t5",
|
20 |
+
from_pretrained="DeepFloyd/t5-v1_1-xxl",
|
21 |
+
model_max_length=120,
|
22 |
+
)
|
23 |
+
scheduler = dict(
|
24 |
+
type="dpm-solver",
|
25 |
+
num_sampling_steps=20,
|
26 |
+
cfg_scale=7.0,
|
27 |
+
)
|
28 |
+
dtype = "bf16"
|
29 |
+
|
30 |
+
# Others
|
31 |
+
batch_size = 2
|
32 |
+
seed = 42
|
33 |
+
prompt_path = "./assets/texts/t2i_samples.txt"
|
34 |
+
save_dir = "./samples/samples/"
|
configs/pixart/inference/1x256x256.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
num_frames = 1
|
2 |
+
fps = 1
|
3 |
+
image_size = (256, 256)
|
4 |
+
|
5 |
+
# Define model
|
6 |
+
model = dict(
|
7 |
+
type="PixArt-XL/2",
|
8 |
+
space_scale=1.0,
|
9 |
+
time_scale=1.0,
|
10 |
+
no_temporal_pos_emb=True,
|
11 |
+
from_pretrained="PixArt-XL-2-256x256.pth",
|
12 |
+
)
|
13 |
+
vae = dict(
|
14 |
+
type="VideoAutoencoderKL",
|
15 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
16 |
+
)
|
17 |
+
text_encoder = dict(
|
18 |
+
type="t5",
|
19 |
+
from_pretrained="DeepFloyd/t5-v1_1-xxl",
|
20 |
+
model_max_length=120,
|
21 |
+
)
|
22 |
+
scheduler = dict(
|
23 |
+
type="dpm-solver",
|
24 |
+
num_sampling_steps=20,
|
25 |
+
cfg_scale=7.0,
|
26 |
+
)
|
27 |
+
dtype = "bf16"
|
28 |
+
|
29 |
+
# Others
|
30 |
+
batch_size = 2
|
31 |
+
seed = 42
|
32 |
+
prompt_path = "./assets/texts/t2i_samples.txt"
|
33 |
+
save_dir = "./samples/samples/"
|
configs/pixart/inference/1x512x512.py
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
num_frames = 1
|
2 |
+
fps = 1
|
3 |
+
image_size = (512, 512)
|
4 |
+
|
5 |
+
# Define model
|
6 |
+
model = dict(
|
7 |
+
type="PixArt-XL/2",
|
8 |
+
space_scale=1.0,
|
9 |
+
time_scale=1.0,
|
10 |
+
no_temporal_pos_emb=True,
|
11 |
+
from_pretrained="PixArt-XL-2-512x512.pth",
|
12 |
+
)
|
13 |
+
vae = dict(
|
14 |
+
type="VideoAutoencoderKL",
|
15 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
16 |
+
)
|
17 |
+
text_encoder = dict(
|
18 |
+
type="t5",
|
19 |
+
from_pretrained="DeepFloyd/t5-v1_1-xxl",
|
20 |
+
model_max_length=120,
|
21 |
+
)
|
22 |
+
scheduler = dict(
|
23 |
+
type="dpm-solver",
|
24 |
+
num_sampling_steps=20,
|
25 |
+
cfg_scale=7.0,
|
26 |
+
)
|
27 |
+
dtype = "bf16"
|
28 |
+
|
29 |
+
# prompt_path = "./assets/texts/t2i_samples.txt"
|
30 |
+
prompt = [
|
31 |
+
"Pirate ship trapped in a cosmic maelstrom nebula.",
|
32 |
+
"A small cactus with a happy face in the Sahara desert.",
|
33 |
+
"A small cactus with a sad face in the Sahara desert.",
|
34 |
+
]
|
35 |
+
|
36 |
+
# Others
|
37 |
+
batch_size = 2
|
38 |
+
seed = 42
|
39 |
+
save_dir = "./samples/samples/"
|
configs/pixart/train/16x256x256.py
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Define dataset
|
2 |
+
dataset = dict(
|
3 |
+
type="VideoTextDataset",
|
4 |
+
data_path=None,
|
5 |
+
num_frames=16,
|
6 |
+
frame_interval=3,
|
7 |
+
image_size=(256, 256),
|
8 |
+
)
|
9 |
+
|
10 |
+
# Define acceleration
|
11 |
+
num_workers = 4
|
12 |
+
dtype = "bf16"
|
13 |
+
grad_checkpoint = True
|
14 |
+
plugin = "zero2"
|
15 |
+
sp_size = 1
|
16 |
+
|
17 |
+
# Define model
|
18 |
+
model = dict(
|
19 |
+
type="PixArt-XL/2",
|
20 |
+
space_scale=0.5,
|
21 |
+
time_scale=1.0,
|
22 |
+
from_pretrained="PixArt-XL-2-512x512.pth",
|
23 |
+
enable_flash_attn=True,
|
24 |
+
enable_layernorm_kernel=True,
|
25 |
+
)
|
26 |
+
vae = dict(
|
27 |
+
type="VideoAutoencoderKL",
|
28 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
29 |
+
)
|
30 |
+
text_encoder = dict(
|
31 |
+
type="t5",
|
32 |
+
from_pretrained="DeepFloyd/t5-v1_1-xxl",
|
33 |
+
model_max_length=120,
|
34 |
+
shardformer=True,
|
35 |
+
)
|
36 |
+
scheduler = dict(
|
37 |
+
type="iddpm",
|
38 |
+
timestep_respacing="",
|
39 |
+
)
|
40 |
+
|
41 |
+
# Others
|
42 |
+
seed = 42
|
43 |
+
outputs = "outputs"
|
44 |
+
wandb = False
|
45 |
+
|
46 |
+
epochs = 1000
|
47 |
+
log_every = 10
|
48 |
+
ckpt_every = 1000
|
49 |
+
load = None
|
50 |
+
|
51 |
+
batch_size = 8
|
52 |
+
lr = 2e-5
|
53 |
+
grad_clip = 1.0
|
configs/pixart/train/1x512x512.py
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Define dataset
|
2 |
+
dataset = dict(
|
3 |
+
type="VideoTextDataset",
|
4 |
+
data_path=None,
|
5 |
+
num_frames=1,
|
6 |
+
frame_interval=3,
|
7 |
+
image_size=(512, 512),
|
8 |
+
)
|
9 |
+
|
10 |
+
# Define acceleration
|
11 |
+
num_workers = 4
|
12 |
+
dtype = "bf16"
|
13 |
+
grad_checkpoint = True
|
14 |
+
plugin = "zero2"
|
15 |
+
sp_size = 1
|
16 |
+
|
17 |
+
# Define model
|
18 |
+
model = dict(
|
19 |
+
type="PixArt-XL/2",
|
20 |
+
space_scale=1.0,
|
21 |
+
time_scale=1.0,
|
22 |
+
no_temporal_pos_emb=True,
|
23 |
+
from_pretrained="PixArt-XL-2-512x512.pth",
|
24 |
+
enable_flash_attn=True,
|
25 |
+
enable_layernorm_kernel=True,
|
26 |
+
)
|
27 |
+
vae = dict(
|
28 |
+
type="VideoAutoencoderKL",
|
29 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
30 |
+
)
|
31 |
+
text_encoder = dict(
|
32 |
+
type="t5",
|
33 |
+
from_pretrained="DeepFloyd/t5-v1_1-xxl",
|
34 |
+
model_max_length=120,
|
35 |
+
shardformer=True,
|
36 |
+
)
|
37 |
+
scheduler = dict(
|
38 |
+
type="iddpm",
|
39 |
+
timestep_respacing="",
|
40 |
+
)
|
41 |
+
|
42 |
+
# Others
|
43 |
+
seed = 42
|
44 |
+
outputs = "outputs"
|
45 |
+
wandb = False
|
46 |
+
|
47 |
+
epochs = 1000
|
48 |
+
log_every = 10
|
49 |
+
ckpt_every = 1000
|
50 |
+
load = None
|
51 |
+
|
52 |
+
batch_size = 32
|
53 |
+
lr = 2e-5
|
54 |
+
grad_clip = 1.0
|
configs/pixart/train/64x512x512.py
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Define dataset
|
2 |
+
dataset = dict(
|
3 |
+
type="VideoTextDataset",
|
4 |
+
data_path=None,
|
5 |
+
num_frames=64,
|
6 |
+
frame_interval=3,
|
7 |
+
image_size=(256, 256),
|
8 |
+
)
|
9 |
+
|
10 |
+
# Define acceleration
|
11 |
+
num_workers = 4
|
12 |
+
dtype = "bf16"
|
13 |
+
grad_checkpoint = True
|
14 |
+
plugin = "zero2"
|
15 |
+
sp_size = 1
|
16 |
+
|
17 |
+
|
18 |
+
# Define model
|
19 |
+
model = dict(
|
20 |
+
type="PixArt-XL/2",
|
21 |
+
space_scale=1.0,
|
22 |
+
time_scale=2 / 3,
|
23 |
+
from_pretrained=None,
|
24 |
+
enable_flash_attn=True,
|
25 |
+
enable_layernorm_kernel=True,
|
26 |
+
)
|
27 |
+
vae = dict(
|
28 |
+
type="VideoAutoencoderKL",
|
29 |
+
from_pretrained="stabilityai/sd-vae-ft-ema",
|
30 |
+
micro_batch_size=128,
|
31 |
+
)
|
32 |
+
text_encoder = dict(
|
33 |
+
type="t5",
|
34 |
+
from_pretrained="DeepFloyd/t5-v1_1-xxl",
|
35 |
+
model_max_length=120,
|
36 |
+
shardformer=True,
|
37 |
+
)
|
38 |
+
scheduler = dict(
|
39 |
+
type="iddpm",
|
40 |
+
timestep_respacing="",
|
41 |
+
)
|
42 |
+
|
43 |
+
# Others
|
44 |
+
seed = 42
|
45 |
+
outputs = "outputs"
|
46 |
+
wandb = False
|
47 |
+
|
48 |
+
epochs = 1000
|
49 |
+
log_every = 10
|
50 |
+
ckpt_every = 250
|
51 |
+
load = None
|
52 |
+
|
53 |
+
batch_size = 4
|
54 |
+
lr = 2e-5
|
55 |
+
grad_clip = 1.0
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
xformers
|
2 |
+
transformers
|
3 |
+
git+https://github.com/hpcaitech/Open-Sora.git#egg=opensora
|