Bernini是一个集视频生成与编辑于一体的统一框架,它将基于MLLM的语义规划器与基于DiT的渲染器相结合。
在视频编辑任务上,Bernini已跻身主流闭源商业模型的第一梯队。下方排行榜数据来源于我们自建的评估平台,该平台通过人类标注员对编辑结果进行盲测投票,并将投票结果汇总为Bradley-Terry评分及两两对比胜率矩阵。
torch==2.5.1+cu124匹配;若自行编译FlashAttention-3,最低需12.3版本)。requirements.txt中固定的依赖版本:torch==2.5.1+cu124、diffusers==0.35.2、accelerate==0.34.2、transformers==4.57.3。参考环境(Bernini-R的开发与测试均基于此配置):
| 组件 | 版本 |
|---|---|
| GPU | NVIDIA H100 |
| CUDA | 12.4 |
| Python | 3.11.2 |
| PyTorch | 2.5.1+cu124 |
git clone https://github.com/bytedance/Bernini.git bernini && cd bernini
pip install -r requirements.txt可选附加组件:
--no-deps 选项,以避免 VeOmni 引入不同的 PyTorch 构建版本并覆盖已固定的 torch==2.5.1+cu124:pip install --no-deps git+https://github.com/ByteDance-Seed/VeOmni.git@v0.1.10。单GPU推理不需要此组件。pip install flash-attn==2.8.3。flash_attn_interface 未在 PyPI 上发布;需从 flash-attention 仓库的 hopper/ 目录(标签 v2.8.3)构建:
git clone https://github.com/Dao-AILab/flash-attention.git
cd flash-attention && git checkout v2.8.3
cd hopper && MAX_JOBS=$(nproc) python3 setup.py install --userBernini-R 提供两种获取渲染器权重的方式。推荐使用 diffusers 格式——它是一个自包含的 diffusers 格式目录,其 transformer / transformer_2 已包含 Bernini-R 权重,因此只需将 --config 指向该目录即可直接加载权重,无需 --high_noise_ckpt / --low_noise_ckpt。
可从 ByteDance/Bernini-R-Diffusers 获取单个即用型 diffusers 格式模型。它将 Wan2.2 基础组件(VAE、UMT5 文本编码器、分词器)与 Bernini-R 转换器权重捆绑在一起,因此运行时无需额外下载其他内容。
pip install -U "huggingface_hub"
hf download ByteDance/Bernini-R-Diffusers --local-dir Bernini-R-Diffusers然后通过 --config 传递它,并省略检查点标志,例如:
python infer_single_gpu.py --config Bernini-R-Diffusers \
--case assets/testcases/t2i/t2i.json --num_frames 1原始布局,Bernini-R 使用两组单独加载的权重:
Wan-AI/Wan2.2-T2V-A14B-Diffusers。提供 VAE、UMT5 文本编码器、分词器以及转换器架构/基础权重。首次运行时会自动下载(由 configs/bernini_renderer_wan22/config.json 中的 wan22_base 配置)。--high_noise_ckpt / --low_noise_ckpt 参数传入。支持本地目录和 Hugging Face 仓库 ID。使用 huggingface-cli 下载模型:
pip install -U "huggingface_hub"
hf download Wan-AI/Wan2.2-T2V-A14B-Diffusers --local-dir Wan2.2-T2V-A14B-Diffusers
hf download ByteDance/Bernini-R --local-dir Bernini-R一次运行由一个案例文件描述——这是一个位于assets/testcases/目录下的小型JSON文件,它整合了单个任务的路由和输入信息(包括task_type、guidance_mode、prompt、源媒体和output)。这样可以避免在命令行中直接输入冗长的提示词。每个任务在assets/testcases/目录下都有一个对应的文件夹,其中包含一个或多个案例文件;有关文件格式以及已整合的t2i/i2i/t2v/v2v/rv2v/r2v示例,请参见assets/testcases/。
--use_pe参数通过兼容OpenAI的端点增强提示词,建议使用此功能以获得最佳生成质量。requirements.txt已安装openai SDK;请通过环境变量配置端点:
export BERNINI_PE_API_KEY=... # or OPENAI_API_KEY
export BERNINI_PE_BASE_URL=... # or OPENAI_BASE_URL
export BERNINI_PE_MODEL=... # vision-capable chat model除非示例另有说明,否则推理输出为480p / 16fps(默认设置——--max_image_size 848,--fps 16)。
每个示例运行 assets/testcases/ 中的一个捆绑案例——将 <hi> / <lo> 替换为您的高/低噪声检查点路径。图像任务(t2i、i2i)在单个 GPU 上展示;视频任务通过 torchrun 在 8 个 GPU 上运行,其中 --ulysses N 为每个样本提供 N 路 Ulysses 序列并行,剩余的 world_size / N 个进程级对任务列表进行数据并行。这两个脚本接受相同的输入,因此任何示例都可以通过任一方式运行。
输入也可以直接作为标志传递,而不是使用 --case(--prompt、--task_type、--guidance_mode、--video、--image、--images、--output);生成参数(--seed、--num_frames 等)始终是命令行标志。
文本到图像(t2i)——单个 GPU;生成一帧,因此需传递 --num_frames 1
python infer_single_gpu.py --high_noise_ckpt <hi> --low_noise_ckpt <lo> \
--case assets/testcases/t2i/t2i.json --num_frames 1图像编辑(i2i)—— 单 GPU;生成一帧,因此需传递 --num_frames 1
python infer_single_gpu.py --high_noise_ckpt <hi> --low_noise_ckpt <lo> \
--case assets/testcases/i2i/i2i.json --num_frames 1文本转视频(t2v)
torchrun --nproc-per-node 8 infer_multi_gpu.py \
--high_noise_ckpt <hi> --low_noise_ckpt <lo> --ulysses 8 \
--case assets/testcases/t2v/t2v.json视频编辑(v2v / mv2v)——提供了两种情况。
对于主体保持常规运动的编辑(情况1在场景中添加了一个雪人),v2v任务类型已足够:
torchrun --nproc-per-node 8 infer_multi_gpu.py \
--high_noise_ckpt <hi> --low_noise_ckpt <lo> --ulysses 8 \
--case assets/testcases/v2v/v2v_case1.json对于需要改变主体动作的编辑(案例 2 使人物蹲下),mv2v 任务类型可提供更好的结果:
torchrun --nproc-per-node 8 infer_multi_gpu.py \
--high_noise_ckpt <hi> --low_noise_ckpt <lo> --ulysses 8 \
--case assets/testcases/v2v/v2v_case2.json参考 + 视频编辑(rv2v)——提供了两种案例。
案例 1 是参考图像引导的视频编辑——将源视频中的服装替换为参考图像中的服装:
torchrun --nproc-per-node 8 infer_multi_gpu.py \
--high_noise_ckpt <hi> --low_noise_ckpt <lo> --ulysses 8 \
--case assets/testcases/rv2v/rv2v_case1.json案例 2 是一个视频插入示例——将内容插入到源视频中。 为更清晰地展示插入效果,它以 720p / 24fps 的规格运行:
torchrun --nproc-per-node 8 infer_multi_gpu.py \
--high_noise_ckpt <hi> --low_noise_ckpt <lo> --ulysses 8 \
--case assets/testcases/rv2v/rv2v_case2.json \
--num_frames 121 --fps 24 --max_image_size 1280参考图转视频(r2v)——通过一张或多张参考图像生成视频
torchrun --nproc-per-node 8 infer_multi_gpu.py \
--high_noise_ckpt <hi> --low_noise_ckpt <lo> --ulysses 8 \
--case assets/testcases/r2v/r2v.json有关完整参数列表,请参见 python infer_single_gpu.py --help。
gradio_demo.py 通过 Gradio 用户界面公开相同的流水线:任务类型下拉菜单会自动填充 guidance_mode(用户仍可编辑),上传的媒体会被路由到匹配的槽位,结果会内联渲染。
# Single GPU
python gradio_demo.py --high_noise_ckpt <hi> --low_noise_ckpt <lo> --port 7860
# 8 GPUs, 8-way Ulysses sequence parallel
torchrun --nproc-per-node 8 gradio_demo.py --ulysses 8 \
--high_noise_ckpt <hi> --low_noise_ckpt <lo> --port 7860 --share添加 --use_pe(以及 export OPENAI_API_KEY=... / BERNINI_PE_API_KEY=...)以启用 GPT 提示词增强功能;UI 中的复选框是在此标志基础上的每请求开关。
如果您在研究中使用 Bernini,请引用:
@article{bernini,
title = {Bernini: Latent Semantic Planning for Video Diffusion},
author = {Chenchen Liu and Junyi Chen and Lei Li and Lu Chi and Mingzhen Sun and Zhuoying Li and Yi Fu and Ruoyu Guo and Yiheng Wu and Ge Bai and Zehuan Yuan},
journal = {arXiv preprint arXiv:2605.22344},
year = {2026}
}Bernini-R 的开发借鉴了多个优秀的开源项目:
感谢这些项目的作者及社区所做出的贡献。
Apache License 2.0。详见 LICENSE。