Open-Sora:Open-Sora: Democratizing Efficient Video Production for All

Open-Sora: Democratizing Efficient Video Production for All

分支8Tags4
文件最后提交记录最后更新时间
2 年前
1 年前
1 年前
1 年前
1 年前
1 年前
1 年前
1 年前
1 年前
2 年前
1 年前
2 个月前
1 年前
1 年前

Open-Sora:让高效视频创作触手可及

我们设计并实现了Open-Sora,这是一项致力于高效生成高质量视频的计划。我们希望将模型、工具及所有细节开放给每一个人。秉持开源理念,Open-Sora不仅让先进的视频生成技术普及化,还提供了一个简洁易用的平台,简化视频生成的复杂流程。借助Open-Sora,我们旨在推动内容创作领域的创新、激发创造力并促进包容发展。

🎬 如需专业级AI视频生成产品,欢迎体验Video Ocean——由更先进的模型驱动。

📰 新闻

  • [2025.03.12] 🔥 我们发布了 Open-Sora 2.0(11B)。🎬 11B 模型在 📐VBench 和 📊人类偏好测试上达到了与 11B HunyuanVideo 及 30B Step-Video 相当的性能。🛠️ 完全开源:仅需 20 万美元即可获取训练所需的检查点和训练代码。[报告]
  • [2025.02.20] 🔥 我们发布了 Open-Sora 1.3(1B)。通过升级的 VAE 和 Transformer 架构,生成视频的质量得到了显著提升 🚀。[检查点] [报告] [演示]
  • [2024.12.23] 视频生成模型的开发成本降低 50%!现提供搭配 H200 GPU 代金券的开源解决方案。[博客] [代码] [代金券]
  • [2024.06.17] 我们发布了 Open-Sora 1.2,其中包含 3D-VAE整流流(rectified flow)分数条件(score condition)。视频质量得到显著提升。[检查点] [报告] [arXiv]
  • [2024.04.25] 🤗 我们在 Hugging Face Spaces 上发布了 Open-Sora 的 Gradio 演示
  • [2024.04.25] 我们发布了 Open-Sora 1.1,它支持 2秒~15秒、144p至720p、任意宽高比 的文本到图像、文本到视频、图像到视频、视频到视频、无限时长 生成。此外,还发布了完整的视频处理流水线。[检查点] [报告]
  • [2024.03.18] 我们发布了 Open-Sora 1.0,一个完全开源的视频生成项目。 Open-Sora 1.0 支持完整的视频数据预处理流水线、借助 加速的训练、推理等功能。我们的模型仅需 3 天训练即可生成 2 秒 512x512 视频。[检查点] [博客] [报告]
  • [2024.03.04] Open-Sora 实现了 46% 的训练成本降低。 [博客]

📍 由于 Open-Sora 正处于积极开发中,我们为不同版本保留了不同的分支。最新版本是 main。旧版本包括:v1.0v1.1v1.2v1.3

🎥 最新演示

为方便展示,演示以压缩 GIF 格式呈现。如需原始质量样本及其对应的提示词,请访问我们的 Gallery

5秒 1024×576 5秒 576×1024 5秒 576×1024
OpenSora 1.3 演示
5秒 720×1280 5秒 720×1280 5秒 720×1280
OpenSora 1.2 演示
4秒 720×1280 4秒 720×1280 4秒 720×1280
OpenSora 1.1 演示
2秒 240×426 2秒 240×426
2秒 426×240 4秒 480×854
16秒 320×320 16秒 224×448 2秒 426×240
OpenSora 1.0 演示
2秒 512×512 2秒 512×512 2秒 512×512
森林地区宁静的夜景。[...] 视频为延时摄影,捕捉从白天到夜晚的过渡,湖泊和森林作为不变的背景。 无人机航拍镜头捕捉到海岸悬崖的壮丽美景,[...] 海水轻轻拍打着岩石底部以及依附在悬崖顶部的绿色植被。 瀑布从悬崖倾泻而下,落入宁静湖泊的壮丽美景。[...] 摄像机角度提供了瀑布的鸟瞰视角。
夜晚繁华的城市街道,充满了汽车前灯的光芒和路灯的环境光。[...] 向日葵田的 vibrant 美景。向日葵排列整齐,营造出秩序感和对称性。[...] 宁静的水下场景,一只海龟游过珊瑚礁。海龟有着绿褐色的壳 [...]

视频已下采样为 .gif 格式以便展示。点击查看原始视频。提示词为展示已精简,完整提示词详见 此处

🔆 报告

📍 由于 Open-Sora 正处于积极开发阶段,我们为不同版本保留了不同的分支。最新版本为 main。旧版本包括:v1.0v1.1v1.2v1.3

快速开始

安装

# create a virtual env and activate (conda as an example)
conda create -n opensora python=3.10
conda activate opensora

