[refactor]: migrate examples/scripts to typed VideoGenerator API; rename api/compat.py to api/translation.py

Move all examples/inference and scripts off the legacy
VideoGenerator.from_pretrained(model, **kwargs) +
generate_video(prompt, **kwargs) surface onto the typed
from_config(GeneratorConfig(...)) + generate(GenerationRequest(...))
convention, including the Kandinsky-5 and DreamX-World examples added
on main after the original migration. git-mv api/compat.py to
api/translation.py ('compat' implied a temporary shim; the forward
translation is its honest permanent role) and repoint all importers,
tests, and doc links.
This commit is contained in:
SolitaryThinker
2026-07-11 03:26:24 -07:00
parent 19a51a1fe6
commit bbbb7ab021
87 changed files with 2493 additions and 1461 deletions
+7 -4
View File
@@ -39,17 +39,20 @@ All you need to generate videos using multi-gpus from state-of-the-art diffusion
```python
from fastvideo import VideoGenerator
from fastvideo.api import EngineConfig, GenerationRequest, GeneratorConfig
def main():
generator = VideoGenerator.from_pretrained(
"Wan-AI/Wan2.1-T2V-1.3B-Diffusers",
num_gpus=1,
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path="Wan-AI/Wan2.1-T2V-1.3B-Diffusers",
engine=EngineConfig(num_gpus=1),
)
)
prompt = ("A curious raccoon peers through a vibrant field of yellow sunflowers, its eyes "
"wide with interest. The playful yet serene atmosphere is complemented by soft "
"natural light filtering through the petals. Mid-shot, warm and cheerful tones.")
video = generator.generate_video(prompt)
result = generator.generate(GenerationRequest(prompt=prompt))
if __name__ == "__main__":
main()
+23 -18
View File
@@ -1,6 +1,7 @@
from fastvideo import VideoGenerator
# from fastvideo.api.sampling_param import SamplingParam
from fastvideo.api import (
EngineConfig, GenerationRequest, GeneratorConfig, OffloadConfig, OutputConfig,
)
OUTPUT_PATH = "video_samples"
def main():
@@ -8,29 +9,32 @@ def main():
# model.
# If a local path is provided, FastVideo will make a best effort
# attempt to identify the optimal arguments.
generator = VideoGenerator.from_pretrained(
"Wan-AI/Wan2.1-T2V-1.3B-Diffusers",
# FastVideo will automatically handle distributed setup
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
dit_cpu_offload=False,
vae_cpu_offload=False,
text_encoder_cpu_offload=True,
pin_cpu_memory=True, # set to false if low CPU RAM or hit obscure "CUDA error: Invalid argument"
# image_encoder_cpu_offload=False,
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path="Wan-AI/Wan2.1-T2V-1.3B-Diffusers",
# FastVideo will automatically handle distributed setup
engine=EngineConfig(
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
offload=OffloadConfig(
dit=False,
vae=False,
text_encoder=True,
pin_cpu_memory=True, # set to false if low CPU RAM or hit obscure "CUDA error: Invalid argument"
# image_encoder=False,
),
),
)
)
# sampling_param = SamplingParam.from_pretrained("Wan-AI/Wan2.1-T2V-1.3B-Diffusers")
# sampling_param.num_frames = 45
# sampling_param.image_path = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/astronaut.jpg"
# Generate videos with the same simple API, regardless of GPU count
prompt = (
"A curious raccoon peers through a vibrant field of yellow sunflowers, its eyes "
"wide with interest. The playful yet serene atmosphere is complemented by soft "
"natural light filtering through the petals. Mid-shot, warm and cheerful tones."
)
video = generator.generate_video(prompt, output_path=OUTPUT_PATH, save_video=True)
# video = generator.generate_video(prompt, sampling_param=sampling_param, output_path="wan_t2v_videos/")
video = generator.generate(
GenerationRequest(prompt=prompt, output=OutputConfig(output_path=OUTPUT_PATH, save_video=True)))
# Generate another video with a different prompt, without reloading the
# model!
@@ -40,7 +44,8 @@ def main():
"the breeze, enhancing the lion's commanding presence. The tone is vibrant, "
"embodying the raw energy of the wild. Low angle, steady tracking shot, "
"cinematic.")
video2 = generator.generate_video(prompt2, output_path=OUTPUT_PATH, save_video=True)
video2 = generator.generate(
GenerationRequest(prompt=prompt2, output=OutputConfig(output_path=OUTPUT_PATH, save_video=True)))
if __name__ == "__main__":
+27 -19
View File
@@ -1,24 +1,30 @@
# SPDX-License-Identifier: Apache-2.0
from fastvideo import VideoGenerator
from fastvideo.api.sampling_param import SamplingParam
from fastvideo.api import (
EngineConfig, GenerationRequest, GeneratorConfig, InputConfig, OffloadConfig, OutputConfig,
)
def main():
# Point this to your local diffusers model dir (or replace with a HF model ID).
model_path = "KyleShao/Cosmos-Predict2.5-2B-Diffusers"
generator = VideoGenerator.from_pretrained(
model_path,
num_gpus=1,
use_fsdp_inference=False, # set True if GPU is out of memory
dit_cpu_offload=False,
vae_cpu_offload=False,
text_encoder_cpu_offload=True,
pin_cpu_memory=True,
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path=model_path,
engine=EngineConfig(
num_gpus=1,
use_fsdp_inference=False, # set True if GPU is out of memory
offload=OffloadConfig(
dit=False,
vae=False,
text_encoder=True,
pin_cpu_memory=True,
),
),
)
)
sampling_param = SamplingParam.from_pretrained(model_path)
# image2world example from official repo
image_path = "assets/images/bus_terminal.jpg"
@@ -33,13 +39,16 @@ def main():
"Overhead signage in Chinese characters remains illuminated, enhancing the vibrant, urban night scene."
)
generator.generate_video(
prompt,
sampling_param=sampling_param,
image_path=str(image_path),
num_cond_frames=1,
output_path="outputs_video/cosmos2_5_i2w.mp4",
save_video=True,
generator.generate(
GenerationRequest(
prompt=prompt,
inputs=InputConfig(image_path=str(image_path)),
output=OutputConfig(
output_path="outputs_video/cosmos2_5_i2w.mp4",
save_video=True,
),
extensions={"num_cond_frames": 1},
)
)
generator.shutdown()
@@ -47,4 +56,3 @@ def main():
if __name__ == "__main__":
main()
+25 -20
View File
@@ -1,24 +1,29 @@
from fastvideo import VideoGenerator
from fastvideo.api.sampling_param import SamplingParam
from fastvideo.api import (
EngineConfig, GenerationRequest, GeneratorConfig, OffloadConfig, OutputConfig,
)
def main():
# Point this to your local diffusers model dir (or replace with a HF model ID).
model_path = "KyleShao/Cosmos-Predict2.5-2B-Diffusers"
generator = VideoGenerator.from_pretrained(
model_path,
num_gpus=1,
use_fsdp_inference=False, # set True if GPU is out of memory
dit_cpu_offload=False,
vae_cpu_offload=False,
text_encoder_cpu_offload=True,
pin_cpu_memory=True,
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path=model_path,
engine=EngineConfig(
num_gpus=1,
use_fsdp_inference=False, # set True if GPU is out of memory
offload=OffloadConfig(
dit=False,
vae=False,
text_encoder=True,
pin_cpu_memory=True,
),
),
)
)
# Load default sampling parameters (negative_prompt, resolution, steps, etc.)
sampling_param = SamplingParam.from_pretrained(model_path)
prompt = (
"A high-definition video captures the precision of robotic welding in an industrial setting. "
"The first frame showcases a robotic arm, equipped with a welding torch, positioned over a large metal structure. "
@@ -34,11 +39,14 @@ def main():
"underscoring the ongoing nature of the welding operation."
)
generator.generate_video(
prompt,
sampling_param=sampling_param,
output_path="outputs_video/cosmos2_5_t2w.mp4",
save_video=True,
generator.generate(
GenerationRequest(
prompt=prompt,
output=OutputConfig(
output_path="outputs_video/cosmos2_5_t2w.mp4",
save_video=True,
),
)
)
generator.shutdown()
@@ -46,6 +54,3 @@ def main():
if __name__ == "__main__":
main()
+28 -21
View File
@@ -1,23 +1,29 @@
# SPDX-License-Identifier: Apache-2.0
from fastvideo import VideoGenerator
from fastvideo.api.sampling_param import SamplingParam
from fastvideo.api import (
EngineConfig, GenerationRequest, GeneratorConfig, InputConfig,
OffloadConfig, OutputConfig,
)
def main():
# Point this to your local diffusers model dir (or replace with a HF model ID).
model_path = "KyleShao/Cosmos-Predict2.5-2B-Diffusers"
generator = VideoGenerator.from_pretrained(
model_path,
num_gpus=1,
use_fsdp_inference=False, # set True if GPU is out of memory
dit_cpu_offload=False,
vae_cpu_offload=False,
text_encoder_cpu_offload=True,
pin_cpu_memory=True,
)
sampling_param = SamplingParam.from_pretrained(model_path)
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path=model_path,
engine=EngineConfig(
num_gpus=1,
use_fsdp_inference=False, # set True if GPU is out of memory
offload=OffloadConfig(
dit=False,
vae=False,
text_encoder=True,
pin_cpu_memory=True,
),
),
))
# video2world example from official repo
video_path = "assets/videos/robot_pouring.mp4"
@@ -36,18 +42,19 @@ def main():
"The final frame captures the robotic arm with the pitcher finishing the pour, with the glass now filled to a higher level, while the pitcher is slightly tilted but still held securely by the gripper."
)
generator.generate_video(
prompt,
sampling_param=sampling_param,
video_path=str(video_path),
num_cond_frames=1,
output_path="outputs_video/cosmos2_5_v2w.mp4",
save_video=True,
)
generator.generate(
GenerationRequest(
prompt=prompt,
inputs=InputConfig(video_path=str(video_path)),
output=OutputConfig(
output_path="outputs_video/cosmos2_5_v2w.mp4",
save_video=True,
),
extensions={"num_cond_frames": 1},
))
generator.shutdown()
if __name__ == "__main__":
main()
+32 -19
View File
@@ -2,7 +2,9 @@ import os
import time
from fastvideo import VideoGenerator
from fastvideo.api.sampling_param import SamplingParam
from fastvideo.api import (EngineConfig, GenerationRequest, GeneratorConfig,
OffloadConfig, OutputConfig, PipelineSelection,
SamplingConfig)
OUTPUT_PATH = "video_samples_dmd2"
def main():
@@ -10,30 +12,36 @@ def main():
load_start_time = time.perf_counter()
model_name = "FastVideo/FastWan2.1-T2V-1.3B-Diffusers"
generator = VideoGenerator.from_pretrained(
model_name,
# FastVideo will automatically handle distributed setup
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
# Adjust these offload parameters if you have < 32GB of VRAM
text_encoder_cpu_offload=True,
pin_cpu_memory=True, # set to false if low CPU RAM or hit obscure "CUDA error: Invalid argument"
dit_cpu_offload=False,
vae_cpu_offload=False,
VSA_sparsity=0.8,
)
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path=model_name,
engine=EngineConfig(
# FastVideo will automatically handle distributed setup
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
# Adjust these offload parameters if you have < 32GB of VRAM
offload=OffloadConfig(
text_encoder=True,
pin_cpu_memory=True, # set to false if low CPU RAM or hit obscure "CUDA error: Invalid argument"
dit=False,
vae=False,
),
),
pipeline=PipelineSelection(experimental={"VSA_sparsity": 0.8}),
))
load_end_time = time.perf_counter()
load_time = load_end_time - load_start_time
sampling_param = SamplingParam.from_pretrained(model_name)
sampling_param.num_frames = 81
prompt = (
"A neon-lit alley in futuristic Tokyo during a heavy rainstorm at night. The puddles reflect glowing signs in kanji, advertising ramen, karaoke, and VR arcades. A woman in a translucent raincoat walks briskly with an LED umbrella. Steam rises from a street food cart, and a cat darts across the screen. Raindrops are visible on the camera lens, creating a cinematic bokeh effect."
)
start_time = time.perf_counter()
video = generator.generate_video(prompt, output_path=OUTPUT_PATH, save_video=True, sampling_param=sampling_param)
video = generator.generate(
GenerationRequest(
prompt=prompt,
sampling=SamplingConfig(num_frames=81),
output=OutputConfig(output_path=OUTPUT_PATH, save_video=True),
))
end_time = time.perf_counter()
gen_time = end_time - start_time
@@ -46,7 +54,12 @@ def main():
"embodying the raw energy of the wild. Low angle, steady tracking shot, "
"cinematic.")
start_time = time.perf_counter()
video2 = generator.generate_video(prompt2, output_path=OUTPUT_PATH, save_video=True, num_frames=81)
video2 = generator.generate(
GenerationRequest(
prompt=prompt2,
sampling=SamplingConfig(num_frames=81),
output=OutputConfig(output_path=OUTPUT_PATH, save_video=True),
))
end_time = time.perf_counter()
gen_time2 = end_time - start_time
+42 -27
View File
@@ -1,6 +1,9 @@
import os
from fastvideo import VideoGenerator
from fastvideo.api import (ComponentConfig, EngineConfig, GenerationRequest,
GeneratorConfig, InputConfig, OffloadConfig,
OutputConfig, PipelineSelection, SamplingConfig)
OUTPUT_PATH = os.getenv("DREAMX_WORLD_OUTPUT_PATH", "video_samples_dreamx_world")
@@ -16,16 +19,22 @@ def _env_float(name: str, default: float) -> float:
def main():
model_name = os.getenv("DREAMX_WORLD_MODEL_DIR", "FastVideo/DreamX-World-5B-Cam-Diffusers")
generator = VideoGenerator.from_pretrained(
model_name,
num_gpus=1,
use_fsdp_inference=False,
dit_cpu_offload=False,
vae_cpu_offload=True,
text_encoder_cpu_offload=True,
pin_cpu_memory=False,
override_pipeline_cls_name="DreamXWorldPipeline",
)
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path=model_name,
engine=EngineConfig(
num_gpus=1,
use_fsdp_inference=False,
offload=OffloadConfig(
dit=False,
vae=True,
text_encoder=True,
pin_cpu_memory=False,
),
),
pipeline=PipelineSelection(
components=ComponentConfig(override_pipeline_cls_name="DreamXWorldPipeline"), ),
))
prompt = os.getenv(
"DREAMX_WORLD_PROMPT",
@@ -37,25 +46,31 @@ def main():
"https://huggingface.co/datasets/YiYiXu/testing-images/resolve/main/wan_i2v_input.JPG",
)
kwargs = {
"output_path": OUTPUT_PATH,
"save_video": os.getenv("DREAMX_WORLD_SAVE_VIDEO", "1") != "0",
"height": _env_int("DREAMX_WORLD_HEIGHT", 480),
"width": _env_int("DREAMX_WORLD_WIDTH", 832),
"num_frames": _env_int("DREAMX_WORLD_NUM_FRAMES", 161),
"num_inference_steps": _env_int("DREAMX_WORLD_STEPS", 30),
"guidance_scale": _env_float("DREAMX_WORLD_GUIDANCE", 5.0),
"action_list": os.getenv("DREAMX_WORLD_ACTIONS", "w,d,w").split(","),
"action_speed_list": [
float(value)
for value in os.getenv("DREAMX_WORLD_ACTION_SPEEDS", "4.0,2.0,4.0").split(",")
],
}
if image_path:
kwargs["image_path"] = image_path
request = GenerationRequest(
prompt=prompt,
inputs=InputConfig(image_path=image_path or None),
sampling=SamplingConfig(
height=_env_int("DREAMX_WORLD_HEIGHT", 480),
width=_env_int("DREAMX_WORLD_WIDTH", 832),
num_frames=_env_int("DREAMX_WORLD_NUM_FRAMES", 161),
num_inference_steps=_env_int("DREAMX_WORLD_STEPS", 30),
guidance_scale=_env_float("DREAMX_WORLD_GUIDANCE", 5.0),
),
output=OutputConfig(
output_path=OUTPUT_PATH,
save_video=os.getenv("DREAMX_WORLD_SAVE_VIDEO", "1") != "0",
),
extensions={
"action_list": os.getenv("DREAMX_WORLD_ACTIONS", "w,d,w").split(","),
"action_speed_list": [
float(value)
for value in os.getenv("DREAMX_WORLD_ACTION_SPEEDS", "4.0,2.0,4.0").split(",")
],
},
)
try:
generator.generate_video(prompt, **kwargs)
generator.generate(request)
finally:
generator.shutdown()
+40 -21
View File
@@ -26,6 +26,15 @@ import os
import torch
from fastvideo import VideoGenerator
from fastvideo.api import (
EngineConfig,
GenerationRequest,
GeneratorConfig,
InputConfig,
OffloadConfig,
OutputConfig,
SamplingConfig,
)
from fastvideo.models.camera import create_camera_trajectory
# Model configuration (use GAMECRAFT_MODEL_PATH for local weights)
@@ -55,14 +64,20 @@ OUTPUT_PATH = "video_samples_gamecraft"
def main():
# Initialize generator
# FastVideo will automatically download weights from HuggingFace
generator = VideoGenerator.from_pretrained(
MODEL_PATH,
num_gpus=1,
use_fsdp_inference=True,
dit_cpu_offload=True,
vae_cpu_offload=True,
text_encoder_cpu_offload=True,
pin_cpu_memory=True,
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path=MODEL_PATH,
engine=EngineConfig(
num_gpus=1,
use_fsdp_inference=True,
offload=OffloadConfig(
dit=True,
vae=True,
text_encoder=True,
pin_cpu_memory=True,
),
),
)
)
# Video parameters
@@ -96,23 +111,27 @@ def main():
prompt = DEFAULT_I2V_PROMPT if is_i2v else DEFAULT_PROMPTS["temple"]
print(f"Mode: {'I2V' if is_i2v else 'T2V'}, prompt: {prompt[:60]}...")
gen_kw = dict(
request = GenerationRequest(
prompt=prompt,
negative_prompt="",
camera_states=camera_states,
height=height,
width=width,
num_frames=num_frames,
num_inference_steps=50,
guidance_scale=6.0,
seed=42,
fps=24,
output_path=OUTPUT_PATH,
save_video=True,
sampling=SamplingConfig(
height=height,
width=width,
num_frames=num_frames,
num_inference_steps=50,
guidance_scale=6.0,
seed=42,
fps=24,
),
output=OutputConfig(
output_path=OUTPUT_PATH,
save_video=True,
),
extensions={"camera_states": camera_states},
)
if is_i2v:
gen_kw["image_path"] = image_path
generator.generate_video(**gen_kw)
request.inputs = InputConfig(image_path=image_path)
generator.generate(request)
if __name__ == "__main__":
+44 -26
View File
@@ -22,6 +22,10 @@ Requirements:
import argparse
from fastvideo import VideoGenerator
from fastvideo.api import (
EngineConfig, GenerationRequest, GeneratorConfig, InputConfig,
OffloadConfig, OutputConfig, SamplingConfig,
)
def main():
@@ -74,33 +78,47 @@ def main():
parser.add_argument("--seed", type=int, default=42)
args = parser.parse_args()
generator = VideoGenerator.from_pretrained(
args.model_path,
num_gpus=1,
use_fsdp_inference=False,
dit_cpu_offload=False,
vae_cpu_offload=True,
text_encoder_cpu_offload=True,
pin_cpu_memory=True,
)
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path=args.model_path,
engine=EngineConfig(
num_gpus=1,
use_fsdp_inference=False,
offload=OffloadConfig(
dit=False,
vae=True,
text_encoder=True,
pin_cpu_memory=True,
),
),
))
video = generator.generate_video(
args.prompt,
negative_prompt=args.negative_prompt,
image_path=args.image_path,
trajectory_type=args.trajectory,
movement_distance=args.movement_distance,
camera_rotation=args.camera_rotation,
height=args.height,
width=args.width,
num_frames=args.num_frames,
num_inference_steps=args.num_inference_steps,
guidance_scale=args.guidance_scale,
fps=24,
seed=args.seed,
output_path=args.output_path,
save_video=True,
)
video = generator.generate(
GenerationRequest(
prompt=args.prompt,
negative_prompt=args.negative_prompt,
inputs=InputConfig(
image_path=args.image_path,
),
sampling=SamplingConfig(
height=args.height,
width=args.width,
num_frames=args.num_frames,
num_inference_steps=args.num_inference_steps,
guidance_scale=args.guidance_scale,
fps=24,
seed=args.seed,
),
output=OutputConfig(
output_path=args.output_path,
save_video=True,
),
extensions={
"trajectory_type": args.trajectory,
"movement_distance": args.movement_distance,
"camera_rotation": args.camera_rotation,
},
))
generator.shutdown()
+35 -14
View File
@@ -1,6 +1,13 @@
from fastvideo import VideoGenerator
from fastvideo.api import (
EngineConfig,
GenerationRequest,
GeneratorConfig,
OffloadConfig,
OutputConfig,
SamplingConfig,
)
import json
# from fastvideo.api.sampling_param import SamplingParam
OUTPUT_PATH = "video_samples_hy15"
def main():
@@ -8,17 +15,21 @@ def main():
# model.
# If a local path is provided, FastVideo will make a best effort
# attempt to identify the optimal arguments.
generator = VideoGenerator.from_pretrained(
"hunyuanvideo-community/HunyuanVideo-1.5-Diffusers-480p_t2v",
generator = VideoGenerator.from_config(GeneratorConfig(
model_path="hunyuanvideo-community/HunyuanVideo-1.5-Diffusers-480p_t2v",
# FastVideo will automatically handle distributed setup
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
dit_cpu_offload=True,
vae_cpu_offload=True,
text_encoder_cpu_offload=True,
pin_cpu_memory=True, # set to false if low CPU RAM or hit obscure "CUDA error: Invalid argument"
# image_encoder_cpu_offload=False,
)
engine=EngineConfig(
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
offload=OffloadConfig(
dit=True,
vae=True,
text_encoder=True,
pin_cpu_memory=True, # set to false if low CPU RAM or hit obscure "CUDA error: Invalid argument"
# image_encoder=False,
),
),
))
prompt = (
"A curious raccoon peers through a vibrant field of yellow sunflowers, its eyes "
@@ -26,7 +37,12 @@ def main():
"natural light filtering through the petals. Mid-shot, warm and cheerful tones."
)
video = generator.generate_video(prompt, output_path=OUTPUT_PATH, save_video=True, negative_prompt="", num_frames=81, fps=16)
generator.generate(GenerationRequest(
prompt=prompt,
negative_prompt="",
sampling=SamplingConfig(num_frames=81, fps=16),
output=OutputConfig(output_path=OUTPUT_PATH, save_video=True),
))
prompt2 = (
"A majestic lion strides across the golden savanna, its powerful frame "
@@ -35,8 +51,13 @@ def main():
"embodying the raw energy of the wild. Low angle, steady tracking shot, "
"cinematic.")
video2 = generator.generate_video(prompt2, output_path=OUTPUT_PATH, save_video=True, negative_prompt="", num_frames=81, fps=16)
generator.generate(GenerationRequest(
prompt=prompt2,
negative_prompt="",
sampling=SamplingConfig(num_frames=81, fps=16),
output=OutputConfig(output_path=OUTPUT_PATH, save_video=True),
))
if __name__ == "__main__":
main()
main()
+38 -14
View File
@@ -1,6 +1,12 @@
from fastvideo import VideoGenerator
from fastvideo.api import (
EngineConfig,
GenerationRequest,
GeneratorConfig,
OffloadConfig,
OutputConfig,
)
import json
# from fastvideo.api.sampling_param import SamplingParam
OUTPUT_PATH = "video_samples_hy15_1080p"
def main():
@@ -8,17 +14,23 @@ def main():
# model.
# If a local path is provided, FastVideo will make a best effort
# attempt to identify the optimal arguments.
generator = VideoGenerator.from_pretrained(
"weizhou03/HunyuanVideo-1.5-Diffusers-1080p-2SR", # 480p -> 720p -> 1080p
# or "weizhou03/HunyuanVideo-1.5-Diffusers-1080p" # 720p -> 1080p
# FastVideo will automatically handle distributed setup
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
dit_cpu_offload=True,
vae_cpu_offload=True,
text_encoder_cpu_offload=True,
pin_cpu_memory=True, # set to false if low CPU RAM or hit obscure "CUDA error: Invalid argument"
# image_encoder_cpu_offload=False,
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path="weizhou03/HunyuanVideo-1.5-Diffusers-1080p-2SR", # 480p -> 720p -> 1080p
# or "weizhou03/HunyuanVideo-1.5-Diffusers-1080p" # 720p -> 1080p
engine=EngineConfig(
# FastVideo will automatically handle distributed setup
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
offload=OffloadConfig(
dit=True,
vae=True,
text_encoder=True,
pin_cpu_memory=True, # set to false if low CPU RAM or hit obscure "CUDA error: Invalid argument"
# image_encoder=False,
),
),
)
)
prompt = (
@@ -27,7 +39,13 @@ def main():
"natural light filtering through the petals. Mid-shot, warm and cheerful tones."
)
video = generator.generate_video(prompt, output_path=OUTPUT_PATH, save_video=True, negative_prompt="")
video = generator.generate(
GenerationRequest(
prompt=prompt,
negative_prompt="",
output=OutputConfig(output_path=OUTPUT_PATH, save_video=True),
)
)
prompt2 = (
"A majestic lion strides across the golden savanna, its powerful frame "
@@ -36,7 +54,13 @@ def main():
"embodying the raw energy of the wild. Low angle, steady tracking shot, "
"cinematic.")
video2 = generator.generate_video(prompt2, output_path=OUTPUT_PATH, save_video=True, negative_prompt="")
video2 = generator.generate(
GenerationRequest(
prompt=prompt2,
negative_prompt="",
output=OutputConfig(output_path=OUTPUT_PATH, save_video=True),
)
)
if __name__ == "__main__":
+37 -23
View File
@@ -1,4 +1,6 @@
from fastvideo import VideoGenerator
from fastvideo.api import (EngineConfig, GenerationRequest, GeneratorConfig, InputConfig, OffloadConfig, OutputConfig,
SamplingConfig)
from fastvideo.models.dits.hyworld.resolution_utils import get_resolution_from_image
# Default prompt from HY-WorldPlay run.sh
@@ -31,33 +33,45 @@ def main():
# Initialize generator
print("\nInitializing VideoGenerator for HYWorld...")
generator = VideoGenerator.from_pretrained(
"FastVideo/HY-WorldPlay-Bidirectional-Diffusers",
num_gpus=1,
use_fsdp_inference=True,
dit_cpu_offload=True,
vae_cpu_offload=True,
text_encoder_cpu_offload=True,
pin_cpu_memory=True,
image_encoder_cpu_offload=True,
)
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path="FastVideo/HY-WorldPlay-Bidirectional-Diffusers",
engine=EngineConfig(
num_gpus=1,
use_fsdp_inference=True,
offload=OffloadConfig(
dit=True,
vae=True,
text_encoder=True,
pin_cpu_memory=True,
image_encoder=True,
),
),
))
# Generate video
# The pose string is automatically converted to camera matrices by the pipeline
print("\nGenerating video...")
generator.generate_video(
prompt=args.prompt,
image_path=args.image,
pose=args.pose, # Camera trajectory control
output_path=args.output_path,
save_video=True,
negative_prompt="",
num_frames=args.num_frames,
fps=24,
height=HEIGHT,
width=WIDTH,
seed=args.seed,
)
generator.generate(
GenerationRequest(
prompt=args.prompt,
negative_prompt="",
inputs=InputConfig(
image_path=args.image,
pose=args.pose, # Camera trajectory control
),
sampling=SamplingConfig(
num_frames=args.num_frames,
fps=24,
height=HEIGHT,
width=WIDTH,
seed=args.seed,
),
output=OutputConfig(
output_path=args.output_path,
save_video=True,
),
))
print(f"\nVideo saved to: {args.output_path}")
@@ -1,36 +1,43 @@
from fastvideo import VideoGenerator
from fastvideo.api import (EngineConfig, GenerationRequest, GeneratorConfig,
InputConfig, OffloadConfig, OutputConfig,
SamplingConfig)
OUTPUT_PATH = "video_samples_kandinsky5_i2v"
IMAGE_PATH = "assets/girl.png"
def main():
generator = VideoGenerator.from_pretrained(
"kandinskylab/Kandinsky-5.0-I2V-Pro-distilled-5s-Diffusers",
# "kandinskylab/Kandinsky-5.0-I2V-Pro-sft-5s-Diffusers"
# "kandinskylab/Kandinsky-5.0-I2V-Lite-5s-Diffusers"
num_gpus=1,
use_fsdp_inference=False,
dit_cpu_offload=False,
vae_cpu_offload=False,
text_encoder_cpu_offload=True,
pin_cpu_memory=True,
# image_encoder_cpu_offload=False,
)
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path="kandinskylab/Kandinsky-5.0-I2V-Pro-distilled-5s-Diffusers",
# "kandinskylab/Kandinsky-5.0-I2V-Pro-sft-5s-Diffusers"
# "kandinskylab/Kandinsky-5.0-I2V-Lite-5s-Diffusers"
engine=EngineConfig(
num_gpus=1,
use_fsdp_inference=False,
offload=OffloadConfig(
dit=False,
vae=False,
text_encoder=True,
pin_cpu_memory=True,
# image_encoder=False,
),
),
))
prompt = (
"A woman stands up and walks away"
)
_ = generator.generate_video(
prompt,
image_path=IMAGE_PATH,
output_path=OUTPUT_PATH,
save_video=True,
height=1024,
width=1024,
num_frames=121,
)
_ = generator.generate(
GenerationRequest(
prompt=prompt,
inputs=InputConfig(image_path=IMAGE_PATH),
sampling=SamplingConfig(height=1024, width=1024, num_frames=121),
output=OutputConfig(output_path=OUTPUT_PATH, save_video=True),
))
if __name__ == "__main__":
@@ -1,28 +1,41 @@
from fastvideo import VideoGenerator
from fastvideo.api import (EngineConfig, GenerationRequest, GeneratorConfig,
OffloadConfig, OutputConfig, SamplingConfig)
OUTPUT_PATH = "video_samples_kandinsky5_t2v"
def main():
generator = VideoGenerator.from_pretrained(
"kandinskylab/Kandinsky-5.0-T2V-Lite-sft-5s-Diffusers",
# "kandinskylab/Kandinsky-5.0-T2V-Pro-sft-5s-Diffusers"
# "kandinskylab/Kandinsky-5.0-T2V-Lite-distilled16steps-5s-Diffusers"
# "kandinskylab/Kandinsky-5.0-T2V-Pro-distilled-5s-Diffusers"
num_gpus=1,
use_fsdp_inference=False,
dit_cpu_offload=False,
vae_cpu_offload=False,
text_encoder_cpu_offload=True,
pin_cpu_memory=True,
# image_encoder_cpu_offload=False,
)
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path="kandinskylab/Kandinsky-5.0-T2V-Lite-sft-5s-Diffusers",
# "kandinskylab/Kandinsky-5.0-T2V-Pro-sft-5s-Diffusers"
# "kandinskylab/Kandinsky-5.0-T2V-Lite-distilled16steps-5s-Diffusers"
# "kandinskylab/Kandinsky-5.0-T2V-Pro-distilled-5s-Diffusers"
engine=EngineConfig(
num_gpus=1,
use_fsdp_inference=False,
offload=OffloadConfig(
dit=False,
vae=False,
text_encoder=True,
pin_cpu_memory=True,
# image_encoder=False,
),
),
))
prompt = (
"A curious raccoon peers through a vibrant field of yellow sunflowers, its eyes "
"wide with interest. The playful yet serene atmosphere is complemented by soft "
"natural light filtering through the petals. Mid-shot, warm and cheerful tones."
)
_ = generator.generate_video(prompt, output_path=OUTPUT_PATH, save_video=True,height=512, width=768, num_frames=121)
_ = generator.generate(
GenerationRequest(
prompt=prompt,
sampling=SamplingConfig(height=512, width=768, num_frames=121),
output=OutputConfig(output_path=OUTPUT_PATH, save_video=True),
))
prompt2 = (
"A majestic lion strides across the golden savanna, its powerful frame "
@@ -30,8 +43,13 @@ def main():
"the breeze, enhancing the lion's commanding presence. The tone is vibrant, "
"embodying the raw energy of the wild. Low angle, steady tracking shot, "
"cinematic.")
_ = generator.generate_video(prompt2, output_path=OUTPUT_PATH, save_video=True, height=512, width=768, num_frames=121)
_ = generator.generate(
GenerationRequest(
prompt=prompt2,
sampling=SamplingConfig(height=512, width=768, num_frames=121),
output=OutputConfig(output_path=OUTPUT_PATH, save_video=True),
))
if __name__ == "__main__":
main()
main()
@@ -1,24 +1,31 @@
from fastvideo import VideoGenerator
from fastvideo.api import (
EngineConfig, GenerationRequest, GeneratorConfig, InputConfig, OffloadConfig, OutputConfig, SamplingConfig,
)
from fastvideo.models.dits.lingbotworld.cam_utils import prepare_camera_embedding
# from fastvideo.api.sampling_param import SamplingParam
OUTPUT_PATH = "video_samples_lingbotworld"
def main():
# FastVideo will automatically use the optimal default arguments for the
# model.
# If a local path is provided, FastVideo will make a best effort
# attempt to identify the optimal arguments.
generator = VideoGenerator.from_pretrained(
"FastVideo/LingBot-World-Base-Cam-Diffusers",
# FastVideo will automatically handle distributed setup
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
dit_cpu_offload=True, # DiT need to be offloaded for MoE
vae_cpu_offload=False,
text_encoder_cpu_offload=True,
# Set pin_cpu_memory to false if CPU RAM is limited and there're no frequent CPU-GPU transfer
pin_cpu_memory=True,
# image_encoder_cpu_offload=False,
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path="FastVideo/LingBot-World-Base-Cam-Diffusers",
engine=EngineConfig(
# FastVideo will automatically handle distributed setup
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
offload=OffloadConfig(
dit=True, # DiT need to be offloaded for MoE
vae=False,
text_encoder=True,
# Set pin_cpu_memory to false if CPU RAM is limited and there're no frequent CPU-GPU transfer
pin_cpu_memory=True,
),
),
)
)
num_frames = 81
@@ -33,15 +40,23 @@ def main():
spatial_scale=8,
)
generator.generate_video(
prompt,
image_path=image_path,
output_path=OUTPUT_PATH,
save_video=True,
num_frames=num_frames,
height=480,
width=832,
c2ws_plucker_emb=c2ws_plucker_emb,
generator.generate(
GenerationRequest(
prompt=prompt,
inputs=InputConfig(
image_path=image_path,
c2ws_plucker_emb=c2ws_plucker_emb,
),
sampling=SamplingConfig(
num_frames=num_frames,
height=480,
width=832,
),
output=OutputConfig(
output_path=OUTPUT_PATH,
save_video=True,
),
)
)
+140 -95
View File
@@ -19,6 +19,10 @@ import glob
import os
from fastvideo import VideoGenerator
from fastvideo.api import (
ComponentConfig, EngineConfig, GenerationRequest, GeneratorConfig,
InputConfig, OffloadConfig, OutputConfig, PipelineSelection, SamplingConfig,
)
# Common prompts and settings matching the shell script examples
PROMPT = (
@@ -45,41 +49,50 @@ SEED = 42
def basic_generation():
"""
Run basic LongCat I2V generation (50 steps at 480p).
This uses the full 50-step denoising process for highest quality.
"""
print("=" * 60)
print("LongCat I2V: Basic Generation (50 steps, 480p)")
print("=" * 60)
generator = VideoGenerator.from_pretrained(
"FastVideo/LongCat-Video-I2V-Diffusers",
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
dit_cpu_offload=False,
vae_cpu_offload=True,
text_encoder_cpu_offload=True,
pin_cpu_memory=False,
enable_bsa=False,
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path="FastVideo/LongCat-Video-I2V-Diffusers",
engine=EngineConfig(
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
offload=OffloadConfig(
dit=False,
vae=True,
text_encoder=True,
pin_cpu_memory=False,
),
),
pipeline=PipelineSelection(experimental={"enable_bsa": False}),
)
)
output_path = "outputs_video/longcat_i2v_basic"
generator.generate_video(
prompt=PROMPT,
negative_prompt=NEGATIVE_PROMPT,
image_path=IMAGE_PATH,
output_path=output_path,
save_video=True,
height=480,
width=480, # Square
num_frames=93,
num_inference_steps=50,
fps=15,
guidance_scale=4.0,
seed=SEED,
generator.generate(
GenerationRequest(
prompt=PROMPT,
negative_prompt=NEGATIVE_PROMPT,
inputs=InputConfig(image_path=IMAGE_PATH),
sampling=SamplingConfig(
height=480,
width=480, # Square
num_frames=93,
num_inference_steps=50,
fps=15,
guidance_scale=4.0,
seed=SEED,
),
output=OutputConfig(output_path=output_path, save_video=True),
)
)
print(f"\nBasic generation complete! Video saved to: {output_path}")
generator.shutdown()
@@ -87,55 +100,70 @@ def basic_generation():
def distill_refine_generation():
"""
Run LongCat I2V with distill+refine pipeline (16 steps + refinement to 768p).
This uses the distilled LoRA for fast 480p generation (16 steps),
then refines to 768p using the refinement LoRA with BSA enabled.
"""
print("\n" + "=" * 60)
print("LongCat I2V: Distill + Refine Pipeline")
print("=" * 60)
# Stage 1: Distilled generation (16 steps at 480p)
print("\n[Stage 1] Distilled generation (16 steps, 480p)")
print("-" * 40)
generator = VideoGenerator.from_pretrained(
"FastVideo/LongCat-Video-I2V-Diffusers",
num_gpus=1,
use_fsdp_inference=True,
dit_cpu_offload=False,
vae_cpu_offload=True,
text_encoder_cpu_offload=True,
pin_cpu_memory=False,
enable_bsa=False,
lora_path="FastVideo/LongCat-Video-T2V-Distilled-LoRA",
lora_nickname="distilled",
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path="FastVideo/LongCat-Video-I2V-Diffusers",
engine=EngineConfig(
num_gpus=1,
use_fsdp_inference=True,
offload=OffloadConfig(
dit=False,
vae=True,
text_encoder=True,
pin_cpu_memory=False,
),
),
pipeline=PipelineSelection(
components=ComponentConfig(
lora_path="FastVideo/LongCat-Video-T2V-Distilled-LoRA",
),
experimental={
"enable_bsa": False,
"lora_nickname": "distilled",
},
),
)
)
distill_output_path = "outputs_video/longcat_i2v_distill"
generator.generate_video(
prompt=PROMPT,
negative_prompt=NEGATIVE_PROMPT,
image_path=IMAGE_PATH,
output_path=distill_output_path,
save_video=True,
height=480,
width=480, # Square
num_frames=93,
num_inference_steps=16,
fps=15,
guidance_scale=1.0,
seed=SEED,
generator.generate(
GenerationRequest(
prompt=PROMPT,
negative_prompt=NEGATIVE_PROMPT,
inputs=InputConfig(image_path=IMAGE_PATH),
sampling=SamplingConfig(
height=480,
width=480, # Square
num_frames=93,
num_inference_steps=16,
fps=15,
guidance_scale=1.0,
seed=SEED,
),
output=OutputConfig(output_path=distill_output_path, save_video=True),
)
)
print(f"Distilled generation complete! Video saved to: {distill_output_path}")
generator.shutdown()
# Stage 2: Refinement (480p -> 768p)
print("\n[Stage 2] Refinement (480p -> 768p with BSA)")
print("-" * 40)
# Find the actual saved video file from stage 1
video_files = glob.glob(os.path.join(distill_output_path, "*.mp4"))
if not video_files:
@@ -143,46 +171,63 @@ def distill_refine_generation():
# Use the most recently created video file
distill_video_path = max(video_files, key=os.path.getmtime)
print(f"Using stage 1 video: {distill_video_path}")
# Create a new generator with refinement LoRA and BSA enabled
# Note: Refinement uses the T2V model (not I2V) since it's upscaling the generated video
# For BSA [4, 4, 8]: latent must be divisible by 8
# 768x768: latent 48x48, 48%8=0 ✓
refine_generator = VideoGenerator.from_pretrained(
"FastVideo/LongCat-Video-T2V-Diffusers",
num_gpus=1,
use_fsdp_inference=True,
dit_cpu_offload=True,
vae_cpu_offload=True,
text_encoder_cpu_offload=True,
pin_cpu_memory=False,
enable_bsa=True,
bsa_sparsity=0.875,
bsa_chunk_q=[4, 4, 4],
bsa_chunk_k=[4, 4, 4],
lora_path="FastVideo/LongCat-Video-T2V-Refinement-LoRA",
lora_nickname="refinement",
refine_generator = VideoGenerator.from_config(
GeneratorConfig(
model_path="FastVideo/LongCat-Video-T2V-Diffusers",
engine=EngineConfig(
num_gpus=1,
use_fsdp_inference=True,
offload=OffloadConfig(
dit=True,
vae=True,
text_encoder=True,
pin_cpu_memory=False,
),
),
pipeline=PipelineSelection(
components=ComponentConfig(
lora_path="FastVideo/LongCat-Video-T2V-Refinement-LoRA",
),
experimental={
"enable_bsa": True,
"bsa_sparsity": 0.875,
"bsa_chunk_q": [4, 4, 4],
"bsa_chunk_k": [4, 4, 4],
"lora_nickname": "refinement",
},
),
)
)
refine_output_path = "outputs_video/longcat_i2v_refine_720p"
refine_generator.generate_video(
prompt=PROMPT,
negative_prompt=NEGATIVE_PROMPT,
output_path=refine_output_path,
save_video=True,
refine_from=distill_video_path,
t_thresh=0.5,
spatial_refine_only=False,
num_cond_frames=0,
height=720,
width=720,
num_inference_steps=50,
fps=30,
guidance_scale=1.0,
seed=SEED,
refine_generator.generate(
GenerationRequest(
prompt=PROMPT,
negative_prompt=NEGATIVE_PROMPT,
inputs=InputConfig(refine_from=distill_video_path),
sampling=SamplingConfig(
height=720,
width=720,
num_inference_steps=50,
fps=30,
guidance_scale=1.0,
seed=SEED,
),
output=OutputConfig(output_path=refine_output_path, save_video=True),
extensions={
"t_thresh": 0.5,
"spatial_refine_only": False,
"num_cond_frames": 0,
},
)
)
print(f"Refinement complete! Video saved to: {refine_output_path}")
refine_generator.shutdown()
@@ -192,13 +237,13 @@ def main():
print("\n" + "=" * 60)
print("LongCat Image-to-Video Example")
print("=" * 60 + "\n")
# Run basic generation
basic_generation()
# Run distill+refine pipeline
distill_refine_generation()
print("\n" + "=" * 60)
print("All generations complete!")
print("=" * 60)
+151 -95
View File
@@ -13,6 +13,10 @@ import glob
import os
from fastvideo import VideoGenerator
from fastvideo.api import (
ComponentConfig, EngineConfig, GenerationRequest, GeneratorConfig,
InputConfig, OffloadConfig, OutputConfig, PipelineSelection, SamplingConfig,
)
# Common prompts and settings matching the shell script examples
PROMPT = (
@@ -38,40 +42,54 @@ SEED = 42
def basic_generation():
"""
Run basic LongCat T2V generation (50 steps at 480p).
This uses the full 50-step denoising process for highest quality.
"""
print("=" * 60)
print("LongCat T2V: Basic Generation (50 steps, 480p)")
print("=" * 60)
generator = VideoGenerator.from_pretrained(
"FastVideo/LongCat-Video-T2V-Diffusers",
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
dit_cpu_offload=False,
vae_cpu_offload=True,
text_encoder_cpu_offload=True,
pin_cpu_memory=False,
enable_bsa=False,
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path="FastVideo/LongCat-Video-T2V-Diffusers",
engine=EngineConfig(
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
offload=OffloadConfig(
dit=False,
vae=True,
text_encoder=True,
pin_cpu_memory=False,
),
),
pipeline=PipelineSelection(
experimental={"enable_bsa": False},
),
)
)
output_path = "outputs_video/longcat_t2v_basic"
generator.generate_video(
prompt=PROMPT,
negative_prompt=NEGATIVE_PROMPT,
output_path=output_path,
save_video=True,
height=480,
width=832,
num_frames=93,
num_inference_steps=50,
fps=15,
guidance_scale=4.0,
seed=SEED,
generator.generate(
GenerationRequest(
prompt=PROMPT,
negative_prompt=NEGATIVE_PROMPT,
output=OutputConfig(
output_path=output_path,
save_video=True,
),
sampling=SamplingConfig(
height=480,
width=832,
num_frames=93,
num_inference_steps=50,
fps=15,
guidance_scale=4.0,
seed=SEED,
),
)
)
print(f"\nBasic generation complete! Video saved to: {output_path}")
generator.shutdown()
@@ -79,54 +97,72 @@ def basic_generation():
def distill_refine_generation():
"""
Run LongCat T2V with distill+refine pipeline (16 steps + refinement to 720p).
This uses the distilled LoRA for fast 480p generation (16 steps),
then refines to 720p using the refinement LoRA with BSA enabled.
"""
print("\n" + "=" * 60)
print("LongCat T2V: Distill + Refine Pipeline")
print("=" * 60)
# Stage 1: Distilled generation (16 steps at 480p)
print("\n[Stage 1] Distilled generation (16 steps, 480p)")
print("-" * 40)
generator = VideoGenerator.from_pretrained(
"FastVideo/LongCat-Video-T2V-Diffusers",
num_gpus=1,
use_fsdp_inference=True,
dit_cpu_offload=False,
vae_cpu_offload=True,
text_encoder_cpu_offload=True,
pin_cpu_memory=False,
enable_bsa=False,
lora_path="FastVideo/LongCat-Video-T2V-Distilled-LoRA",
lora_nickname="distilled",
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path="FastVideo/LongCat-Video-T2V-Diffusers",
engine=EngineConfig(
num_gpus=1,
use_fsdp_inference=True,
offload=OffloadConfig(
dit=False,
vae=True,
text_encoder=True,
pin_cpu_memory=False,
),
),
pipeline=PipelineSelection(
components=ComponentConfig(
lora_path="FastVideo/LongCat-Video-T2V-Distilled-LoRA",
),
experimental={
"enable_bsa": False,
"lora_nickname": "distilled",
},
),
)
)
distill_output_path = "outputs_video/longcat_t2v_distill"
generator.generate_video(
prompt=PROMPT,
negative_prompt=NEGATIVE_PROMPT,
output_path=distill_output_path,
save_video=True,
height=480,
width=832,
num_frames=93,
num_inference_steps=16,
fps=15,
guidance_scale=1.0,
seed=SEED,
generator.generate(
GenerationRequest(
prompt=PROMPT,
negative_prompt=NEGATIVE_PROMPT,
output=OutputConfig(
output_path=distill_output_path,
save_video=True,
),
sampling=SamplingConfig(
height=480,
width=832,
num_frames=93,
num_inference_steps=16,
fps=15,
guidance_scale=1.0,
seed=SEED,
),
)
)
print(f"Distilled generation complete! Video saved to: {distill_output_path}")
generator.shutdown()
# Stage 2: Refinement (480p -> 720p)
print("\n[Stage 2] Refinement (480p -> 720p with BSA)")
print("-" * 40)
# Find the actual saved video file from stage 1
video_files = glob.glob(os.path.join(distill_output_path, "*.mp4"))
if not video_files:
@@ -134,43 +170,65 @@ def distill_refine_generation():
# Use the most recently created video file
distill_video_path = max(video_files, key=os.path.getmtime)
print(f"Using stage 1 video: {distill_video_path}")
# Create a new generator with refinement LoRA and BSA enabled
refine_generator = VideoGenerator.from_pretrained(
"FastVideo/LongCat-Video-T2V-Diffusers",
num_gpus=1,
use_fsdp_inference=True,
dit_cpu_offload=True,
vae_cpu_offload=True,
text_encoder_cpu_offload=True,
pin_cpu_memory=False,
enable_bsa=True,
bsa_sparsity=0.875,
bsa_chunk_q=[4, 4, 8],
bsa_chunk_k=[4, 4, 8],
lora_path="FastVideo/LongCat-Video-T2V-Refinement-LoRA",
lora_nickname="refinement",
refine_generator = VideoGenerator.from_config(
GeneratorConfig(
model_path="FastVideo/LongCat-Video-T2V-Diffusers",
engine=EngineConfig(
num_gpus=1,
use_fsdp_inference=True,
offload=OffloadConfig(
dit=True,
vae=True,
text_encoder=True,
pin_cpu_memory=False,
),
),
pipeline=PipelineSelection(
components=ComponentConfig(
lora_path="FastVideo/LongCat-Video-T2V-Refinement-LoRA",
),
experimental={
"enable_bsa": True,
"bsa_sparsity": 0.875,
"bsa_chunk_q": [4, 4, 8],
"bsa_chunk_k": [4, 4, 8],
"lora_nickname": "refinement",
},
),
)
)
refine_output_path = "outputs_video/longcat_t2v_refine_720p"
refine_generator.generate_video(
prompt=PROMPT,
negative_prompt=NEGATIVE_PROMPT,
output_path=refine_output_path,
save_video=True,
refine_from=distill_video_path,
t_thresh=0.5,
spatial_refine_only=False,
num_cond_frames=0,
height=720,
width=1280,
num_inference_steps=50,
fps=30,
guidance_scale=1.0,
seed=SEED,
refine_generator.generate(
GenerationRequest(
prompt=PROMPT,
negative_prompt=NEGATIVE_PROMPT,
output=OutputConfig(
output_path=refine_output_path,
save_video=True,
),
inputs=InputConfig(
refine_from=distill_video_path,
),
sampling=SamplingConfig(
height=720,
width=1280,
num_inference_steps=50,
fps=30,
guidance_scale=1.0,
seed=SEED,
),
extensions={
"t_thresh": 0.5,
"spatial_refine_only": False,
"num_cond_frames": 0,
},
)
)
print(f"Refinement complete! Video saved to: {refine_output_path}")
refine_generator.shutdown()
@@ -180,13 +238,13 @@ def main():
print("\n" + "=" * 60)
print("LongCat Text-to-Video Example")
print("=" * 60 + "\n")
# Run basic generation
basic_generation()
# Run distill+refine pipeline
distill_refine_generation()
print("\n" + "=" * 60)
print("All generations complete!")
print("=" * 60)
@@ -194,5 +252,3 @@ def main():
if __name__ == "__main__":
main()
+142 -86
View File
@@ -19,6 +19,10 @@ import glob
import os
from fastvideo import VideoGenerator
from fastvideo.api import (
ComponentConfig, EngineConfig, GenerationRequest, GeneratorConfig, InputConfig, OffloadConfig, OutputConfig,
PipelineSelection, SamplingConfig,
)
# Common prompts and settings matching the shell script examples
PROMPT = (
@@ -63,35 +67,49 @@ def basic_generation():
"Please provide a valid video path."
)
generator = VideoGenerator.from_pretrained(
"FastVideo/LongCat-Video-VC-Diffusers",
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
dit_cpu_offload=False,
vae_cpu_offload=True,
text_encoder_cpu_offload=True,
pin_cpu_memory=False,
enable_bsa=False,
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path="FastVideo/LongCat-Video-VC-Diffusers",
engine=EngineConfig(
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
offload=OffloadConfig(
dit=False,
vae=True,
text_encoder=True,
pin_cpu_memory=False,
),
),
pipeline=PipelineSelection(
experimental={"enable_bsa": False},
),
)
)
output_path = "outputs_video/longcat_vc_basic"
generator.generate_video(
prompt=PROMPT,
negative_prompt=NEGATIVE_PROMPT,
video_path=VIDEO_PATH,
num_cond_frames=NUM_COND_FRAMES,
output_path=output_path,
save_video=True,
height=480,
width=832,
num_frames=93,
num_inference_steps=50,
fps=15,
guidance_scale=4.0,
seed=SEED,
generator.generate(
GenerationRequest(
prompt=PROMPT,
negative_prompt=NEGATIVE_PROMPT,
inputs=InputConfig(video_path=VIDEO_PATH),
sampling=SamplingConfig(
height=480,
width=832,
num_frames=93,
num_inference_steps=50,
fps=15,
guidance_scale=4.0,
seed=SEED,
),
output=OutputConfig(
output_path=output_path,
save_video=True,
),
extensions={"num_cond_frames": NUM_COND_FRAMES},
)
)
print(f"\nBasic generation complete! Video saved to: {output_path}")
generator.shutdown()
@@ -118,37 +136,55 @@ def distill_refine_generation():
print("\n[Stage 1] Distilled generation (16 steps, 480p)")
print("-" * 40)
generator = VideoGenerator.from_pretrained(
"FastVideo/LongCat-Video-VC-Diffusers",
num_gpus=1,
use_fsdp_inference=True,
dit_cpu_offload=False,
vae_cpu_offload=True,
text_encoder_cpu_offload=True,
pin_cpu_memory=False,
enable_bsa=False,
lora_path="FastVideo/LongCat-Video-T2V-Distilled-LoRA",
lora_nickname="distilled",
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path="FastVideo/LongCat-Video-VC-Diffusers",
engine=EngineConfig(
num_gpus=1,
use_fsdp_inference=True,
offload=OffloadConfig(
dit=False,
vae=True,
text_encoder=True,
pin_cpu_memory=False,
),
),
pipeline=PipelineSelection(
components=ComponentConfig(
lora_path="FastVideo/LongCat-Video-T2V-Distilled-LoRA",
),
experimental={
"enable_bsa": False,
"lora_nickname": "distilled",
},
),
)
)
distill_output_path = "outputs_video/longcat_vc_distill"
generator.generate_video(
prompt=PROMPT,
negative_prompt=NEGATIVE_PROMPT,
video_path=VIDEO_PATH,
num_cond_frames=NUM_COND_FRAMES,
output_path=distill_output_path,
save_video=True,
height=480,
width=832,
num_frames=93,
num_inference_steps=16,
fps=15,
guidance_scale=1.0,
seed=SEED,
generator.generate(
GenerationRequest(
prompt=PROMPT,
negative_prompt=NEGATIVE_PROMPT,
inputs=InputConfig(video_path=VIDEO_PATH),
sampling=SamplingConfig(
height=480,
width=832,
num_frames=93,
num_inference_steps=16,
fps=15,
guidance_scale=1.0,
seed=SEED,
),
output=OutputConfig(
output_path=distill_output_path,
save_video=True,
),
extensions={"num_cond_frames": NUM_COND_FRAMES},
)
)
print(f"Distilled generation complete! Video saved to: {distill_output_path}")
generator.shutdown()
@@ -166,41 +202,61 @@ def distill_refine_generation():
# Create a new generator with refinement LoRA and BSA enabled
# Note: Refinement uses the T2V model (not VC) since it's upscaling the generated video
refine_generator = VideoGenerator.from_pretrained(
"FastVideo/LongCat-Video-T2V-Diffusers",
num_gpus=1,
use_fsdp_inference=True,
dit_cpu_offload=True,
vae_cpu_offload=True,
text_encoder_cpu_offload=True,
pin_cpu_memory=False,
enable_bsa=True,
bsa_sparsity=0.875,
bsa_chunk_q=[4, 4, 8],
bsa_chunk_k=[4, 4, 8],
lora_path="FastVideo/LongCat-Video-T2V-Refinement-LoRA",
lora_nickname="refinement",
refine_generator = VideoGenerator.from_config(
GeneratorConfig(
model_path="FastVideo/LongCat-Video-T2V-Diffusers",
engine=EngineConfig(
num_gpus=1,
use_fsdp_inference=True,
offload=OffloadConfig(
dit=True,
vae=True,
text_encoder=True,
pin_cpu_memory=False,
),
),
pipeline=PipelineSelection(
components=ComponentConfig(
lora_path="FastVideo/LongCat-Video-T2V-Refinement-LoRA",
),
experimental={
"enable_bsa": True,
"bsa_sparsity": 0.875,
"bsa_chunk_q": [4, 4, 8],
"bsa_chunk_k": [4, 4, 8],
"lora_nickname": "refinement",
},
),
)
)
refine_output_path = "outputs_video/longcat_vc_refine_720p"
refine_generator.generate_video(
prompt=PROMPT,
negative_prompt=NEGATIVE_PROMPT,
output_path=refine_output_path,
save_video=True,
refine_from=distill_video_path,
t_thresh=0.5,
spatial_refine_only=False,
num_cond_frames=0, # For refinement, no conditioning frames
height=720,
width=1280,
num_inference_steps=50,
fps=30,
guidance_scale=1.0,
seed=SEED,
refine_generator.generate(
GenerationRequest(
prompt=PROMPT,
negative_prompt=NEGATIVE_PROMPT,
inputs=InputConfig(refine_from=distill_video_path),
sampling=SamplingConfig(
height=720,
width=1280,
num_inference_steps=50,
fps=30,
guidance_scale=1.0,
seed=SEED,
),
output=OutputConfig(
output_path=refine_output_path,
save_video=True,
),
extensions={
"t_thresh": 0.5,
"spatial_refine_only": False,
"num_cond_frames": 0, # For refinement, no conditioning frames
},
)
)
print(f"Refinement complete! Video saved to: {refine_output_path}")
refine_generator.shutdown()
+28 -11
View File
@@ -1,4 +1,11 @@
from fastvideo import VideoGenerator
from fastvideo.api import (
EngineConfig,
GenerationRequest,
GeneratorConfig,
OutputConfig,
SamplingConfig,
)
PROMPT = (
@@ -18,22 +25,32 @@ PROMPT = (
def main() -> None:
# Uses FastVideo default sampling settings for LTX2 base.
generator = VideoGenerator.from_pretrained(
"Davids048/LTX2-Base-Diffusers",
num_gpus=1,
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path="Davids048/LTX2-Base-Diffusers",
engine=EngineConfig(
num_gpus=1,
),
)
)
output_path = "outputs_video/ltx2_basic/output_ltx2_base_t2v_1088_1920_1.1.mp4"
generator.generate_video(
prompt=PROMPT,
output_path=output_path,
save_video=True,
num_frames=121,
height=1088,
width=1920,
generator.generate(
GenerationRequest(
prompt=PROMPT,
output=OutputConfig(
output_path=output_path,
save_video=True,
),
sampling=SamplingConfig(
num_frames=121,
height=1088,
width=1920,
),
)
)
generator.shutdown()
if __name__ == "__main__":
main()
main()
@@ -49,6 +49,11 @@ from pathlib import Path
import torch._inductor.config as _inductor
from fastvideo import VideoGenerator
from fastvideo.api import (
CompileConfig, ComponentConfig, EngineConfig, GenerationRequest,
GeneratorConfig, OffloadConfig, OutputConfig, PipelineSelection,
SamplingConfig,
)
from fastvideo.configs.pipelines.base import PipelineConfig
from fastvideo.utils import maybe_download_model
@@ -86,9 +91,9 @@ PROMPT = os.getenv("LTX23_I2V_PROMPT", DEFAULT_PROMPT)
# Per-stage timing helpers --------------------------------------------------
def _print_stage_breakdown(result: dict, label: str) -> float | None:
def _print_stage_breakdown(result, label: str) -> float | None:
"""Print stage execution times and return the sum, or None if missing."""
logging_info = result.get("logging_info")
logging_info = result.logging_info
stages = getattr(logging_info, "stages", None) if logging_info else None
if not stages:
print(f" [{label}] stage breakdown unavailable")
@@ -104,11 +109,11 @@ def _print_stage_breakdown(result: dict, label: str) -> float | None:
def _collect_stage_times(
result: dict,
result,
stage_times: dict[str, list[float]],
stage_order: OrderedDict[str, None],
) -> None:
logging_info = result.get("logging_info")
logging_info = result.logging_info
stages = getattr(logging_info, "stages", None) if logging_info else None
if not stages:
return
@@ -169,34 +174,54 @@ def main() -> None:
pipeline_config = PipelineConfig.from_pretrained(model_root)
pipeline_config.dit_config.quant_config = None
generator = VideoGenerator.from_pretrained(
model_root,
num_gpus=1,
# LTX-2.3 distilled uses the two-stage refine pipeline; the refine
# LoRA is intentionally empty for the distilled student.
ltx2_refine_enabled=True,
ltx2_refine_upsampler_path=str(refine_upsampler_path),
ltx2_refine_lora_path="",
ltx2_refine_num_inference_steps=3,
ltx2_refine_guidance_scale=1.0,
ltx2_refine_add_noise=True,
pipeline_config=pipeline_config,
enable_torch_compile=True,
enable_torch_compile_text_encoder=True,
# Compile the VAE codec submodules (encoder / decoder) too. The
# `LTX2CausalVideoAutoencoder` declares `_compile_conditions` so
# `_compile_with_conditions` targets just those submodules and
# leaves the surrounding tiling control flow eager — needed for
# fullgraph + dynamic=False to succeed. VAE eager decode is
# ~1.0s; compiling it brings the stage to ~0.3s.
enable_torch_compile_vae=True,
torch_compile_kwargs=torch_compile_kwargs,
torch_compile_kwargs_vae=torch_compile_kwargs,
# Keep everything resident — no CPU offload for serving-style runs.
dit_cpu_offload=False,
text_encoder_cpu_offload=False,
vae_cpu_offload=False,
ltx2_vae_tiling=False,
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path=model_root,
engine=EngineConfig(
num_gpus=1,
compile=CompileConfig(
enabled=True,
text_encoder_enabled=True,
# Compile the VAE codec submodules (encoder / decoder)
# too. The `LTX2CausalVideoAutoencoder` declares
# `_compile_conditions` so `_compile_with_conditions`
# targets just those submodules and leaves the
# surrounding tiling control flow eager — needed for
# fullgraph + dynamic=False to succeed. VAE eager decode
# is ~1.0s; compiling it brings the stage to ~0.3s.
vae_enabled=True,
backend=torch_compile_kwargs["backend"],
fullgraph=torch_compile_kwargs["fullgraph"],
mode=torch_compile_kwargs["mode"],
dynamic=torch_compile_kwargs["dynamic"],
vae_kwargs=torch_compile_kwargs,
),
# Keep everything resident — no CPU offload for serving runs.
offload=OffloadConfig(
dit=False,
text_encoder=False,
vae=False,
),
),
pipeline=PipelineSelection(
vae_tiling=False,
# LTX-2.3 distilled uses the two-stage refine pipeline; the
# refine LoRA is intentionally empty for the distilled
# student.
components=ComponentConfig(
upsampler_weights=str(refine_upsampler_path),
),
preset_overrides={
"refine": {
"enabled": True,
"num_inference_steps": 3,
"guidance_scale": 1.0,
"add_noise": True,
}
},
experimental={"pipeline_config": pipeline_config},
),
)
)
common_kwargs = dict(
@@ -206,12 +231,15 @@ def main() -> None:
height=1280, width=832, # portrait runway aspect
num_frames=121, fps=24, # ~5s clip
num_inference_steps=8, # distilled denoise steps
# i2v: anchor the input image at frame 0 with full strength.
# `ltx2_image_crf=0.0` skips an extra JPEG re-encode of an already
# JPEG conditioning image.
)
# i2v: anchor the input image at frame 0 with full strength.
# `ltx2_image_crf=0.0` skips an extra JPEG re-encode of an already
# JPEG conditioning image. These are model-specific knobs routed through
# the request extensions escape hatch.
common_extensions = dict(
ltx2_images=[(I2V_IMAGE, 0, 1.0)],
ltx2_image_crf=0.0,
save_video=True,
)
warmup_runs = 2
@@ -227,10 +255,25 @@ def main() -> None:
for w in range(warmup_runs):
t0 = time.perf_counter()
print(f"\n[warmup {w + 1}/{warmup_runs}] compiling + generating…")
generator.generate_video(
output_path=str(OUTPUT_DIR / f"_warmup_{w + 1}.mp4"),
seed=7,
**common_kwargs,
generator.generate(
GenerationRequest(
prompt=common_kwargs["prompt"],
negative_prompt=common_kwargs["negative_prompt"],
sampling=SamplingConfig(
guidance_scale=common_kwargs["guidance_scale"],
height=common_kwargs["height"],
width=common_kwargs["width"],
num_frames=common_kwargs["num_frames"],
fps=common_kwargs["fps"],
num_inference_steps=common_kwargs["num_inference_steps"],
seed=7,
),
output=OutputConfig(
output_path=str(OUTPUT_DIR / f"_warmup_{w + 1}.mp4"),
save_video=True,
),
extensions=common_extensions,
)
)
dt = time.perf_counter() - t0
warmup_secs.append(dt)
@@ -245,19 +288,31 @@ def main() -> None:
out_path = OUTPUT_DIR / f"output_ltx2_3_distilled_i2v_run_{m + 1}.mp4"
print(f"\n[measured {m + 1}/{measured_runs}] generating: {out_path}")
t0 = time.perf_counter()
result = generator.generate_video(
output_path=str(out_path),
seed=2002 + m,
**common_kwargs,
result = generator.generate(
GenerationRequest(
prompt=common_kwargs["prompt"],
negative_prompt=common_kwargs["negative_prompt"],
sampling=SamplingConfig(
guidance_scale=common_kwargs["guidance_scale"],
height=common_kwargs["height"],
width=common_kwargs["width"],
num_frames=common_kwargs["num_frames"],
fps=common_kwargs["fps"],
num_inference_steps=common_kwargs["num_inference_steps"],
seed=2002 + m,
),
output=OutputConfig(
output_path=str(out_path),
save_video=True,
),
extensions=common_extensions,
)
)
wall = time.perf_counter() - t0
e2e = (
result.get("e2e_latency")
if isinstance(result, dict) else None
) or wall
e2e = (result.extra.get("e2e_latency") if result is not None else None) or wall
measured_secs.append(e2e)
print(f"[measured {m + 1}/{measured_runs}] e2e={e2e:.2f}s wall={wall:.2f}s")
if isinstance(result, dict):
if result is not None:
_print_stage_breakdown(result, f"measured {m + 1}")
_collect_stage_times(result, stage_times, stage_order)
@@ -1,4 +1,5 @@
from fastvideo import VideoGenerator
from fastvideo.api import EngineConfig, GenerationRequest, GeneratorConfig, OutputConfig
PROMPT = (
"A warm sunny backyard. The camera starts in a tight cinematic close-up "
@@ -17,16 +18,19 @@ import os
os.environ["FASTVIDEO_ATTENTION_BACKEND"] = "FLASH_ATTN"
def main() -> None:
generator = VideoGenerator.from_pretrained(
"FastVideo/LTX2-Distilled-Diffusers",
num_gpus=4,
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path="FastVideo/LTX2-Distilled-Diffusers",
engine=EngineConfig(num_gpus=4),
)
)
output_path = "outputs_video/ltx2_basic/output_ltx2_distilled_t2v.mp4"
generator.generate_video(
prompt=PROMPT,
output_path=output_path,
save_video=True,
generator.generate(
GenerationRequest(
prompt=PROMPT,
output=OutputConfig(output_path=output_path, save_video=True),
)
)
generator.shutdown()
@@ -8,6 +8,11 @@ from pathlib import Path
import torch
import torch._inductor.config
from fastvideo import VideoGenerator
from fastvideo.api import (
CompileConfig, ComponentConfig, EngineConfig, GenerationRequest,
GenerationResult, GeneratorConfig, OffloadConfig, OutputConfig,
PipelineSelection, SamplingConfig,
)
from fastvideo.configs.pipelines.base import PipelineConfig
from fastvideo.layers.quantization.nvfp4_config import NVFP4Config
from fastvideo.utils import maybe_download_model
@@ -45,11 +50,11 @@ def load_validation_entries(path: Path) -> list[dict]:
def print_stage_breakdown(
result: dict,
result: GenerationResult,
run_idx: int,
num_runs: int,
) -> float | None:
logging_info = result.get("logging_info")
logging_info = result.logging_info
if logging_info is None:
print(f"[{run_idx}/{num_runs}] Stage breakdown unavailable: no logging_info")
return None
@@ -70,9 +75,9 @@ def print_stage_breakdown(
def extract_sr_forward_latency(
result: dict,
result: GenerationResult,
) -> tuple[float | None, list[tuple[str, float]], list[str]]:
logging_info = result.get("logging_info")
logging_info = result.logging_info
if logging_info is None:
return None, [], []
@@ -106,11 +111,11 @@ def extract_sr_forward_latency(
def collect_stage_times(
result: dict,
result: GenerationResult,
stage_times: dict[str, list[float]],
stage_order: OrderedDict[str, None],
) -> None:
logging_info = result.get("logging_info")
logging_info = result.logging_info
if logging_info is None:
return
stages = getattr(logging_info, "stages", None)
@@ -202,26 +207,45 @@ def main() -> None:
"dynamic": False,
}
generator = VideoGenerator.from_pretrained(
model_root,
num_gpus=1,
ltx2_refine_enabled=True,
ltx2_refine_upsampler_path=str(refine_upsampler_path),
refine_lora_path="", # keep refine LoRA disabled in this repo's typed adapter
ltx2_refine_lora_path="", # keep refine LoRA disabled for distilled model
ltx2_refine_num_inference_steps=2,
ltx2_refine_guidance_scale=1.0,
ltx2_refine_add_noise=True,
pipeline_config=pipeline_config,
enable_torch_compile=True,
enable_torch_compile_text_encoder=True,
enable_torch_compile_vae=True,
torch_compile_kwargs=torch_compile_kwargs,
torch_compile_kwargs_vae=torch_compile_kwargs,
dit_cpu_offload=False,
text_encoder_cpu_offload=False,
vae_cpu_offload=False,
ltx2_vae_tiling=False,
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path=model_root,
engine=EngineConfig(
num_gpus=1,
offload=OffloadConfig(
dit=False,
text_encoder=False,
vae=False,
),
compile=CompileConfig(
enabled=True,
text_encoder_enabled=True,
vae_enabled=True,
backend="inductor",
fullgraph=True,
dynamic=False,
vae_kwargs=torch_compile_kwargs,
),
),
pipeline=PipelineSelection(
vae_tiling=False,
components=ComponentConfig(
upsampler_weights=str(refine_upsampler_path),
),
preset_overrides={
"refine": {
"enabled": True,
"num_inference_steps": 2,
"guidance_scale": 1.0,
"add_noise": True,
}
},
experimental={
"refine_lora_path": "", # keep refine LoRA disabled in this repo's typed adapter
"pipeline_config": pipeline_config,
},
),
)
)
run_times: list[float] = []
@@ -243,25 +267,31 @@ def main() -> None:
torch.cuda.synchronize()
start = time.perf_counter()
result = generator.generate_video(
prompt=prompt,
output_path=str(output_path),
fps=24,
seed=10,
save_video=True,
guidance_scale=1.0,
height=benchmark_entry.get("height", 1088),
width=benchmark_entry.get("width", 1920),
num_frames=121,
num_inference_steps=5,
# image_path="examples/inference/basic/prompt1.png",
# ltx2_image_crf=0.0
result = generator.generate(
GenerationRequest(
prompt=prompt,
sampling=SamplingConfig(
fps=24,
seed=10,
guidance_scale=1.0,
height=benchmark_entry.get("height", 1088),
width=benchmark_entry.get("width", 1920),
num_frames=121,
num_inference_steps=5,
),
output=OutputConfig(
output_path=str(output_path),
save_video=True,
),
# inputs=InputConfig(image_path="examples/inference/basic/prompt1.png"),
# extensions={"ltx2_image_crf": 0.0},
)
)
if os.environ.get("FASTVIDEO_STAGE_LOGGING") == "0":
torch.cuda.synchronize()
elapsed = result.get("generation_time") if isinstance(result, dict) else None
e2e_elapsed = result.get("e2e_latency") if isinstance(result, dict) else None
elapsed = result.generation_time if isinstance(result, GenerationResult) else None
e2e_elapsed = result.extra.get("e2e_latency") if isinstance(result, GenerationResult) else None
if elapsed is None:
elapsed = time.perf_counter() - start
if e2e_elapsed is None:
@@ -272,7 +302,7 @@ def main() -> None:
print(f"[{i + 1}/{num_runs}] Generation time: {elapsed:.2f}s")
print(f"[{i + 1}/{num_runs}] End-to-end latency: {e2e_elapsed:.2f}s")
if isinstance(result, dict):
if isinstance(result, GenerationResult):
stage_sum = print_stage_breakdown(result, i + 1, num_runs)
if stage_sum is not None:
non_stage_overhead = e2e_elapsed - stage_sum
+32 -21
View File
@@ -1,18 +1,27 @@
from fastvideo import VideoGenerator
from fastvideo.api import (
EngineConfig, GenerationRequest, GeneratorConfig, InputConfig,
OffloadConfig, OutputConfig, SamplingConfig,
)
OUTPUT_PATH = "video_samples_lucy_edit"
def main():
generator = VideoGenerator.from_pretrained(
"decart-ai/Lucy-Edit-Dev",
num_gpus=1,
use_fsdp_inference=False,
dit_cpu_offload=True,
vae_cpu_offload=False,
text_encoder_cpu_offload=True,
pin_cpu_memory=True,
)
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path="decart-ai/Lucy-Edit-Dev",
engine=EngineConfig(
num_gpus=1,
use_fsdp_inference=False,
offload=OffloadConfig(
dit=True,
vae=False,
text_encoder=True,
pin_cpu_memory=True,
),
),
))
prompt = ("Change the apron and blouse to a classic clown costume: satin "
"polka-dot jumpsuit in bright primary colors, ruffled white collar, "
@@ -20,18 +29,20 @@ def main():
"foam nose; soft window light from left, eye-level medium shot.")
video_path = "https://d2drjpuinn46lb.cloudfront.net/painter_original_edit.mp4"
generator.generate_video(
prompt,
negative_prompt="",
video_path=video_path,
output_path=OUTPUT_PATH,
save_video=True,
height=480,
width=832,
num_frames=81,
fps=24,
guidance_scale=5.0,
)
generator.generate(
GenerationRequest(
prompt=prompt,
negative_prompt="",
inputs=InputConfig(video_path=video_path),
sampling=SamplingConfig(
height=480,
width=832,
num_frames=81,
fps=24,
guidance_scale=5.0,
),
output=OutputConfig(output_path=OUTPUT_PATH, save_video=True),
))
if __name__ == "__main__":
+38 -23
View File
@@ -1,4 +1,6 @@
from fastvideo import VideoGenerator
from fastvideo.api import (EngineConfig, GenerationRequest, GeneratorConfig, InputConfig, OffloadConfig, OutputConfig,
SamplingConfig)
from fastvideo.models.dits.matrixgame2.utils import create_action_presets
import torch
@@ -38,35 +40,48 @@ def main():
# attempt to identify the optimal arguments.
config = VARIANT_CONFIG[MODEL_VARIANT]
generator = VideoGenerator.from_pretrained(
config["model_path"],
# FastVideo will automatically handle distributed setup
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
dit_cpu_offload=True, # DiT need to be offloaded for MoE
vae_cpu_offload=False,
text_encoder_cpu_offload=True,
# Set pin_cpu_memory to false if CPU RAM is limited and there're no frequent CPU-GPU transfer
pin_cpu_memory=True,
# image_encoder_cpu_offload=False,
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path=config["model_path"],
# FastVideo will automatically handle distributed setup
engine=EngineConfig(
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
offload=OffloadConfig(
dit=True, # DiT need to be offloaded for MoE
vae=False,
text_encoder=True,
# Set pin_cpu_memory to false if CPU RAM is limited and there're no frequent CPU-GPU transfer
pin_cpu_memory=True,
),
),
)
)
num_frames = 597
actions = create_action_presets(num_frames, keyboard_dim=config["keyboard_dim"])
grid_sizes = torch.tensor([150, 44, 80])
generator.generate_video(
prompt="",
image_path=config["image_url"],
mouse_cond=actions["mouse"].unsqueeze(0),
keyboard_cond=actions["keyboard"].unsqueeze(0),
grid_sizes=grid_sizes,
num_frames=num_frames,
height=352,
width=640,
num_inference_steps=50,
output_path=OUTPUT_PATH,
save_video=True,
generator.generate(
GenerationRequest(
prompt="",
inputs=InputConfig(
image_path=config["image_url"],
mouse_cond=actions["mouse"].unsqueeze(0),
keyboard_cond=actions["keyboard"].unsqueeze(0),
grid_sizes=grid_sizes,
),
sampling=SamplingConfig(
num_frames=num_frames,
height=352,
width=640,
num_inference_steps=50,
),
output=OutputConfig(
output_path=OUTPUT_PATH,
save_video=True,
),
)
)
@@ -1,5 +1,6 @@
from fastvideo.entrypoints.streaming_generator import StreamingVideoGenerator
from fastvideo.models.dits.matrixgame2.utils import get_current_action_async, expand_action_to_frames
from fastvideo.api import EngineConfig, GeneratorConfig, OffloadConfig
import torch
import asyncio
@@ -42,17 +43,23 @@ async def main():
# attempt to identify the optimal arguments.
config = VARIANT_CONFIG[MODEL_VARIANT]
generator = StreamingVideoGenerator.from_pretrained(
config["model_path"],
# FastVideo will automatically handle distributed setup
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
dit_cpu_offload=True, # DiT need to be offloaded for MoE
vae_cpu_offload=False,
text_encoder_cpu_offload=True,
# Set pin_cpu_memory to false if CPU RAM is limited and there're no frequent CPU-GPU transfer
pin_cpu_memory=True,
# image_encoder_cpu_offload=False,
generator = StreamingVideoGenerator.from_config(
GeneratorConfig(
model_path=config["model_path"],
# FastVideo will automatically handle distributed setup
engine=EngineConfig(
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
offload=OffloadConfig(
dit=True, # DiT need to be offloaded for MoE
vae=False,
text_encoder=True,
# Set pin_cpu_memory to false if CPU RAM is limited and there're no frequent CPU-GPU transfer
pin_cpu_memory=True,
# image_encoder=False,
),
),
)
)
max_blocks = 50
+34 -21
View File
@@ -1,4 +1,7 @@
from fastvideo import VideoGenerator
from fastvideo.api import (
EngineConfig, GenerationRequest, GeneratorConfig, InputConfig, OffloadConfig, OutputConfig, SamplingConfig,
)
MODEL_PATH = "FastVideo/Matrix-Game-3.0-Base-Distilled-Diffusers"
IMAGE_URL = "https://raw.githubusercontent.com/SkyworkAI/Matrix-Game/main/Matrix-Game-3/demo_images/001/image.png"
@@ -7,28 +10,38 @@ OUTPUT_PATH = "video_samples_matrixgame3"
def main():
generator = VideoGenerator.from_pretrained(
MODEL_PATH,
num_gpus=1,
use_fsdp_inference=False,
dit_cpu_offload=False,
vae_cpu_offload=False,
text_encoder_cpu_offload=True,
pin_cpu_memory=True,
)
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path=MODEL_PATH,
engine=EngineConfig(
num_gpus=1,
use_fsdp_inference=False,
offload=OffloadConfig(
dit=False,
vae=False,
text_encoder=True,
pin_cpu_memory=True,
),
),
))
generator.generate_video(
prompt=PROMPT,
image_path=IMAGE_URL,
height=720,
width=1280,
num_frames=57,
num_inference_steps=3,
guidance_scale=1.0,
seed=42,
output_path=OUTPUT_PATH,
save_video=True,
)
generator.generate(
GenerationRequest(
prompt=PROMPT,
inputs=InputConfig(image_path=IMAGE_URL),
sampling=SamplingConfig(
height=720,
width=1280,
num_frames=57,
num_inference_steps=3,
guidance_scale=1.0,
seed=42,
),
output=OutputConfig(
output_path=OUTPUT_PATH,
save_video=True,
),
))
if __name__ == "__main__":
+36 -20
View File
@@ -1,40 +1,56 @@
from fastvideo import VideoGenerator, PipelineConfig
from fastvideo.api.sampling_param import SamplingParam
from fastvideo.api import (
EngineConfig,
GenerationRequest,
GeneratorConfig,
OffloadConfig,
PipelineSelection,
SamplingConfig,
)
def main():
config = PipelineConfig.from_pretrained("Wan-AI/Wan2.1-T2V-1.3B-Diffusers")
config.text_encoder_precisions = ["fp16"]
generator = VideoGenerator.from_pretrained(
"Wan-AI/Wan2.1-T2V-1.3B-Diffusers",
pipeline_config=config,
use_fsdp_inference=False, # Disable FSDP for MPS
dit_cpu_offload=True,
text_encoder_cpu_offload=True,
pin_cpu_memory=True,
disable_autocast=False,
num_gpus=1,
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path="Wan-AI/Wan2.1-T2V-1.3B-Diffusers",
engine=EngineConfig(
num_gpus=1,
use_fsdp_inference=False, # Disable FSDP for MPS
disable_autocast=False,
offload=OffloadConfig(
dit=True,
text_encoder=True,
pin_cpu_memory=True,
),
),
pipeline=PipelineSelection(
experimental={"pipeline_config": config},
),
)
)
# Create sampling parameters with reduced number of frames
sampling_param = SamplingParam.from_pretrained("Wan-AI/Wan2.1-T2V-1.3B-Diffusers")
sampling_param.num_frames = 25 # Reduce from default 81 to 25 frames bc we have to use the SDPA attn backend for mps
sampling_param.height = 256
sampling_param.width = 256
# Reduce from default 81 to 25 frames bc we have to use the SDPA attn backend for mps
sampling = SamplingConfig(
num_frames=25,
height=256,
width=256,
)
prompt = ("A curious raccoon peers through a vibrant field of yellow sunflowers, its eyes "
"wide with interest. The playful yet serene atmosphere is complemented by soft "
"natural light filtering through the petals. Mid-shot, warm and cheerful tones.")
video = generator.generate_video(prompt, sampling_param=sampling_param)
video = generator.generate(GenerationRequest(prompt=prompt, sampling=sampling))
prompt2 = ("A majestic lion strides across the golden savanna, its powerful frame "
"glistening under the warm afternoon sun. The tall grass ripples gently in "
"the breeze, enhancing the lion's commanding presence. The tone is vibrant, "
"embodying the raw energy of the wild. Low angle, steady tracking shot, "
"cinematic.")
video2 = generator.generate_video(prompt2, sampling_param=sampling_param)
video2 = generator.generate(GenerationRequest(prompt=prompt2, sampling=sampling))
if __name__ == "__main__":
main()
+25 -15
View File
@@ -1,6 +1,8 @@
from fastvideo import VideoGenerator
# from fastvideo.api.sampling_param import SamplingParam
from fastvideo.api import (
EngineConfig, GenerationRequest, GeneratorConfig, OffloadConfig,
OutputConfig,
)
OUTPUT_PATH = "video_samples"
def main():
@@ -8,17 +10,23 @@ def main():
# model.
# If a local path is provided, FastVideo will make a best effort
# attempt to identify the optimal arguments.
generator = VideoGenerator.from_pretrained(
"Wan-AI/Wan2.1-T2V-1.3B-Diffusers",
# FastVideo will automatically handle distributed setup
num_gpus=2,
use_fsdp_inference=True,
dit_cpu_offload=False,
vae_cpu_offload=False,
text_encoder_cpu_offload=True,
pin_cpu_memory=True, # set to false if low CPU RAM or hit obscure "CUDA error: Invalid argument"
distributed_executor_backend="ray",
# image_encoder_cpu_offload=False,
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path="Wan-AI/Wan2.1-T2V-1.3B-Diffusers",
# FastVideo will automatically handle distributed setup
engine=EngineConfig(
num_gpus=2,
use_fsdp_inference=True,
execution_backend="ray",
offload=OffloadConfig(
dit=False,
vae=False,
text_encoder=True,
pin_cpu_memory=True, # set to false if low CPU RAM or hit obscure "CUDA error: Invalid argument"
# image_encoder=False,
),
),
)
)
# Generate videos with the same simple API, regardless of GPU count
@@ -27,7 +35,8 @@ def main():
"wide with interest. The playful yet serene atmosphere is complemented by soft "
"natural light filtering through the petals. Mid-shot, warm and cheerful tones."
)
video = generator.generate_video(prompt, output_path=OUTPUT_PATH, save_video=True)
video = generator.generate(
GenerationRequest(prompt=prompt, output=OutputConfig(output_path=OUTPUT_PATH, save_video=True)))
# Generate another video with a different prompt, without reloading the
# model!
@@ -37,7 +46,8 @@ def main():
"the breeze, enhancing the lion's commanding presence. The tone is vibrant, "
"embodying the raw energy of the wild. Low angle, steady tracking shot, "
"cinematic.")
video2 = generator.generate_video(prompt2, output_path=OUTPUT_PATH, save_video=True)
video2 = generator.generate(
GenerationRequest(prompt=prompt2, output=OutputConfig(output_path=OUTPUT_PATH, save_video=True)))
if __name__ == "__main__":
+45 -29
View File
@@ -85,24 +85,35 @@ def main() -> None:
os.environ["FASTVIDEO_ATTENTION_BACKEND"] = args.backend
from fastvideo import VideoGenerator
from fastvideo.api import (
EngineConfig, GenerationRequest, GeneratorConfig, OffloadConfig, OutputConfig,
ParallelismConfig, PipelineSelection, SamplingConfig,
)
os.makedirs(args.out_dir, exist_ok=True)
init_kwargs = {
"num_gpus": args.num_gpus,
"workload_type": "t2i",
"sp_size": 1,
"tp_size": 1,
"dit_cpu_offload": False,
"dit_layerwise_offload": False,
"text_encoder_cpu_offload": False,
"vae_cpu_offload": False,
"image_encoder_cpu_offload": False,
"pin_cpu_memory": False,
"use_fsdp_inference": False,
}
generator = VideoGenerator.from_pretrained(model_path=args.model_path, **init_kwargs)
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path=args.model_path,
engine=EngineConfig(
num_gpus=args.num_gpus,
use_fsdp_inference=False,
parallelism=ParallelismConfig(
sp_size=1,
tp_size=1,
),
offload=OffloadConfig(
dit=False,
dit_layerwise=False,
text_encoder=False,
vae=False,
image_encoder=False,
pin_cpu_memory=False,
),
),
pipeline=PipelineSelection(workload_type="t2i"),
)
)
try:
for i, prompt in enumerate(prompts):
seed = args.seed + i
@@ -113,20 +124,25 @@ def main() -> None:
output_path = os.path.join(args.out_dir, f"{filename_base}.png")
print(f"[sd35] prompt_idx={i} seed={seed} output_path={output_path}")
generation_kwargs = {
"output_path": output_path,
"height": args.height,
"width": args.width,
"num_frames": 1,
"fps": 1,
"num_inference_steps": args.steps,
"guidance_scale": args.guidance,
"seed": seed,
"negative_prompt": args.negative,
"save_video": True,
}
generator.generate_video(prompt, **generation_kwargs)
generator.generate(
GenerationRequest(
prompt=prompt,
negative_prompt=args.negative,
sampling=SamplingConfig(
height=args.height,
width=args.width,
num_frames=1,
fps=1,
num_inference_steps=args.steps,
guidance_scale=args.guidance,
seed=seed,
),
output=OutputConfig(
output_path=output_path,
save_video=True,
),
)
)
print(f"[sd35] done. outputs written to: {args.out_dir}")
finally:
@@ -1,6 +1,14 @@
import os
import time
from fastvideo import VideoGenerator, SamplingParam
from fastvideo import VideoGenerator
from fastvideo.api import (
EngineConfig,
GenerationRequest,
GeneratorConfig,
OffloadConfig,
OutputConfig,
)
OUTPUT_PATH = "video_samples_causal"
def main():
@@ -9,23 +17,33 @@ def main():
# If a local path is provided, FastVideo will make a best effort
# attempt to identify the optimal arguments.
model_name = "wlsaidhi/SFWan2.1-T2V-1.3B-Diffusers"
generator = VideoGenerator.from_pretrained(
model_name,
generator_config = GeneratorConfig(
model_path=model_name,
# FastVideo will automatically handle distributed setup
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
text_encoder_cpu_offload=False,
dit_cpu_offload=False,
engine=EngineConfig(
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
offload=OffloadConfig(
text_encoder=False,
dit=False,
),
),
)
sampling_param = SamplingParam.from_pretrained(model_name)
generator = VideoGenerator.from_config(generator_config)
prompt = (
"A curious raccoon peers through a vibrant field of yellow sunflowers, its eyes "
"wide with interest. The playful yet serene atmosphere is complemented by soft "
"natural light filtering through the petals. Mid-shot, warm and cheerful tones."
)
video = generator.generate_video(prompt, output_path=OUTPUT_PATH, save_video=True, sampling_param=sampling_param)
request = GenerationRequest(
prompt=prompt,
output=OutputConfig(
output_path=OUTPUT_PATH,
save_video=True,
),
)
video = generator.generate(request)
if __name__ == "__main__":
main()
@@ -1,8 +1,17 @@
# NOTE: This is still a work in progress, and the checkpoints are not released yet.
from fastvideo import VideoGenerator, SamplingParam
from fastvideo import VideoGenerator
from fastvideo.api import (
EngineConfig,
GenerationRequest,
GeneratorConfig,
InputConfig,
OffloadConfig,
OutputConfig,
PipelineSelection,
SamplingConfig,
)
import json
# from fastvideo.api.sampling_param import SamplingParam
OUTPUT_PATH = "video_samples_self_forcing_causal_wan2_2_14B_i2v"
def main():
@@ -10,26 +19,37 @@ def main():
# model.
# If a local path is provided, FastVideo will make a best effort
# attempt to identify the optimal arguments.
generator = VideoGenerator.from_pretrained(
"FastVideo/SFWan2.2-I2V-A14B-Preview-Diffusers",
# FastVideo will automatically handle distributed setup
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
dit_cpu_offload=True, # DiT need to be offloaded for MoE
dit_precision="fp32",
vae_cpu_offload=False,
text_encoder_cpu_offload=True,
dmd_denoising_steps=[1000, 850, 700, 550, 350, 275, 200, 125],
# Set pin_cpu_memory to false if CPU RAM is limited and there're no frequent CPU-GPU transfer
pin_cpu_memory=True,
# image_encoder_cpu_offload=False,
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path="FastVideo/SFWan2.2-I2V-A14B-Preview-Diffusers",
# FastVideo will automatically handle distributed setup
engine=EngineConfig(
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
offload=OffloadConfig(
dit=True, # DiT need to be offloaded for MoE
vae=False,
text_encoder=True,
# Set pin_cpu_memory to false if CPU RAM is limited and there're no frequent CPU-GPU transfer
pin_cpu_memory=True,
# image_encoder=False,
),
),
pipeline=PipelineSelection(
experimental={
"dit_precision": "fp32",
"dmd_denoising_steps": [1000, 850, 700, 550, 350, 275, 200, 125],
},
),
)
)
sampling_param = SamplingParam.from_pretrained("FastVideo/SFWan2.2-I2V-A14B-Preview-Diffusers")
sampling_param.num_frames = 81
sampling_param.width = 832
sampling_param.height = 480
sampling_param.seed = 1000
sampling = SamplingConfig(
num_frames=81,
width=832,
height=480,
seed=1000,
)
with open("assets/prompts/mixkit_i2v.jsonl", "r") as f:
prompt_image_pairs = json.load(f)
@@ -37,7 +57,14 @@ def main():
for prompt_image_pair in prompt_image_pairs:
prompt = prompt_image_pair["prompt"]
image_path = prompt_image_pair["image_path"]
_ = generator.generate_video(prompt, image_path=image_path, output_path=OUTPUT_PATH, save_video=True, sampling_param=sampling_param)
_ = generator.generate(
GenerationRequest(
prompt=prompt,
inputs=InputConfig(image_path=image_path),
sampling=sampling,
output=OutputConfig(output_path=OUTPUT_PATH, save_video=True),
)
)
if __name__ == "__main__":
@@ -1,8 +1,10 @@
# NOTE: This is still a work in progress, and the checkpoints are not released yet.
from fastvideo import VideoGenerator
# from fastvideo.api.sampling_param import SamplingParam
from fastvideo.api import (
ComponentConfig, EngineConfig, GenerationRequest, GeneratorConfig,
OffloadConfig, OutputConfig, PipelineSelection, SamplingConfig,
)
OUTPUT_PATH = "video_samples_self_forcing_causal_wan2_2_14B_t2v"
def main():
@@ -10,34 +12,49 @@ def main():
# model.
# If a local path is provided, FastVideo will make a best effort
# attempt to identify the optimal arguments.
generator = VideoGenerator.from_pretrained(
"rand0nmr/SFWan2.2-T2V-A14B-Diffusers",
# FastVideo will automatically handle distributed setup
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
dit_cpu_offload=True, # DiT need to be offloaded for MoE
vae_cpu_offload=False,
text_encoder_cpu_offload=True,
dmd_denoising_steps=[1000, 850, 700, 550, 350, 275, 200, 125],
# Set pin_cpu_memory to false if CPU RAM is limited and there're no frequent CPU-GPU transfer
pin_cpu_memory=True,
init_weights_from_safetensors="/mnt/sharefs/users/hao.zhang/wei/SFwan2.2_distill_self_forcing_release_cfg2/checkpoint-246_weight_only/generator_inference_transformer/",
init_weights_from_safetensors_2="/mnt/sharefs/users/hao.zhang/wei/SFwan2.2_distill_self_forcing_release_cfg2/checkpoint-246_weight_only/generator_2_inference_transformer/",
num_frame_per_block=7,
# image_encoder_cpu_offload=False,
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path="rand0nmr/SFWan2.2-T2V-A14B-Diffusers",
engine=EngineConfig(
# FastVideo will automatically handle distributed setup
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
offload=OffloadConfig(
dit=True, # DiT need to be offloaded for MoE
vae=False,
text_encoder=True,
# Set pin_cpu_memory to false if CPU RAM is limited and there're no frequent CPU-GPU transfer
pin_cpu_memory=True,
),
),
pipeline=PipelineSelection(
components=ComponentConfig(
transformer_weights="/mnt/sharefs/users/hao.zhang/wei/SFwan2.2_distill_self_forcing_release_cfg2/checkpoint-246_weight_only/generator_inference_transformer/",
transformer_2_weights="/mnt/sharefs/users/hao.zhang/wei/SFwan2.2_distill_self_forcing_release_cfg2/checkpoint-246_weight_only/generator_2_inference_transformer/",
),
experimental={
"dmd_denoising_steps": [1000, 850, 700, 550, 350, 275, 200, 125],
"num_frame_per_block": 7,
},
),
# image_encoder_cpu_offload=False,
)
)
# sampling_param = SamplingParam.from_pretrained("Wan-AI/Wan2.1-T2V-1.3B-Diffusers")
# sampling_param.num_frames = 45
# sampling_param.image_path = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/astronaut.jpg"
# Generate videos with the same simple API, regardless of GPU count
prompt = (
"A curious raccoon peers through a vibrant field of yellow sunflowers, its eyes "
"wide with interest. The playful yet serene atmosphere is complemented by soft "
"natural light filtering through the petals. Mid-shot, warm and cheerful tones."
)
_ = generator.generate_video(prompt, output_path=OUTPUT_PATH, save_video=True, num_frames=81)
_ = generator.generate(
GenerationRequest(
prompt=prompt,
sampling=SamplingConfig(num_frames=81),
output=OutputConfig(output_path=OUTPUT_PATH, save_video=True),
)
)
if __name__ == "__main__":
main()
main()
+19 -13
View File
@@ -51,25 +51,31 @@ Prerequisites:
uv pip install k_diffusion einops_exts alias_free_torch torchsde
"""
from fastvideo import VideoGenerator
from fastvideo.api import (EngineConfig, GenerationRequest, GeneratorConfig,
OutputConfig)
PROMPT = "Lo-fi hip hop instrumental with vinyl crackle and gentle piano."
def main() -> None:
generator = VideoGenerator.from_pretrained(
"FastVideo/stable-audio-open-1.0-Diffusers",
num_gpus=1,
)
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path="FastVideo/stable-audio-open-1.0-Diffusers",
engine=EngineConfig(num_gpus=1),
))
output_path = "outputs_audio/stable_audio_basic/output_stable_audio.wav"
generator.generate_video(
prompt=PROMPT,
output_path=output_path,
save_video=True,
# 6-second clip; the model max is ~47.5s.
audio_end_in_s=6.0,
# The registered preset gives 100 steps + CFG=7.0 by default;
# override num_inference_steps / guidance_scale here for QA.
)
generator.generate(
GenerationRequest(
prompt=PROMPT,
output=OutputConfig(
output_path=output_path,
save_video=True,
),
# 6-second clip; the model max is ~47.5s.
extensions={"audio_end_in_s": 6.0},
# The registered preset gives 100 steps + CFG=7.0 by default;
# override num_inference_steps / guidance_scale here for QA.
))
generator.shutdown()
@@ -48,6 +48,12 @@ Picking `init_audio_strength` (0.0 to 1.0):
Prerequisites: same as `basic_stable_audio.py`.
"""
from fastvideo import VideoGenerator
from fastvideo.api import (
EngineConfig,
GenerationRequest,
GeneratorConfig,
OutputConfig,
)
PROMPT = "Change the piano to a cello playing the same notes"
# Path to any audio-bearing file (wav, mp3, mp4, m4a, flac, ...).
@@ -58,18 +64,24 @@ INIT_AUDIO_STRENGTH = 0.6
def main() -> None:
generator = VideoGenerator.from_pretrained(
"FastVideo/stable-audio-open-1.0-Diffusers",
num_gpus=1,
)
generator.generate_video(
prompt=PROMPT,
output_path="outputs_audio/stable_audio_a2a/output_a2a.wav",
save_video=True,
audio_end_in_s=6.0,
init_audio=INIT_AUDIO_PATH,
init_audio_strength=INIT_AUDIO_STRENGTH,
)
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path="FastVideo/stable-audio-open-1.0-Diffusers",
engine=EngineConfig(num_gpus=1),
))
generator.generate(
GenerationRequest(
prompt=PROMPT,
output=OutputConfig(
output_path="outputs_audio/stable_audio_a2a/output_a2a.wav",
save_video=True,
),
extensions={
"audio_end_in_s": 6.0,
"init_audio": INIT_AUDIO_PATH,
"init_audio_strength": INIT_AUDIO_STRENGTH,
},
))
generator.shutdown()
@@ -48,6 +48,9 @@ Prerequisites: same as `basic_stable_audio.py`.
import os
from fastvideo import VideoGenerator
from fastvideo.api import (
EngineConfig, GeneratorConfig, GenerationRequest, OutputConfig,
)
PROMPT = "Steady lo-fi hip hop drum loop with vinyl crackle."
# Required: path to the reference audio file (wav, mp3, mp4, m4a, flac,
@@ -64,19 +67,25 @@ def main() -> None:
f"REFERENCE_AUDIO_PATH={REFERENCE_AUDIO_PATH!r} does not exist. "
"Edit this script to point at a real audio file (wav/mp3/mp4/"
"m4a/flac) before running.")
generator = VideoGenerator.from_pretrained(
"FastVideo/stable-audio-open-1.0-Diffusers",
num_gpus=1,
)
generator.generate_video(
prompt=PROMPT,
output_path="outputs_audio/stable_audio_inpaint/output_inpaint.wav",
save_video=True,
audio_end_in_s=TOTAL_SECONDS,
inpaint_audio=REFERENCE_AUDIO_PATH,
# Tuple form: keep first KEEP_SECONDS, regenerate the rest.
inpaint_mask=(KEEP_SECONDS, TOTAL_SECONDS),
)
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path="FastVideo/stable-audio-open-1.0-Diffusers",
engine=EngineConfig(num_gpus=1),
))
generator.generate(
GenerationRequest(
prompt=PROMPT,
output=OutputConfig(
output_path="outputs_audio/stable_audio_inpaint/output_inpaint.wav",
save_video=True,
),
extensions={
"audio_end_in_s": TOTAL_SECONDS,
"inpaint_audio": REFERENCE_AUDIO_PATH,
# Tuple form: keep first KEEP_SECONDS, regenerate the rest.
"inpaint_mask": (KEEP_SECONDS, TOTAL_SECONDS),
},
))
generator.shutdown()
@@ -28,24 +28,27 @@ Prerequisites: same as `basic_stable_audio.py`. The converted repo is
public so no gated-access flow is required.
"""
from fastvideo import VideoGenerator
from fastvideo.api import (EngineConfig, GenerationRequest, GeneratorConfig,
OutputConfig)
PROMPT = "Lo-fi hip hop instrumental with vinyl crackle and gentle piano."
def main() -> None:
generator = VideoGenerator.from_pretrained(
"FastVideo/stable-audio-open-small-Diffusers",
num_gpus=1,
)
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path="FastVideo/stable-audio-open-small-Diffusers",
engine=EngineConfig(num_gpus=1),
))
output_path = "outputs_audio/stable_audio_small/output_stable_audio_small.wav"
generator.generate_video(
prompt=PROMPT,
output_path=output_path,
save_video=True,
# Small variant trains on a ~11.9s window — keep `audio_end_in_s`
# at or below that.
audio_end_in_s=6.0,
)
generator.generate(
GenerationRequest(
prompt=PROMPT,
output=OutputConfig(output_path=output_path, save_video=True),
# Small variant trains on a ~11.9s window — keep `audio_end_in_s`
# at or below that.
extensions={"audio_end_in_s": 6.0},
))
generator.shutdown()
@@ -4,6 +4,9 @@ import os
os.environ["FASTVIDEO_ATTENTION_BACKEND"] = "SLA_ATTN"
from fastvideo import VideoGenerator
from fastvideo.api import (
EngineConfig, GenerationRequest, GeneratorConfig, OutputConfig, SamplingConfig,
)
OUTPUT_PATH = "video_samples_turbodiffusion"
@@ -11,14 +14,17 @@ OUTPUT_PATH = "video_samples_turbodiffusion"
def main() -> None:
# TurboDiffusion: 1-4 step video generation using RCM scheduler + SLA attention
# FastVideo will automatically use TurboDiffusionPipeline when specified
generator = VideoGenerator.from_pretrained(
"loayrashid/TurboWan2.1-T2V-1.3B-Diffusers",
# FastVideo will automatically handle distributed setup
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
# set to false if using RTX 4090
# pin_cpu_memory=False,
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path="loayrashid/TurboWan2.1-T2V-1.3B-Diffusers",
# FastVideo will automatically handle distributed setup
engine=EngineConfig(
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
),
# set to false if using RTX 4090
# pin_cpu_memory=False,
)
)
# Generate videos with the same simple API, regardless of GPU count
@@ -28,11 +34,17 @@ def main() -> None:
"wide with interest. The playful yet serene atmosphere is complemented by soft "
"natural light filtering through the petals. Mid-shot, warm and cheerful tones."
)
video = generator.generate_video(
prompt,
output_path=OUTPUT_PATH,
save_video=True,
seed=42,
video = generator.generate(
GenerationRequest(
prompt=prompt,
output=OutputConfig(
output_path=OUTPUT_PATH,
save_video=True,
),
sampling=SamplingConfig(
seed=42,
),
)
)
# Generate another video with a different prompt, without reloading the model!
@@ -43,11 +55,17 @@ def main() -> None:
"embodying the raw energy of the wild. Low angle, steady tracking shot, "
"cinematic."
)
video2 = generator.generate_video(
prompt2,
output_path=OUTPUT_PATH,
save_video=True,
seed=42,
video2 = generator.generate(
GenerationRequest(
prompt=prompt2,
output=OutputConfig(
output_path=OUTPUT_PATH,
save_video=True,
),
sampling=SamplingConfig(
seed=42,
),
)
)
@@ -4,6 +4,9 @@ import os
os.environ["FASTVIDEO_ATTENTION_BACKEND"] = "SLA_ATTN"
from fastvideo import VideoGenerator
from fastvideo.api import (
EngineConfig, GenerationRequest, GeneratorConfig, OutputConfig, SamplingConfig,
)
OUTPUT_PATH = "video_samples_turbodiffusion_14B"
@@ -11,10 +14,12 @@ OUTPUT_PATH = "video_samples_turbodiffusion_14B"
def main() -> None:
# TurboDiffusion 14B: 1-4 step video generation using RCM scheduler + SLA attention
# FastVideo will automatically use TurboDiffusionPipeline when specified
generator = VideoGenerator.from_pretrained(
"loayrashid/TurboWan2.1-T2V-14B-Diffusers",
# 14B model needs more GPUs
num_gpus=2,
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path="loayrashid/TurboWan2.1-T2V-14B-Diffusers",
# 14B model needs more GPUs
engine=EngineConfig(num_gpus=2),
)
)
prompt = (
@@ -22,11 +27,12 @@ def main() -> None:
"wide with interest. The playful yet serene atmosphere is complemented by soft "
"natural light filtering through the petals. Mid-shot, warm and cheerful tones."
)
video = generator.generate_video(
prompt,
output_path=OUTPUT_PATH,
save_video=True,
seed=42,
video = generator.generate(
GenerationRequest(
prompt=prompt,
output=OutputConfig(output_path=OUTPUT_PATH, save_video=True),
sampling=SamplingConfig(seed=42),
)
)
# Generate another video with a different prompt, without reloading the model!
@@ -37,11 +43,12 @@ def main() -> None:
"embodying the raw energy of the wild. Low angle, steady tracking shot, "
"cinematic."
)
video2 = generator.generate_video(
prompt2,
output_path=OUTPUT_PATH,
save_video=True,
seed=42,
video2 = generator.generate(
GenerationRequest(
prompt=prompt2,
output=OutputConfig(output_path=OUTPUT_PATH, save_video=True),
sampling=SamplingConfig(seed=42),
)
)
@@ -4,6 +4,10 @@ import os
os.environ["FASTVIDEO_ATTENTION_BACKEND"] = "SLA_ATTN"
from fastvideo import VideoGenerator
from fastvideo.api import (
EngineConfig, GenerationRequest, GeneratorConfig, InputConfig,
OutputConfig, SamplingConfig,
)
# Use local model path
MODEL_PATH = "loayrashid/TurboWan2.2-I2V-A14B-Diffusers"
@@ -12,9 +16,11 @@ OUTPUT_PATH = "video_samples_turbodiffusion_i2v"
def main() -> None:
# TurboDiffusion I2V: 1-4 step image-to-video generation
generator = VideoGenerator.from_pretrained(
MODEL_PATH,
num_gpus=2,
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path=MODEL_PATH,
engine=EngineConfig(num_gpus=2),
)
)
# Example prompt and image for I2V
@@ -24,12 +30,13 @@ def main() -> None:
image_path = "https://huggingface.co/datasets/YiYiXu/testing-images/resolve/main/wan_i2v_input.JPG"
video = generator.generate_video(
prompt,
image_path=image_path,
output_path=OUTPUT_PATH,
save_video=True,
seed=42,
video = generator.generate(
GenerationRequest(
prompt=prompt,
inputs=InputConfig(image_path=image_path),
sampling=SamplingConfig(seed=42),
output=OutputConfig(output_path=OUTPUT_PATH, save_video=True),
)
)
+35 -20
View File
@@ -1,6 +1,8 @@
from fastvideo import VideoGenerator
# from fastvideo.api.sampling_param import SamplingParam
from fastvideo.api import (
EngineConfig, GenerationRequest, GeneratorConfig, OffloadConfig,
OutputConfig, SamplingConfig,
)
OUTPUT_PATH = "video_samples_wan2_2_14B_t2v"
def main():
@@ -8,30 +10,37 @@ def main():
# model.
# If a local path is provided, FastVideo will make a best effort
# attempt to identify the optimal arguments.
generator = VideoGenerator.from_pretrained(
"Wan-AI/Wan2.2-T2V-A14B-Diffusers",
# FastVideo will automatically handle distributed setup
num_gpus=2,
use_fsdp_inference=False, # set to True if GPU is out of memory
dit_cpu_offload=True, # DiT need to be offloaded for MoE
vae_cpu_offload=False,
text_encoder_cpu_offload=True,
# Set pin_cpu_memory to false if CPU RAM is limited and there're no frequent CPU-GPU transfer
pin_cpu_memory=True,
# image_encoder_cpu_offload=False,
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path="Wan-AI/Wan2.2-T2V-A14B-Diffusers",
engine=EngineConfig(
# FastVideo will automatically handle distributed setup
num_gpus=2,
use_fsdp_inference=False, # set to True if GPU is out of memory
offload=OffloadConfig(
dit=True, # DiT need to be offloaded for MoE
vae=False,
text_encoder=True,
# Set pin_cpu_memory to false if CPU RAM is limited and there're no frequent CPU-GPU transfer
pin_cpu_memory=True,
),
),
)
)
# sampling_param = SamplingParam.from_pretrained("Wan-AI/Wan2.1-T2V-1.3B-Diffusers")
# sampling_param.num_frames = 45
# sampling_param.image_path = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/astronaut.jpg"
# Generate videos with the same simple API, regardless of GPU count
prompt = (
"A curious raccoon peers through a vibrant field of yellow sunflowers, its eyes "
"wide with interest. The playful yet serene atmosphere is complemented by soft "
"natural light filtering through the petals. Mid-shot, warm and cheerful tones."
)
_ = generator.generate_video(prompt, output_path=OUTPUT_PATH, save_video=True, height=720, width=1280, num_frames=81)
# video = generator.generate_video(prompt, sampling_param=sampling_param, output_path="wan_t2v_videos/")
_ = generator.generate(
GenerationRequest(
prompt=prompt,
sampling=SamplingConfig(height=720, width=1280, num_frames=81),
output=OutputConfig(output_path=OUTPUT_PATH, save_video=True),
)
)
# Generate another video with a different prompt, without reloading the
# model!
@@ -41,8 +50,14 @@ def main():
"the breeze, enhancing the lion's commanding presence. The tone is vibrant, "
"embodying the raw energy of the wild. Low angle, steady tracking shot, "
"cinematic.")
_ = generator.generate_video(prompt2, output_path=OUTPUT_PATH, save_video=True, height=720, width=1280, num_frames=81)
_ = generator.generate(
GenerationRequest(
prompt=prompt2,
sampling=SamplingConfig(height=720, width=1280, num_frames=81),
output=OutputConfig(output_path=OUTPUT_PATH, save_video=True),
)
)
if __name__ == "__main__":
main()
main()
+35 -16
View File
@@ -1,6 +1,12 @@
from fastvideo import VideoGenerator
# from fastvideo.api.sampling_param import SamplingParam
from fastvideo.api import (
EngineConfig,
GenerationRequest,
GeneratorConfig,
InputConfig,
OffloadConfig,
OutputConfig,
)
OUTPUT_PATH = "video_samples_wan2_1_Fun"
OUTPUT_NAME = "wan2.1_test"
@@ -9,18 +15,24 @@ def main():
# model.
# If a local path is provided, FastVideo will make a best effort
# attempt to identify the optimal arguments.
generator = VideoGenerator.from_pretrained(
"IRMChen/Wan2.1-Fun-1.3B-Control-Diffusers",
# "alibaba-pai/Wan2.2-Fun-A14B-Control",
# FastVideo will automatically handle distributed setup
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
dit_cpu_offload=True, # DiT need to be offloaded for MoE
vae_cpu_offload=False,
text_encoder_cpu_offload=True,
# Set pin_cpu_memory to false if CPU RAM is limited and there're no frequent CPU-GPU transfer
pin_cpu_memory=True,
# image_encoder_cpu_offload=False,
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path="IRMChen/Wan2.1-Fun-1.3B-Control-Diffusers",
# "alibaba-pai/Wan2.2-Fun-A14B-Control",
engine=EngineConfig(
# FastVideo will automatically handle distributed setup
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
offload=OffloadConfig(
dit=True, # DiT need to be offloaded for MoE
vae=False,
text_encoder=True,
# Set pin_cpu_memory to false if CPU RAM is limited and there're no frequent CPU-GPU transfer
pin_cpu_memory=True,
# image_encoder=False,
),
),
)
)
prompt = "一位年轻女性穿着一件粉色的连衣裙,裙子上有白色的装饰和粉色的纽扣。她的头发是紫色的,头上戴着一个红色的大蝴蝶结,显得非常可爱和精致。她还戴着一个红色的领结,整体造型充满了少女感和活力。她的表情温柔,双手轻轻交叉放在身前,姿态优雅。背景是简单的灰色,没有任何多余的装饰,使得人物更加突出。她的妆容清淡自然,突显了她的清新气质。整体画面给人一种甜美、梦幻的感觉,仿佛置身于童话世界中。"
@@ -30,7 +42,14 @@ def main():
image_path = "https://pai-aigc-photog.oss-cn-hangzhou.aliyuncs.com/wan_fun/asset_Wan2_2/v1.0/8.png"
control_video_path = "https://pai-aigc-photog.oss-cn-hangzhou.aliyuncs.com/wan_fun/asset_Wan2_2/v1.0/pose.mp4"
video = generator.generate_video(prompt, negative_prompt=negative_prompt, image_path=image_path, video_path=control_video_path, output_path=OUTPUT_PATH, output_video_name=OUTPUT_NAME, save_video=True)
video = generator.generate(
GenerationRequest(
prompt=prompt,
negative_prompt=negative_prompt,
inputs=InputConfig(image_path=image_path, video_path=control_video_path),
output=OutputConfig(output_path=OUTPUT_PATH, output_video_name=OUTPUT_NAME, save_video=True),
)
)
if __name__ == "__main__":
main()
main()
+30 -15
View File
@@ -1,6 +1,8 @@
from fastvideo import VideoGenerator
# from fastvideo.api.sampling_param import SamplingParam
from fastvideo.api import (
EngineConfig, GenerationRequest, GeneratorConfig, InputConfig,
OffloadConfig, OutputConfig, SamplingConfig,
)
OUTPUT_PATH = "video_samples_wan2_2_14B_i2v"
def main():
@@ -8,23 +10,36 @@ def main():
# model.
# If a local path is provided, FastVideo will make a best effort
# attempt to identify the optimal arguments.
generator = VideoGenerator.from_pretrained(
"Wan-AI/Wan2.2-I2V-A14B-Diffusers",
# FastVideo will automatically handle distributed setup
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
dit_cpu_offload=True, # DiT need to be offloaded for MoE
vae_cpu_offload=False,
text_encoder_cpu_offload=True,
# Set pin_cpu_memory to false if CPU RAM is limited and there're no frequent CPU-GPU transfer
pin_cpu_memory=True,
# image_encoder_cpu_offload=False,
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path="Wan-AI/Wan2.2-I2V-A14B-Diffusers",
# FastVideo will automatically handle distributed setup
engine=EngineConfig(
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
offload=OffloadConfig(
dit=True, # DiT need to be offloaded for MoE
vae=False,
text_encoder=True,
# Set pin_cpu_memory to false if CPU RAM is limited and there're no frequent CPU-GPU transfer
pin_cpu_memory=True,
# image_encoder=False,
),
),
)
)
prompt = "Summer beach vacation style, a white cat wearing sunglasses sits on a surfboard. The fluffy-furred feline gazes directly at the camera with a relaxed expression. Blurred beach scenery forms the background featuring crystal-clear waters, distant green hills, and a blue sky dotted with white clouds. The cat assumes a naturally relaxed posture, as if savoring the sea breeze and warm sunlight. A close-up shot highlights the feline's intricate details and the refreshing atmosphere of the seaside."
image_path = "https://huggingface.co/datasets/YiYiXu/testing-images/resolve/main/wan_i2v_input.JPG"
video = generator.generate_video(prompt, image_path=image_path, output_path=OUTPUT_PATH, save_video=True, height=832, width=480, num_frames=81)
video = generator.generate(
GenerationRequest(
prompt=prompt,
inputs=InputConfig(image_path=image_path),
sampling=SamplingConfig(height=832, width=480, num_frames=81),
output=OutputConfig(output_path=OUTPUT_PATH, save_video=True),
)
)
if __name__ == "__main__":
main()
main()
+33 -13
View File
@@ -1,4 +1,7 @@
from fastvideo import VideoGenerator
from fastvideo.api import (
EngineConfig, GenerationRequest, GeneratorConfig, InputConfig, OffloadConfig, OutputConfig,
)
OUTPUT_PATH = "video_samples_wan2_2_5B_ti2v"
def main():
@@ -7,22 +10,34 @@ def main():
# If a local path is provided, FastVideo will make a best effort
# attempt to identify the optimal arguments.
model_name = "Wan-AI/Wan2.2-TI2V-5B-Diffusers"
generator = VideoGenerator.from_pretrained(
model_name,
# FastVideo will automatically handle distributed setup
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
dit_cpu_offload=True,
vae_cpu_offload=False,
text_encoder_cpu_offload=True,
pin_cpu_memory=True, # set to false if low CPU RAM or hit obscure "CUDA error: Invalid argument"
# image_encoder_cpu_offload=False,
generator = VideoGenerator.from_config(
GeneratorConfig(
model_path=model_name,
engine=EngineConfig(
# FastVideo will automatically handle distributed setup
num_gpus=1,
use_fsdp_inference=False, # set to True if GPU is out of memory
offload=OffloadConfig(
dit=True,
vae=False,
text_encoder=True,
pin_cpu_memory=True, # set to false if low CPU RAM or hit obscure "CUDA error: Invalid argument"
# image_encoder=False,
),
),
)
)
# I2V is triggered just by passing in an image_path argument
prompt = "Summer beach vacation style, a white cat wearing sunglasses sits on a surfboard. The fluffy-furred feline gazes directly at the camera with a relaxed expression. Blurred beach scenery forms the background featuring crystal-clear waters, distant green hills, and a blue sky dotted with white clouds. The cat assumes a naturally relaxed posture, as if savoring the sea breeze and warm sunlight. A close-up shot highlights the feline's intricate details and the refreshing atmosphere of the seaside."
image_path = "https://huggingface.co/datasets/YiYiXu/testing-images/resolve/main/wan_i2v_input.JPG"
video = generator.generate_video(prompt, output_path=OUTPUT_PATH, save_video=True, image_path=image_path)
video = generator.generate(
GenerationRequest(
prompt=prompt,
inputs=InputConfig(image_path=image_path),
output=OutputConfig(output_path=OUTPUT_PATH, save_video=True),
)
)
# Generate another video with a different prompt, without reloading the
# model!
@@ -34,8 +49,13 @@ def main():
"the breeze, enhancing the lion's commanding presence. The tone is vibrant, "
"embodying the raw energy of the wild. Low angle, steady tracking shot, "
"cinematic.")
video2 = generator.generate_video(prompt2, output_path=OUTPUT_PATH, save_video=True)
video2 = generator.generate(
GenerationRequest(
prompt=prompt2,
output=OutputConfig(output_path=OUTPUT_PATH, save_video=True),
)
)
if __name__ == "__main__":
main()
main()