智谱AI版Sora开源!首个可商用,在线可玩,5小时GitHub狂揽3.7K星

金磊 发自 凹非寺
量子位 | 公众号 QbitAI

国产版Sora真的卷疯了。

就在刚刚,智谱AI直接把清影视频生成背后的大模型给开源了

而且是首个可商用的那种哦!

29e37ca906137f58e1dcf505c42ffbea.png

这个模型的名字叫做CogVideoX,刚刚在GitHub发布仅5个小时,便狂揽了3.7K个Star0a1a80099b9470ab1bc7b15ce433327f.png️。

ef3e74653515ece1dc181332117103d4.png

我们直接来看下效果。

Prompt 1,人物大特写

In the haunting backdrop of a war-torn city, where ruins and crumbled walls tell a story of devastation, a poignant close-up frames a young girl. Her face is smudged with ash, a silent testament to the chaos around her. Her eyes glistening with a mix of sorrow and resilience, capturing the raw emotion of a world that has lost its innocence to the ravages of conflict.

可以看到,不仅人物眼睛等细节非常高清,眨眼前后的连贯性也是hold住了。

再来Prompt 2,一镜到底

The camera follows behind a white vintage SUV with a black roof rack as it speeds up a steep dirt road surrounded by pine trees on a steep mountain slope, dust kicks up from it’s tires, the sunlight shines on the SUV as it speeds along the dirt road, casting a warm glow over the scene. The dirt road curves gently into the distance, with no other cars or vehicles in sight. The trees on either side of the road are redwoods, with patches of greenery scattered throughout. The car is seen from the rear following the curve with ease, making it seem as if it is on a rugged drive through the rugged terrain. The dirt road itself is surrounded by steep hills and mountains, with a clear blue sky above with wispy clouds.

光影、远景、近景,以及车辆行驶的过程,统统都拿捏住了。

而且这些效果还不只是官方一个发布动作而已,是人人可以在线可玩的哦~

单卡A100,90秒即可生成

值得一提的是,智谱AI的CogVideoX是包含多个不同尺寸,而这次开源的是CogVideoX-2B。

它的相关基础信息如下所示:

adc933cc3bc96309aee059a81ec5bed4.png

它在FP-16精度下的推理仅需18GB显存,微调则只需要40GB显存,这意味着单张4090显卡即可进行推理,而单张A6000显卡即可完成微调。

据了解,这个模型已经支持在HuggingFace的diffusers库中进行部署,操作也是非常简单,只有2步:

1、安装对应的依赖

pip install --upgrade opencv-python transformers acc
pip install git+https://github.com/huggingface/diffusers.git@878f609aa5ce4a78fea0f048726889debde1d7e8#egg=diffusers # Still in PR

2、运行代码

import torch
from diffusers import CogVideoXPipeline
from diffusers.utils import export_to_video

prompt = "A panda, dressed in a small, red jacket and a tiny hat, sits on a wooden stool in a serene bamboo forest. The panda's fluffy paws strum a miniature acoustic guitar, producing soft, melodic tunes. Nearby, a few other pandas gather, watching curiously and some clapping in rhythm. Sunlight filters through the tall bamboo, casting a gentle glow on the scene. The panda's face is expressive, showing concentration and joy as it plays. The background includes a small, flowing stream and vibrant green foliage, enhancing the peaceful and magical atmosphere of this unique musical performance."

pipe = CogVideoXPipeline.from_pretrained(
    "THUDM/CogVideoX-2b",
    torch_dtype=torch.float16
).to("cuda")

prompt_embeds, _ = pipe.encode_prompt(
    prompt=prompt,
    do_classifier_free_guidance=True,
    num_videos_per_prompt=1,
    max_sequence_length=226,
    device="cuda",
    dtype=torch.float16,
)

video = pipe(
    num_inference_steps=50,
    guidance_scale=6,
    prompt_embeds=prompt_embeds,
).frames[0]

export_to_video(video, "output.mp4", fps=8)