# download the repo
git clone https://github.com/hpcaitech/Open-Sora
cd Open-Sora

# Ensure torch >= 2.4.0
pip install -v . # for development mode, `pip install -v -e .`
pip install xformers==0.0.27.post2 --index-url https://download.pytorch.org/whl/cu121 # install xformers according to your cuda version
pip install flash-attn --no-build-isolation

(可选)你可以安装 flash attention 3 以获得更快的速度。

git clone https://github.com/Dao-AILab/flash-attention # 4f0640d5
cd flash-attention/hopper
python setup.py install

模型下载

我们的 11B 模型支持 256px 和 768px 分辨率。单个模型同时支持文本生成视频(T2V)和图像生成视频(I2V)功能。🤗 Huggingface 🤖 ModelScope

从 Huggingface 下载:

pip install "huggingface_hub[cli]"
huggingface-cli download hpcai-tech/Open-Sora-v2 --local-dir ./ckpts

从 ModelScope 下载:

pip install modelscope
modelscope download hpcai-tech/Open-Sora-v2 --local_dir ./ckpts

文本到视频生成

我们的模型针对图像到视频生成进行了优化,但也可用于文本到视频生成。为生成高质量视频,我们借助 flux 文本到图像模型,构建了一条文本到图像再到视频的处理流程。对于 256x256 分辨率:

# Generate one given prompt
torchrun --nproc_per_node 1 --standalone scripts/diffusion/inference.py configs/diffusion/inference/t2i2v_256px.py --save-dir samples --prompt "raining, sea"

# Save memory with offloading
torchrun --nproc_per_node 1 --standalone scripts/diffusion/inference.py configs/diffusion/inference/t2i2v_256px.py --save-dir samples --prompt "raining, sea" --offload True

# Generation with csv
torchrun --nproc_per_node 1 --standalone scripts/diffusion/inference.py configs/diffusion/inference/t2i2v_256px.py --save-dir samples --dataset.data-path assets/texts/example.csv

对于 768x768 分辨率:

# One GPU
torchrun --nproc_per_node 1 --standalone scripts/diffusion/inference.py configs/diffusion/inference/t2i2v_768px.py --save-dir samples --prompt "raining, sea"

# Multi-GPU with colossalai sp
torchrun --nproc_per_node 8 --standalone scripts/diffusion/inference.py configs/diffusion/inference/t2i2v_768px.py --save-dir samples --prompt "raining, sea"

您可以通过 --aspect_ratio 调整生成视频的宽高比,通过 --num_frames 调整生成视频的长度。宽高比的可选值包括 16:99:161:12.39:1。帧数的可选值应为 4k+1 且小于 129。

您还可以通过以下方式直接运行文本到视频的生成:

# One GPU for 256px
torchrun --nproc_per_node 1 --standalone scripts/diffusion/inference.py configs/diffusion/inference/256px.py --prompt "raining, sea"
# Multi-GPU for 768px
torchrun --nproc_per_node 8 --standalone scripts/diffusion/inference.py configs/diffusion/inference/768px.py --prompt "raining, sea"

图像转视频生成

给定提示词和参考图像,您可以使用以下命令生成视频:

# 256px
torchrun --nproc_per_node 1 --standalone scripts/diffusion/inference.py configs/diffusion/inference/256px.py --cond_type i2v_head --prompt "A plump pig wallows in a muddy pond on a rustic farm, its pink snout poking out as it snorts contentedly. The camera captures the pig's playful splashes, sending ripples through the water under the midday sun. Wooden fences and a red barn stand in the background, framed by rolling green hills. The pig's muddy coat glistens in the sunlight, showcasing the simple pleasures of its carefree life." --ref assets/texts/i2v.png

# 256px with csv
torchrun --nproc_per_node 1 --standalone scripts/diffusion/inference.py configs/diffusion/inference/256px.py --cond_type i2v_head --dataset.data-path assets/texts/i2v.csv

# Multi-GPU 768px
torchrun --nproc_per_node 8 --standalone scripts/diffusion/inference.py configs/diffusion/inference/768px.py --cond_type i2v_head --dataset.data-path assets/texts/i2v.csv

高级用法

运动分数

在训练过程中,我们将运动分数融入文本提示。推理时,您可以使用以下命令生成带有运动分数的视频(默认分数为4):

torchrun --nproc_per_node 1 --standalone scripts/diffusion/inference.py configs/diffusion/inference/t2i2v_256px.py --save-dir samples --prompt "raining, sea" --motion-score 4

我们还提供动态运动评分评估器。设置好您的 OpenAI API 密钥后,可使用以下命令评估视频的运动评分:

torchrun --nproc_per_node 1 --standalone scripts/diffusion/inference.py configs/diffusion/inference/t2i2v_256px.py --save-dir samples --prompt "raining, sea" --motion-score dynamic
分数 1 4 7

