A bundle's training variant (header-declared `variant`, filename token as
fallback) now selects its sampling preset: distilled -> ltx2_distilled
(8 steps, cfg 1.0, distilled sigmas engage at <=8 steps), sft/base ->
ltx2_base. The bundle table also pins the pipeline class, so
VideoGenerator.from_pretrained(<bundle>) resolves without an override.
Adds basic_ltx2_5{,_distilled}.py examples (--model-path takes the FILE,
--gemma-root declares the paired encoder root), a README section, and CPU
tests for variant/preset resolution, table integrity, and the examples.
86 lines
3.1 KiB
Markdown
86 lines
3.1 KiB
Markdown
# Basic Video Generation Tutorial
|
|
The `VideoGenerator` class provides the primary Python interface for doing offline video generation, which is interacting with a diffusion pipeline without using a separate inference api server.
|
|
|
|
## Requirements
|
|
- At least a single NVIDIA GPU with CUDA 12.4.
|
|
- Python 3.10-3.12
|
|
|
|
## Installation
|
|
If you have not installed FastVideo, please following these [instructions](https://hao-ai-lab.github.io/FastVideo/getting_started/installation) first.
|
|
|
|
## Usage
|
|
The first script in this example shows the most basic usage of FastVideo. If you are new to Python and FastVideo, you should start here.
|
|
|
|
```bash
|
|
# if you have not cloned the directory:
|
|
git clone https://github.com/hao-ai-lab/FastVideo.git && cd FastVideo
|
|
|
|
python examples/inference/basic/basic.py
|
|
```
|
|
|
|
For an example on Apple silicon:
|
|
```
|
|
python examples/inference/basic/basic_mps.py
|
|
```
|
|
|
|
For an example running DMD+VSA inference:
|
|
```
|
|
python examples/inference/basic/basic_dmd.py
|
|
```
|
|
|
|
For the typed config/request path added during the inference API refactor:
|
|
```
|
|
python examples/inference/basic/basic_dmd_new_api.py
|
|
```
|
|
|
|
## LTX-2.5 single-file bundles
|
|
|
|
These examples load LTX-2.5 from a single-file bundle: one `.safetensors`
|
|
file carrying every component (transformer, video VAE, audio VAE, vocoder,
|
|
text projection). (The Hugging Face release ships as a split pack — one
|
|
file per component — which loads through the standard repo path instead.)
|
|
Pass the bundle FILE path directly:
|
|
|
|
```bash
|
|
python examples/inference/basic/basic_ltx2_5_distilled.py \
|
|
--model-path /path/to/bundle.safetensors \
|
|
--gemma-root /path/to/gemma_root
|
|
```
|
|
|
|
| bundle variant | preset | sampling defaults |
|
|
|---|---|---|
|
|
| distilled | `ltx2_distilled` | one stage, 8 steps, CFG 1.0 (no CFG/STG, no spatial upscaler) |
|
|
| sft / base | `ltx2_base` | 40 steps, CFG 3.0 with STG |
|
|
|
|
- The variant is read from the bundle header when declared; otherwise the
|
|
`distilled` token in the file name decides.
|
|
- The Gemma text encoder is NOT in the bundle. Declare its root with
|
|
`--gemma-root` (or `FASTVIDEO_LTX_ENCODER_ROOT`), and use the root shipped
|
|
with the same transformer variant — the roots differ in prompt templating.
|
|
- Decoder caveat: bundles that declare a diffusion VAE decoder
|
|
(`CausalDiffusionVAE`) are not supported yet; loading them currently
|
|
fails at VAE build time. Bundles with the classic `CausalVideoAutoencoder`
|
|
run end to end.
|
|
|
|
## Basic Walkthrough
|
|
|
|
All you need to generate videos using multi-gpus from state-of-the-art diffusion pipelines is the following few lines!
|
|
|
|
```python
|
|
from fastvideo import VideoGenerator
|
|
|
|
def main():
|
|
generator = VideoGenerator.from_pretrained(
|
|
"Wan-AI/Wan2.1-T2V-1.3B-Diffusers",
|
|
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)
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
```
|