i2vgen xl

提供商ali-vilab
分类text-to-video
许可证mit
下载量35.4K
星标0

简介

i2vgen-xl 是由阿里视觉实验室 (Ali-Vilab) 开源的一款高质量图生视频模型。与常见的文生视频工具不同,它专注于将静态图像转化为流畅的动态视频,能有效保持原图的视觉一致性,避免在生成过程中出现严重的形变。对于开发者而言,该模型采用 MIT 协议,部署门槛较低,非常适合用于将电商产品图动态化、给 AI 绘画作品添加氛围感或构建简单的短视频生成管线。它在处理光影变化和物体自然运动方面表现出色,是目前开源社区中极具竞争力的图生视频方案。

核心亮点

  • 基于 MIT 协议完全开源,部署与商用灵活
  • 强一致性图生视频,有效还原原图细节
  • 擅长处理自然光影,视频动态流畅不崩坏
  • 适配 AI 绘画工作流,将静态图转化为短视频

使用方法

安装依赖
# 安装 Hugging Face transformers
pip install transformers torch
SDK 使用
# 使用 transformers 加载模型
from transformers import AutoModel, AutoTokenizer

model = AutoModel.from_pretrained("ali-vilab/i2vgen-xl")
tokenizer = AutoTokenizer.from_pretrained("ali-vilab/i2vgen-xl")

Hugging Face 下载

我们推荐使用命令行或者 Hugging Face Hub SDK 来进行模型的下载。

操作指引:在下载前,请先通过如下命令安装 huggingface_hub:

操作指引
pip install -U huggingface_hub

命令行下载

下载完整模型库

下载完整模型库
huggingface-cli download ali-vilab/i2vgen-xl

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)
huggingface-cli download ali-vilab/i2vgen-xl config.json --local-dir ./dir

更多命令行下载选项,可参见官方文档

SDK 下载

SDK 下载
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('ali-vilab/i2vgen-xl')

Git 下载

请确保 lfs 已经被正确安装

Git 下载
git lfs install
git clone https://huggingface.co/ali-vilab/i2vgen-xl

如果您希望跳过 lfs 大文件下载,可以使用如下命令

跳过 LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/ali-vilab/i2vgen-xl

模型文件托管在 Hugging Face Hub,使用 HF CLI / SDK / Git 直接下载,不经过本站。

PyTorch / Transformers 使用

安装 Transformers

安装 Transformers
pip install -U transformers torch

模型加载和推理

模型加载和推理
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained('ali-vilab/i2vgen-xl')
tokenizer = AutoTokenizer.from_pretrained('ali-vilab/i2vgen-xl')

完整文档

来源: HuggingFace

---
license: mit
tags:

  • image-to-video

pipeline_tag: text-to-video
---

VGen

!figure1

VGen is an open-source video synthesis codebase developed by the Tongyi Lab of Alibaba Group, featuring state-of-the-art video generative models. This repository includes implementations of the following methods:

  • [A Recipe for Scaling up Text-to-Video Generation with Text-free Videos]()
  • [InstructVideo: Instructing Video Diffusion Models with Human Feedback]()

VGen can produce high-quality videos from the input text, images, desired motion, desired subjects, and even the feedback signals provided. It also offers a variety of commonly used video generation tools such as visualization, sampling, training, inference, join training using images and videos, acceleration, and more.

