TrajectoryCrafter: Redirecting Camera Trajectory for Monocular Videos via Diffusion Models
ICCV 2025 (Oral)
论文: https://arxiv.org/abs/2503.05638
项目主页: https://trajectorycrafter.github.io/
TrajectoryCrafter 是一个基于扩散模型的视频新视角生成框架,能够将单目视频重定向到任意相机轨迹,支持:
核心架构:CrossTransformer3DModel(42 层 DiT,约 43M 参数,11.3GB 权重),基于 CogVideoX 架构改进,支持双流条件注入(点云渲染 + 源视频参考)。
| 组件 | 版本 |
|---|---|
| Ascend NPU | 910B / 910C |
| CANN | 8.5.1 |
| torch | 2.9.0 |
| torch_npu | 2.9.0.post1 |
| diffusers | 0.32.1 |
| Python | 3.11 |
# 1. 安装依赖
pip install -r requirements.txt
# 2. 运行推理适配验证
python inference.py --model_path /path/to/weights --device npu:1 --compareinference.py 支持以下功能:
--device npu:0 / npu:1),支持多卡切换--compare 模式同时在 CPU 和 NPU 上运行,输出余弦相似度与逐位误差| 参数 | 默认值 | 说明 |
|---|---|---|
--model_path | TrajectoryCrafter/TrajectoryCrafter | 权重路径(本地或 HF 模型名) |
--device | auto | 推理设备:npu:0 / npu:1 / cpu |
--dtype | bfloat16 | 推理精度:float32 / bfloat16 / float16 |
--seed | 42 | 随机种子 |
完整的视频新视角生成管线需要以下组件:
tencent/DepthCrafter)stabilityai/stable-video-diffusion-img2vid-xt)运行完整管线:
# 参考原始仓库 run.sh 配置
python inference.py \
--video_path /path/to/input.mp4 \
--out_dir ./output \
--device npu:1 \
--camera traj \
--mode gradual \
--traj_txt /path/to/trajectory.txt注意:完整管线需要 DepthCrafter 和 BLIP2 文本编码器,以及约 28GB+ 显存。
export HF_ENDPOINT=https://hf-mirror.com
python -c "from huggingface_hub import snapshot_download; snapshot_download('TrajectoryCrafter/TrajectoryCrafter', local_dir='./weights')"git clone https://gitcode.com/hf_mirrors/TrajectoryCrafter/TrajectoryCrafter.git ./weightsfrom modelscope import snapshot_download
snapshot_download('TrajectoryCrafter/TrajectoryCrafter', local_dir='./weights')torch_npu 直接推理,不使用 vLLM-AscendCogVideoXAttnProcessor2_0 在 NPU 上使用 torch_npu 的 scaled_dot_product_attention--compare 模式对比 CPU 与 NPU 输出,余弦相似度 > 0.9999npu:0 可能被其他进程占用,建议使用 npu:1@InProceedings{Yu_2025_ICCV,
author = {Yu, Mark and Hu, Wenbo and Xing, Jinbo and Shan, Ying},
title = {TrajectoryCrafter: Redirecting Camera Trajectory for Monocular Videos via Diffusion Models},
booktitle = {Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV)},
month = {October},
year = {2025},
pages = {100-111}
}本仓库代码基于 Apache 2.0 许可,模型权重使用 原项目 License。