提示词优化

我们借助 ChatGPT 对提示词进行优化。您可以使用以下命令来优化提示词。该功能同时适用于文本生成视频和图像生成视频任务。

export OPENAI_API_KEY=sk-xxxx
torchrun --nproc_per_node 1 --standalone scripts/diffusion/inference.py configs/diffusion/inference/t2i2v_256px.py --save-dir samples --prompt "raining, sea" --refine-prompt True

可复现性

为确保结果可复现,您可以通过以下方式设置随机种子:

torchrun --nproc_per_node 1 --standalone scripts/diffusion/inference.py configs/diffusion/inference/t2i2v_256px.py --save-dir samples --prompt "raining, sea" --sampling_option.seed 42 --seed 42

使用 --num-sample k 为每个提示生成 k 个样本。

计算效率

我们在 H100/H800 GPU 上测试了文本到视频的计算效率。对于 256x256 分辨率,我们使用 colossalai 的张量并行,并启用 --offload True。对于 768x768 分辨率,我们使用 colossalai 的序列并行。所有测试均采用 50 步。结果格式为:总时间(秒)/峰值 GPU 内存(GB)\color{blue}{\text{总时间(秒)}}/\color{red}{\text{峰值 GPU 内存(GB)}}

分辨率 1 张 GPU 2 张 GPU 4 张 GPU 8 张 GPU
256x256 60/52.5\color{blue}{60}/\color{red}{52.5} 40/44.3\color{blue}{40}/\color{red}{44.3} 34/44.3\color{blue}{34}/\color{red}{44.3}
768x768 1656/60.3\color{blue}{1656}/\color{red}{60.3} 863/48.3\color{blue}{863}/\color{red}{48.3} 466/44.3\color{blue}{466}/\color{red}{44.3} 276/44.3\color{blue}{276}/\color{red}{44.3}

评估

VBench 上,Open-Sora 2.0 显著缩小了与 OpenAI Sora 的差距,与 Open-Sora 1.2 相比,差距从 4.52% 降至 0.69%。

VBench

人类偏好结果显示,我们的模型与 HunyuanVideo 11B 和 Step-Video 30B 相当。

Win Rate

凭借出色的性能,Open-Sora 2.0 兼具成本效益。

Cost

贡献者

感谢以下杰出的贡献者:

如果您希望为该项目做出贡献,请参考 贡献指南

致谢

此处仅列出部分项目。其他相关研究成果及数据集,请参考我们的报告。

  • ColossalAI:功能强大的大模型并行加速与优化系统。
  • DiT:基于Transformer的可扩展扩散模型。
  • OpenDiT:DiT训练加速工具。我们借鉴了OpenDiT中宝贵的训练加速策略。
  • PixArt:基于DiT的开源文本到图像模型。
  • Flux:功能强大的文本到图像生成模型。
  • Latte:针对视频场景高效训练DiT的尝试。
  • HunyuanVideo:开源文本到视频模型。
  • StabilityAI VAE:功能强大的图像VAE模型。
  • DC-AE:用于图像压缩的深度压缩自编码器。
  • CLIP:功能强大的文本-图像嵌入模型。
  • T5:功能强大的文本编码器。
  • LLaVA:基于Mistral-7BYi-34B的强大图像 captioning 模型。
  • PLLaVA:功能强大的视频 captioning 模型。
  • MiraData:具有长时长和结构化 caption 的大规模视频数据集。

引用

@article{opensora,
  title={Open-sora: Democratizing efficient video production for all},
  author={Zheng, Zangwei and Peng, Xiangyu and Yang, Tianji and Shen, Chenhui and Li, Shenggui and Liu, Hongxin and Zhou, Yukun and Li, Tianyi and You, Yang},
  journal={arXiv preprint arXiv:2412.20404},
  year={2024}
}

@article{opensora2,
    title={Open-Sora 2.0: Training a Commercial-Level Video Generation Model in $200k}, 
    author={Xiangyu Peng and Zangwei Zheng and Chenhui Shen and Tom Young and Xinying Guo and Binluo Wang and Hang Xu and Hongxin Liu and Mingyan Jiang and Wenjun Li and Yuhui Wang and Anbang Ye and Gang Ren and Qianran Ma and Wanying Liang and Xiang Lian and Xiwen Wu and Yuting Zhong and Zhuangyan Li and Chaoyu Gong and Guojun Lei and Leijun Cheng and Limin Zhang and Minghao Li and Ruijie Zhang and Silan Hu and Shijie Huang and Xiaokang Wang and Yuanheng Zhao and Yuqi Wang and Ziang Wei and Yang You},
    year={2025},
    journal={arXiv preprint arXiv:2503.09642},
}

星标历史

星标历史图表

项目介绍

Open-Sora: Democratizing Efficient Video Production for All

定制我的领域
23929.16 K2.99 K访问 GitHub