<a href='https://i2vgen-xl.github.io/'><img src='https://img.shields.io/badge/Project-Page-Green'></a> <a href='https://arxiv.org/abs/2311.04145'><img src='https://img.shields.io/badge/Paper-Arxiv-red'></a> ![YouTube](https://youtu.be/XUi0y7dxqEQ) <a href='https://cloud.video.taobao.com/play/u/null/p/1/e/6/t/1/441039979087.mp4'><img src='source/logo.png'></a>

🔥News!!!

  • __[2023.12]__ We release the high-efficiency video generation method VideoLCM
  • __[2023.12]__ We release the code and model of I2VGen-XL and the ModelScope T2V
  • __[2023.12]__ We release the T2V method HiGen and customizing T2V method DreamVideo.
  • __[2023.11]__ We release a high-quality I2VGen-XL model, please refer to the Webpage

TODO

  • [x] Release the technical papers and webpage of I2VGen-XL
  • [x] Release the code and pretrained models that can generate 1280x720 videos
  • [ ] Release models optimized specifically for the human body and faces
  • [ ] Updated version can fully maintain the ID and capture large and accurate motions simultaneously
  • [ ] Release other methods and the corresponding models

Preparation

The main features of VGen are as follows:

  • Expandability, allowing for easy management of your own experiments.

  • Completeness, encompassing all common components for video generation.

  • Excellent performance, featuring powerful pre-trained models in multiple tasks.

Installation

code
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

Datasets

We have provided a demo dataset that includes images and videos, along with their lists in `data.

*Please note that the demo images used here are for testing purposes and were not included in the training.*

Clone codeb

code
git clone https://github.com/damo-vilab/i2vgen-xl.git
cd i2vgen-xl

Getting Started with VGen

(1) Train your text-to-video model

Executing the following command to enable distributed training is as easy as that.

code
python train_net.py --cfg configs/t2v_train.yaml

In the t2v_train.yaml configuration file, you can specify the data, adjust the video-to-image ratio using frame_lens, and validate your ideas with different Diffusion settings, and so on.

  • Before the training, you can download any of our open-source models for initialization. Our codebase supports custom initialization and grad_scale settings, all of which are included in the Pretrain item in yaml file.
  • During the training, you can view the saved models and intermediate inference results in the workspace/experiments/t2v_traindirectory.

After the training is completed, you can perform inference on the model using the following command.

code
python inference.py --cfg configs/t2v_infer.yaml

Then you can find the videos you generated in the
workspace/experiments/test_img_01 directory. For specific configurations such as data, models, seed, etc., please refer to the t2v_infer.yaml file.

<!-- <table>
<center>
<tr>
<td ><center>
<video muted="true" autoplay="true" loop="true" height="260" src="https://cloud.video.taobao.com/play/u/null/p/1/e/6/t/1/441754174077.mp4"></video>
</center></td>
<td ><center>
<video muted="true" autoplay="true" loop="true" height="260" src="https://cloud.video.taobao.com/play/u/null/p/1/e/6/t/1/441138824052.mp4"></video>
</center></td>
</tr>
</center>
</table>
</center> -->

<table>
<center>
<tr>
<td ><center>
<image height="260" src="https://img.alicdn.com/imgextra/i4/O1CN01Ya2I5I25utrJwJ9Jf_!!6000000007587-2-tps-1280-720.png"></image>
</center></td>
<td ><center>
<image height="260" src="https://img.alicdn.com/imgextra/i3/O1CN01CrmYaz1zXBetmg3dd_!!6000000006723-2-tps-1280-720.png"></image>
</center></td>
</tr>
<tr>
<td ><center>
<p>Clike <a href="https://cloud.video.taobao.com/play/u/null/p/1/e/6/t/1/441754174077.mp4">HRER</a> to view the generated video.</p>
</center></td>
<td ><center>
<p>Clike <a href="https://cloud.video.taobao.com/play/u/null/p/1/e/6/t/1/441138824052.mp4">HRER</a> to view the generated video.</p>
</center></td>
</tr>
</center>
</table>
</center>

(2) Run the I2VGen-XL model

(i) Download model and test data:

code
!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')

(ii) Run the following command:

code
python inference.py --cfg configs/i2vgen_xl_infer.yaml

In a few minutes, you can retrieve the high-definition video you wish to create from the
workspace/experiments/test_img_01` directory. At present, we find that the current model performs inadequately on anime images and images with a black background due to the lack of relevant training data. We are consistently working to optimize it.

<span style="color:red">Due to the compression of our video quality in GIF format, please click 'HRER' below to view the original video.</span>

<center>
<table>
<center>
<tr>
<td ><center>
<image height="260" src="https://img.alicdn.com/imgextra/i1/O1CN01CCEq7K1ZeLpNQqrWu_!!6000000003219-0-tps-1280-720.jpg"></image>
</center></td>
<td ><center>
<!-- <video muted="true" autoplay="true" loop="true" height="260" src="https://cloud.video.taobao.com/play/u/null/p/1/e/6/t/1/442125067544.mp4"></video> -->
<image height="260" src="https://img.alicdn.com/imgextra/i4/O1CN01hIQcvG1spmQMLqBo0_!!6000000005816-1-tps-1280-704.gif"></image>
</center></td>
</tr>
<tr>
<td ><center>
<p>Input Image</p>
</center></td>
<td ><center>
<p>Clike <a href="https://cloud.video.taobao.com/play/u/null/p/1/e/6/t/1/442125067544.mp4">HRER</a> to view the generated video.</p>
</center></td>
</tr>
<tr>
<td ><center>
<image height="260" src="https://img.alicdn.com/imgextra/i4/O1CN01ZXY7UN23K8q4oQ3uG_!!6000000007236-2-tps-1280-720.png"></image>
</center></td>
<td ><center>
<!-- <video muted="true" autoplay="true" loop="true" heigh