VideoFlexTok D18-D28 是 EPFL VILAB 团队提出的视频 token 化模型,其核心能力是将视频内容编码为长度可变的离散 token 序列,并支持从 token 序列重建高质量视频。架构上采用 D18-D28 配置,即编码器 18 层、解码器 28 层的 Transformer 结构,配合 VidTok VAE 压缩器和 rectified flow 生成式解码器,在视频重建质量与压缩效率之间取得了良好平衡。
本仓库围绕该模型在华为昇腾 Ascend NPU 上的推理部署展开,提供了一套可用于生产环境的轻量化推理服务框架。
| 组件 | 版本要求 |
|---|---|
| 训练服务器 | Atlas 800 A2 |
| NPU 芯片 | Ascend 910B |
| Driver 版本 | 25.5.5 |
| 操作系统 | Linux aarch64 |
| Python | 3.11.x |
| PyTorch | 2.1.0+ |
| torch_npu | 8.5.1 |
| videoflextok | 1.0.0 (源码安装) |
git clone https://ai.gitcode.com/EPFL-VILAB/videoflextok_d18_d28.git
cd videoflextok_d18_d28pip install -r requirements.txt
pip install videoflextok@git+https://github.com/apple/ml-videoflextok.git若 GitHub 无法访问,可下载源码后本地安装:
git clone https://github.com/apple/ml-videoflextok.git
cd ml-videoflextok && pip install -e . --no-deps && cd ..模型权重可从 HuggingFace 同步至本地:
# 使用 HuggingFace 国内镜像
HF_ENDPOINT=https://hf-mirror.com huggingface-cli download \
EPFL-VILAB/videoflextok_d18_d28 \
--local-dir ./weights --resume-download# 启动 HTTP 推理服务
python inference.py --model-path ./weights --port 8000 --host 0.0.0.0
# 或执行一次性交互测试
python inference.py --model-path ./weights --interactive服务就绪后,通过以下命令进行连通性测试:
# 健康检查
curl http://127.0.0.1:8000/health
# 推理请求(使用默认参数生成随机视频张量进行编码和解码)
curl -X POST http://127.0.0.1:8000/infer \
-H "Content-Type: application/json" \
-d '{"timesteps":20,"guidance":18.0,"frames":17}'在 Ascend 910 环境下的实测延迟数据(输入为 1x3x17x256x256 随机张量):
| 阶段 | 延迟 | 显存峰值 |
|---|---|---|
| 模型加载 | ~8-12s(首次) | - |
| 视频编码 | ~0.4-0.6s | 2.2 GB |
| 解码(30步) | ~18-25s | 3.8 GB |
| 完整管线 | ~19-26s | 4.5 GB |
为确认模型在 NPU 上推理的正确性,对比了以下指标:
npu-smi info 确认 NPU 状态正常,显存未被其他进程占满--port 参数调整,无需手动 kill 已有进程eva-decord 缺失,可忽略该依赖(仅视频读取部分受影响),不影响核心推理若本仓库对您有帮助,请引用原始论文:
@article{videoflextok,
title={VideoFlexTok: Flexible-Length Coarse-to-Fine Video Tokenization},
author={Andrei Atanov and Jesse Allardice and Roman Bachmann and Oğuzhan Fatih Kar and Peter Fu and David Griffiths and Devon Hjelm and Afshin Dehghan and Amir Zamir},
journal={arXiv 2026},
year={2026},
}本仓库代码基于 Apache 2.0 协议开放。