Merge branch 'main' into dev/v1.2

This commit is contained in:
Zangwei Zheng 2024-05-09 16:49:24 +08:00
commit 4f27cb51fc
8 changed files with 59 additions and 41 deletions

View file

@ -82,8 +82,8 @@ see [here](/assets/texts/t2v_samples.txt) for full prompts.
Open-Sora improves **55%** training speed when training on 64x512x512 videos. Details locates
at [acceleration.md](docs/acceleration.md).
* 🔧 **Data preprocessing pipeline v1.0**,
including [downloading](/tools/datasets/README.md), [video cutting](/tools/scenedetect/README.md),
and [captioning](/tools/caption/README.md) tools. Our data collection plan can be found
including [downloading](tools/datasets/README.md), [video cutting](tools/scene_cut/README.md),
and [captioning](tools/caption/README.md) tools. Our data collection plan can be found
at [datasets.md](docs/datasets.md).
<details>
@ -114,7 +114,7 @@ see [here](/assets/texts/t2v_samples.txt) for full prompts.
* [x] Scaling model parameters and dataset size.
* [x] Incoporate a better scheduler (rectified flow).
* [x] Evaluation pipeline.
* [x] Complete the data processing pipeline (including dense optical flow, aesthetics scores, text-image similarity, etc.).
* [x] Complete the data processing pipeline (including dense optical flow, aesthetics scores, text-image similarity, etc.). See [the dataset](/docs/datasets.md) for more information
* [x] Support image and video conditioning.
* [x] Support variable aspect ratios, resolutions, durations.

View file

@ -111,7 +111,7 @@ As we get one step closer to the replication of Sora, we find many limitations f
- **Lack of time consistency**: we find the model cannot generate videos with high time consistency. We think the problem is due to the lack of training FLOPs. We plan to collect more data and continue training the model to improve the time consistency.
- **Bad human generation**: We find the model cannot generate high-quality human videos. We think the problem is due to the lack of human data. We plan to collect more human data and continue training the model to improve the human generation.
- **Low aesthetic score**: we find the model's aesthetic score is not high. The problem is due to the lack of aesthetic score filtering, which is not conducted due to IO bottleneck. We plan to filter the data by aesthetic score and finetuning the model to improve the aesthetic score.
- **Worse quality for longer video genration**: we find with a same prompt, the longer video has worse quality. This means the image quality is not equally adapted to different lengths of sequences.
- **Worse quality for longer video generation**: we find with a same prompt, the longer video has worse quality. This means the image quality is not equally adapted to different lengths of sequences.
> - **Algorithm & Acceleration**: Zangwei Zheng, Xiangyu Peng, Shenggui Li, Hongxing Liu, Yukun Zhou
> - **Algorithm & Acceleration**: Zangwei Zheng, Xiangyu Peng, Shenggui Li, Hongxing Liu, Yukun Zhou, Tianyi Li
> - **Data Collection & Pipeline**: Xiangyu Peng, Zangwei Zheng, Chenhui Shen, Tom Young, Junjie Wang, Chenfeng Yu

View file

