模型简介
模型特点
模型能力
使用案例
🚀 VGen
VGen是由阿里巴巴集团通义实验室开发的开源视频合成代码库,拥有先进的视频生成模型。该项目能够根据输入的文本、图像、期望的动作、期望的主题,甚至提供的反馈信号,生成高质量的视频。此外,它还提供了各种常用的视频生成工具,如可视化、采样、训练、推理、图像和视频联合训练、加速等功能。
🚀 快速开始
准备工作
安装环境
conda create -n vgen python=3.8
conda activate vgen
pip install torch==1.12.0+cu113 torchvision==0.13.0+cu113 torchaudio==0.12.0 --extra-index-url https://download.pytorch.org/whl/cu113
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
数据集
我们提供了一个包含图像和视频的演示数据集,以及它们的列表,位于data
目录下。
⚠️ 重要提示:这里使用的演示图像仅用于测试,未包含在训练数据中。
克隆代码库
git clone https://github.com/damo-vilab/i2vgen-xl.git
cd i2vgen-xl
训练文本到视频模型
执行以下命令即可轻松开启分布式训练:
python train_net.py --cfg configs/t2v_train.yaml
在t2v_train.yaml
配置文件中,你可以指定数据、使用frame_lens
调整视频与图像的比例,并通过不同的扩散设置验证你的想法等。
- 训练前,你可以下载我们的任何开源模型进行初始化。我们的代码库支持自定义初始化和
grad_scale
设置,所有这些都包含在yaml文件的Pretrain
项中。 - 训练期间,你可以在
workspace/experiments/t2v_train
目录中查看保存的模型和中间推理结果。
训练完成后,你可以使用以下命令对模型进行推理:
python inference.py --cfg configs/t2v_infer.yaml
然后你可以在workspace/experiments/test_img_01
目录中找到生成的视频。有关数据、模型、种子等具体配置,请参考t2v_infer.yaml
文件。
运行I2VGen - XL模型
下载模型和测试数据
!pip install modelscope
from modelscope.hub.snapshot_download import snapshot_download
model_dir = snapshot_download('damo/I2VGen-XL', cache_dir='models/', revision='v1.0.0')
运行推理命令
python inference.py --cfg configs/i2vgen_xl_infer.yaml
几分钟后,你可以从workspace/experiments/test_img_01
目录中获取你想要创建的高清视频。目前,由于缺乏相关训练数据,我们发现当前模型在动漫图像和黑色背景图像上的表现不佳,我们正在不断努力优化。
⚠️ 重要提示:由于我们的视频质量在GIF格式中被压缩,请点击下面的'HERE'查看原始视频。
其他方法
正在筹备中。
✨ 主要特性
- 可扩展性:便于管理你自己的实验。
- 完整性:涵盖了视频生成的所有常见组件。
- 卓越性能:在多个任务中拥有强大的预训练模型。
📦 安装指南
环境安装
conda create -n vgen python=3.8
conda activate vgen
pip install torch==1.12.0+cu113 torchvision==0.13.0+cu113 torchaudio==0.12.0 --extra-index-url https://download.pytorch.org/whl/cu113
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
克隆代码
git clone https://github.com/damo-vilab/i2vgen-xl.git
cd i2vgen-xl
💻 使用示例
基础用法
训练文本到视频模型
# 开启分布式训练
python train_net.py --cfg configs/t2v_train.yaml
# 训练完成后进行推理
python inference.py --cfg configs/t2v_infer.yaml
运行I2VGen - XL模型
# 下载模型和测试数据
!pip install modelscope
from modelscope.hub.snapshot_download import snapshot_download
model_dir = snapshot_download('damo/I2VGen-XL', cache_dir='models/', revision='v1.0.0')
# 运行推理命令
python inference.py --cfg configs/i2vgen_xl_infer.yaml
高级用法
集成I2VGenXL与 🧨 diffusers
import torch
from diffusers import I2VGenXLPipeline
from diffusers.utils import load_image, export_to_gif
repo_id = "ali-vilab/i2vgen-xl"
pipeline = I2VGenXLPipeline.from_pretrained(repo_id, torch_dtype=torch.float16, variant="fp16").to("cuda")
image_url = "https://github.com/ali-vilab/i2vgen-xl/blob/main/data/test_images/img_0009.png?download=true"
image = load_image(image_url).convert("RGB")
prompt = "Papers were floating in the air on a table in the library"
generator = torch.manual_seed(8888)
frames = pipeline(
prompt=prompt,
image=image,
generator=generator
).frames[0]
print(export_to_gif(frames))
📚 详细文档
自定义方法
我们的代码库本质上支持视频生成中所有常用的组件。你可以通过添加相应的注册类(包括ENGINE, MODEL, DATASETS, EMBEDDER, AUTO_ENCODER, DISTRIBUTION, VISUAL, DIFFUSION, PRETRAIN
)灵活管理你的实验,并且可以根据自己的需求兼容我们所有的开源算法。如果你有任何问题,请随时给我们反馈。
I2VGenXL与 🧨 diffusers集成文档
你可以在这里找到官方文档。
示例输出
使用I2VGenXL的示例输出:
提示词 | 输出示例 |
---|---|
masterpiece, bestquality, sunset. | ![]() |
🔧 技术细节
本项目实现了以下方法:
- I2VGen - XL: High - quality image - to - video synthesis via cascaded diffusion models
- VideoComposer: Compositional Video Synthesis with Motion Controllability
- Hierarchical Spatio - temporal Decoupling for Text - to - Video Generation
- A Recipe for Scaling up Text - to - Video Generation with Text - free Videos
- InstructVideo: Instructing Video Diffusion Models with Human Feedback
- DreamVideo: Composing Your Dream Videos with Customized Subject and Motion
- VideoLCM: Video Latent Consistency Model
- Modelscope text - to - video technical report
📄 许可证
本项目采用MIT许可证。
🔥 最新消息
- [2023.12] 我们发布了高效视频生成方法VideoLCM
- [2023.12] 我们发布了I2VGen - XL和ModelScope T2V的代码和模型
- [2023.12] 我们发布了文本到视频方法HiGen和自定义文本到视频方法DreamVideo
- [2023.12] 我们为VGen编写了一份介绍文档,并将I2VGen - XL与SVD进行了比较
- [2023.11] 我们发布了高质量的I2VGen - XL模型,请参考网页
TODO
- [x] 发布I2VGen - XL的技术论文和网页
- [x] 发布可以生成1280x720视频的代码和预训练模型
- [ ] 发布专门针对人体和面部优化的模型
- [ ] 更新版本能够完全保持身份并同时捕捉大而准确的动作
- [ ] 发布其他方法和相应的模型
BibTeX
如果这个仓库对你有用,请引用我们相应的技术论文:
@article{2023i2vgenxl,
title={I2VGen-XL: High-Quality Image-to-Video Synthesis via Cascaded Diffusion Models},
author={Zhang, Shiwei and Wang, Jiayu and Zhang, Yingya and Zhao, Kang and Yuan, Hangjie and Qing, Zhiwu and Wang, Xiang and Zhao, Deli and Zhou, Jingren},
booktitle={arXiv preprint arXiv:2311.04145},
year={2023}
}
@article{2023videocomposer,
title={VideoComposer: Compositional Video Synthesis with Motion Controllability},
author={Wang, Xiang and Yuan, Hangjie and Zhang, Shiwei and Chen, Dayou and Wang, Jiuniu, and Zhang, Yingya, and Shen, Yujun, and Zhao, Deli and Zhou, Jingren},
booktitle={arXiv preprint arXiv:2306.02018},
year={2023}
}
@article{wang2023modelscope,
title={Modelscope text-to-video technical report},
author={Wang, Jiuniu and Yuan, Hangjie and Chen, Dayou and Zhang, Yingya and Wang, Xiang and Zhang, Shiwei},
journal={arXiv preprint arXiv:2308.06571},
year={2023}
}
@article{dreamvideo,
title={DreamVideo: Composing Your Dream Videos with Customized Subject and Motion},
author={Wei, Yujie and Zhang, Shiwei and Qing, Zhiwu and Yuan, Hangjie and Liu, Zhiheng and Liu, Yu and Zhang, Yingya and Zhou, Jingren and Shan, Hongming},
journal={arXiv preprint arXiv:2312.04433},
year={2023}
}
@article{qing2023higen,
title={Hierarchical Spatio-temporal Decoupling for Text-to-Video Generation},
author={Qing, Zhiwu and Zhang, Shiwei and Wang, Jiayu and Wang, Xiang and Wei, Yujie and Zhang, Yingya and Gao, Changxin and Sang, Nong },
journal={arXiv preprint arXiv:2312.04483},
year={2023}
}
@article{wang2023videolcm,
title={VideoLCM: Video Latent Consistency Model},
author={Wang, Xiang and Zhang, Shiwei and Zhang, Han and Liu, Yu and Zhang, Yingya and Gao, Changxin and Sang, Nong },
journal={arXiv preprint arXiv:2312.09109},
year={2023}
}
免责声明
这个开源模型是使用WebVid - 10M和LAION - 400M数据集训练的,仅用于研究/非商业用途。