并且在单卡A100上,按照刚才的步骤操作,生成视频仅需90秒。

不仅如此,在HuggingFace上,智谱AI也搞了在线可玩的demo,亲测效果如下:

可以看到,生成后的结果不仅可以以.mp4的方式下载,还提供了GIF的格式。

那么接下来的一个问题,智谱AI是如何做到的?

论文也已公开

智谱AI这次不仅是将视频生成模型开源,背后的技术报告也是一并被发布了出来。

396432a7f6335e8cd4f6dec088597ddc.png

纵观报告内容,有三大技术亮点值得说道说道。

首先便是团队自研了一个高效的三维变分自编码器结构(3D VAE),将原视频空间压缩至2%大小,大大减少了视频扩散生成模型的训练成本及训练难度。

模型结构包括编码器、解码器和潜在空间正则化器,通过四个阶段的下采样和上采样实现压缩。时间因果卷积确保了信息的因果性,减少了通信开销。团队采用上下文并行技术以适应大规模视频处理。

在实验中,团队发现大分辨率编码易于泛化,而增加帧数则挑战较大。

因此,团队分两阶段训练模型:首先在较低帧率和小批量上训练,然后通过上下文并行在更高帧率上进行微调。训练损失函数结合了L2损失、LPIPS感知损失和3D判别器的GAN损失。

e402f6e11cebd5f056e4328d8a2de434.png

其次是专家 Transformer

团队使用VAE的编码器将视频压缩至潜在空间,然后将潜在空间分割成块并展开成长的序列嵌入z_vision。

同时,他们使用T5,将文本输入编码为文本嵌入z_text,然后将z_text和z_vision沿序列维度拼接。拼接后的嵌入被送入专家Transformer块堆栈中处理。

最后,团队反向拼接嵌入来恢复原始潜在空间形状,并使用VAE进行解码以重建视频。

01af9a454e4c1b18b2f0ffa4b7cee5bc.png

最后的亮点,便是在于数据了。

团队开发了负面标签来识别和排除低质量视频,如过度编辑、运动不连贯、质量低下、讲座式、文本主导和屏幕噪音视频。

通过video-llama训练的过滤器,他们标注并筛选了20000个视频数据点。同时,计算光流和美学分数,动态调整阈值,确保生成视频的质量。

视频数据通常没有文本描述,需要转换为文本描述以供文本到视频模型训练。现有的视频字幕数据集字幕较短,无法全面描述视频内容。

为此,团队还提出了一种从图像字幕生成视频字幕的管道,并微调端到端的视频字幕模型以获得更密集的字幕。

这种方法通过Panda70M模型生成简短字幕,使用CogView3模型生成密集图像字幕,然后使用GPT-4模型总结生成最终的短视频。

他们还微调了一个基于CogVLM2-Video和Llama 3的CogVLM2-Caption模型,使用密集字幕数据进行训练,以加速视频字幕生成过程。

f2e70965278d9dc0da3d9d0190464980.png

以上便是CogVideoX其背后的技术实力了。

One More Thing

在视频生成这个领域,Runway家的Gen-3也有新动作——

Gen-3 Alpha的文生视频,现在支持把“喂”进去的图片,不仅可以作为视频的第一帧,也可以作为视频的最后一帧。

颇有种AI让时间倒流的感觉。

来看下效果:

最后,关于智谱AI开源的视频生成大模型,相关链接附在下面喽~

代码仓库:
https://github.com/THUDM/CogVideo

模型下载:
https://huggingface.co/THUDM/CogVideoX-2b

技术报告:
https://github.com/THUDM/CogVideo/blob/main/resources/CogVideoX.pdf

在线体验:
https://huggingface.co/spaces/THUDM/CogVideoX

量子位年度AI主题策划正在征集中!

欢迎投稿专题 一千零一个AI应365行AI落地方案

或与我们分享你在寻找的AI产品,或发现的AI新动向

6096474fa2801bfb56b6ceb63e067fbf.png

点这里👇关注我,记得标星哦~

  • 1
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值