@ -1,5 +1,5 @@
<p align="center">
<img src="../assets/readme/icon.png" width="250"/>
<img src="../../assets/readme/icon.png" width="250"/>
<p>
<div align="center">
@ -21,11 +21,11 @@
<h4>Open-Sora 项目目前处在早期阶段,并将持续更新。</h4>
## 📰 资讯
## 📰 资讯
> 由于文档需要进行翻译,最新资讯请看[英文文档](/README.md#-news)
* **[2024.03.18]** 🔥 我们发布了**Open-Sora 1.0**,这是一个完全开源的视频生成项目。
* Open-Sora 1.0 支持视频数据预处理、<a href="https://github.com/hpcaitech/ColossalAI"><img src="../assets/readme/colossal_ai.png" width="8%" ></a> 加速训练、推理等全套流程。
* 我们提供的[模型权重](/#model-weights)只需 3 天的训练就能生成 2 秒的 512x512 视频。
* Open-Sora 1.0 支持视频数据预处理、加速训练、推理等全套流程。
* 我们提供的[模型权重](#模型权重)只需 3 天的训练就能生成 2 秒的 512x512 视频。
* **[2024.03.04]** Open-Sora开源Sora复现方案成本降低46%,序列扩充至近百万。[[英文博客]](https://hpc-ai.com/blog/open-sora)
## 🎥 最新视频
@ -40,13 +40,13 @@
视频经过降采样处理为`.gif`格式,以便显示。点击查看原始视频。为便于显示,文字经过修剪,全文请参见 [此处](/assets/texts/t2v_samples.txt)。在我们的[图片库](https://hpcaitech.github.io/Open-Sora/)中查看更多样本。
## 🔆 新功能
* 📍Open-Sora-v1 已发布。[这里](/#model-weights)提供了模型权重。只需 400K 视频片段和在单卡 H800 上训200天类比Stable Video Diffusion 的 152M 样本),我们就能生成 2 秒的 512×512 视频。
> 由于文档需要进行翻译,最新资讯请看[英文文档](/README.md#-new-featuresupdates)
* 📍Open-Sora-v1 已发布。[这里](#模型权重)提供了模型权重。只需 400K 视频片段和在单卡 H800 上训200天类比Stable Video Diffusion 的 152M 样本),我们就能生成 2 秒的 512×512 视频。
* ✅ 从图像扩散模型到视频扩散模型的三阶段训练。我们提供每个阶段的权重。
* ✅ 支持训练加速包括Transformer加速、更快的 T5 和 VAE 以及序列并行。在对 64x512x512 视频进行训练时Open-Sora 可将训练速度提高**55%**。详细信息请参见[训练加速](/acceleration.md)。
* 我们提供用于数据预处理的视频切割和字幕工具。有关说明请点击[此处](tools/data/README.md),我们的数据收集计划请点击 [数据集](docs/datasets.md)。
* ✅ 支持训练加速包括Transformer加速、更快的 T5 和 VAE 以及序列并行。在对 64x512x512 视频进行训练时Open-Sora 可将训练速度提高**55%**。详细信息请参见[训练加速](acceleration.md)。
* 🔧 我们提供用于数据预处理的视频切割和字幕工具。有关说明请点击[此处](tools/data/README.md),我们的数据收集计划请点击 [数据集](datasets.md)。
* ✅ 我们发现来自[VideoGPT](https://wilson1yan.github.io/videogpt/index.html)的 VQ-VAE 质量较低,因此采用了来自[Stability-AI](https://huggingface.co/stabilityai/sd-vae-ft-mse-original) 的高质量 VAE。我们还发现使用添加了时间维度的采样会导致生成质量降低。更多讨论请参阅我们的 **[报告](docs/report_v1.md)**。
* ✅ 我们研究了不同的架构,包括 DiT、Latte 和我们提出的 **STDiT**。我们的STDiT在质量和速度之间实现了更好的权衡。更多讨论请参阅我们的 **[报告](docs/report_v1.md)**。
* ✅ 我们研究了不同的架构,包括 DiT、Latte 和我们提出的 **STDiT**。我们的STDiT在质量和速度之间实现了更好的权衡。更多讨论请参阅我们的 **[报告](report_v1.md)**。
* ✅ 支持剪辑和 T5 文本调节。
* ✅ 通过将图像视为单帧视频,我们的项目支持在图像和视频(如 ImageNet 和 UCF101上训练 DiT。更多说明请参见 [指令解析](command.md)。
* ✅ 利用[DiT](https://github.com/facebookresearch/DiT)、[Latte](https://github.com/Vchitect/Latte) 和 [PixArt](https://pixart-alpha.github.io/) 的官方权重支持推理。
@ -60,30 +60,31 @@
### 下一步计划【按优先级排序】
* [ ] 完成数据处理流程(包括密集光流、美学评分、文本图像相似性、重复数据删除等)。更多信息请参见[数据集](/docs/datasets.md)。**[项目进行中]**
* [ ] 训练视频-VAE。 **[项目进行中]**
* [ ] 训练视频-VAE并让模型适应新的VAE **[项目进行中]**
* [ ] 缩放模型参数和数据集大小 **[项目进行中]**
* [ ] 纳入更好的时间表,例如 SD3 中的修正流程。 **[项目进行中]**
<details>
<summary>查看更多</summary>
* [ ] 支持图像和视频调节。
* [ ] 评估流程。
* [ ] 加入更好的调度程序,如 SD3 中的rectified flow程序。
* [ ] 支持可变长宽比、分辨率和持续时间。
* [ ] 发布后支持 SD3。
* [x] 评估流程。
* [x] 完成数据处理流程(包括密集光流、美学评分、文本图像相似性、重复数据删除等)。更多信息请参见[数据集](datasets.md)
* [x] 支持图像和视频调节。
* [x] 支持可变长宽比、分辨率和持续时间。
</details>
## 目录
* [安装](#installation)
* [模型权重](/#model-weights)
* [推理](/#inference)
* [数据处理](/#data-processing)
* [训练](/#training)
* [贡献](/#contribution)
* [声明](/#acknowledgement)
* [引用](/#citation)
* [安装](#安装)
* [模型权重](#模型权重)
* [推理](#推理)
* [数据处理](#数据处理)
* [训练](#训练)
* [评估](#评估)
* [贡献](#贡献)
* [声明](#声明)
* [引用](#引用)
## 安装
@ -137,12 +138,12 @@ docker run -ti --gpus all -v {MOUNT_DIR}:/data opensora
| 16×256×256 | 20K HQ | 24k | 8×64 | 45 | [:link:]() |
| 16×512×512 | 20K HQ | 20k | 2×64 | 35 | [:link:]() |
我们模型的权重部分由[PixArt-α](https://github.com/PixArt-alpha/PixArt-alpha) 初始化。参数数量为 724M。有关训练的更多信息请参阅我们的 **[报告](/docs/report_v1.md)**。有关数据集的更多信息,请参阅[数据](datasets.md)。HQ 表示高质量。
我们模型的权重部分由[PixArt-α](https://github.com/PixArt-alpha/PixArt-alpha) 初始化。参数数量为 724M。有关训练的更多信息请参阅我们的 **[报告](report_v1.md)**。有关数据集的更多信息,请参阅[数据](datasets.md)。HQ 表示高质量。
:warning: **局限性**:我们的模型是在有限的预算内训练出来的。质量和文本对齐度相对较差。特别是在生成人类时,模型表现很差,无法遵循详细的指令。我们正在努力改进质量和文本对齐。
## 推理
要使用我们提供的权重进行推理,首先要将[T5](https://huggingface.co/DeepFloyd/t5-v1_1-xxl/tree/main)权重下载到pretrained_models/t5_ckpts/t5-v1_1-xxl 中。然后下载模型权重。运行以下命令生成样本。请参阅[此处](docs/structure.md#inference-config-demos)自定义配置。
要使用我们提供的权重进行推理,首先要将[T5](https://huggingface.co/DeepFloyd/t5-v1_1-xxl/tree/main)权重下载到pretrained_models/t5_ckpts/t5-v1_1-xxl 中。然后下载模型权重。运行以下命令生成样本。请参阅[此处](structure.md#推理配置演示)自定义配置。
```bash
# Sample 16x512x512 (20s/sample, 100 time steps, 24 GB memory)
@ -160,18 +161,22 @@ torchrun --standalone --nproc_per_node 2 scripts/inference.py configs/opensora/i
```
我们在 H800 GPU 上进行了速度测试。如需使用其他模型进行推理,请参阅[此处](commands_zh.md)获取更多说明。减小`vae.micro_batch_size`来降低显存使用(但取样速度会略微减慢)。
我们在 H800 GPU 上进行了速度测试。如需使用其他模型进行推理,请参阅[此处](commands.md)获取更多说明。减小`vae.micro_batch_size`来降低显存使用(但取样速度会略微减慢)。
## 数据处理
高质量数据是高质量模型的关键。[这里](datasets.md)有我们使用过的数据集和数据收集计划。我们提供处理视频数据的工具。目前,我们的数据处理流程包括以下步骤:
1. 下载数据集。[[文件](/tools/datasets/README.md)]
2. 将视频分割成片段。 [[文件](/tools/scenedetect/README.md)]
2. 将视频分割成片段。 [[文件](/tools/scene_cut/README.md)]
3. 生成视频字幕。 [[文件](/tools/caption/README.md)]
## 训练
### Open-Sora 1.0 训练
<details>
<summary>查看更多</summary>
要启动训练,首先要将[T5](https://huggingface.co/DeepFloyd/t5-v1_1-xxl/tree/main)权重下载到pretrained_models/t5_ckpts/t5-v1_1-xxl 中。然后运行以下命令在单个节点上启动训练。
```bash
@ -187,12 +192,24 @@ torchrun --nnodes=1 --nproc_per_node=8 scripts/train.py configs/opensora/train/6
colossalai run --nproc_per_node 8 --hostfile hostfile scripts/train.py configs/opensora/train/64x512x512.py --data-path YOUR_CSV_PATH --ckpt-path YOUR_PRETRAINED_CKPT
```
有关其他模型的训练和高级使用方法,请参阅[此处](commands_zh.md)获取更多说明。
有关其他模型的训练和高级使用方法,请参阅[此处](commands.md)获取更多说明。
</details>
## 评估
点击[这里](https://github.com/hpcaitech/Open-Sora/blob/main/eval/README.md)查看评估
## 贡献
如果您希望为该项目做出贡献,可以参考 [贡献指南](/CONTRIBUTING.md).
本中文翻译还有许多不足,如果您希望为该项目做出贡献,可以参考 [贡献指南](/CONTRIBUTING.md).
目前需要翻译或更新的文件:
* [ ] 更新[资讯](#-资讯)
* [ ] 更新[最新视频](#-最新视频)
* [ ] 更新[新功能](#-新功能)。
* [ ] 翻译[评估](https://github.com/hpcaitech/Open-Sora/blob/main/eval/README.md)文件
* [ ] 更新Open-Sora 1.1[训练](#训练)
## 声明
* [ColossalAI](https://github.com/hpcaitech/ColossalAI): A powerful large model parallel acceleration and optimization

View file

@ -12,7 +12,7 @@ We assume that you have already installed `opensora` based on the instructions g
pip install gradio spaces
```
2. Afterwards, you can use the following command to launch different models. Remeber to launch the command in the project root directory instead of the `gradio` folder.
2. Afterwards, you can use the following command to launch different models. Remember to launch the command in the project root directory instead of the `gradio` folder.
```bash
# run the default model v1-HQ-16x256x256

View file

@ -134,7 +134,7 @@ class VariableVideoTextDataset(VideoTextDataset):
sample = self.data.iloc[index]
path = sample["path"]
file_type = self.get_type(path)
ar = width / height
ar = height / width
video_fps = 24 # default fps
if file_type == "video":

View file

@ -6,7 +6,7 @@ Human labeling of videos is expensive and time-consuming. We adopt powerful imag
## LLaVA Captioning
We extract three frames from the video for captioning. With batch inference, we can achieve 10 times speedup. With approximatly 720p resolution and 1 frames, the speed is 2~3 videos/s on 8 GPUs. If we resize the smaller side to 336, the speed can be 8 videos/s. In Open-Sora v1.1, to lower the cost, we use the 7B model.
We extract three frames from the video for captioning. With batch inference, we can achieve 10 times speedup. With approximately 720p resolution and 1 frames, the speed is 2~3 videos/s on 8 GPUs. If we resize the smaller side to 336, the speed can be 8 videos/s. In Open-Sora v1.1, to lower the cost, we use the 7B model.
### Requirement

View file

@ -18,7 +18,8 @@ from torch.utils.data.distributed import DistributedSampler
from tqdm import tqdm
from .acceleration.llava.policies import LlavaLlamaForCausalLMPolicy, LlavaMistralForCausalLMPolicy
from .utils import IMG_EXTENSIONS, PROMPTS, VID_EXTENSIONS, Timer, VideoTextDataset, collate_fn
from .utils import PROMPTS, Timer, VideoTextDataset, collate_fn
from ..datasets.utils import IMG_EXTENSIONS, VID_EXTENSIONS
disable_torch_init()

View file

@ -23,7 +23,7 @@ def make_colorwheel():
Baker et al. "A Database and Evaluation Methodology for Optical Flow" (ICCV, 2007)
URL: http://vision.middlebury.edu/flow/flowEval-iccv07.pdf
Code follows the original C++ source code of Daniel Scharstein.
Code follows the the Matlab source code of Deqing Sun.
Code follows the Matlab source code of Deqing Sun.
Returns:
np.ndarray: Color wheel
"""