Tune-A-Video

Tune-A-Video

图像扩散模型微调实现高质量文本到视频转换

Tune-A-Video项目通过微调预训练的文本到图像扩散模型,实现高质量文本到视频生成。该方法仅需一个视频-文本对作为输入,即可快速适应新的视频生成任务。支持Stable Diffusion等多种预训练模型,能生成多样化风格的视频内容。项目开源代码实现,提供在线演示和预训练模型,为研究和开发提供便捷的文本到视频生成工具。

Tune-A-Video文本生成视频扩散模型人工智能计算机视觉Github开源项目

Tune-A-Video

这个仓库是 Tune-A-Video 的官方实现。

Tune-A-Video:图像扩散模型的一次性微调用于文本到视频生成 <br/> Jay Zhangjie Wu, Yixiao Ge, Xintao Wang, Stan Weixian Lei, Yuchao Gu, Yufei Shi, Wynne Hsu, Ying Shan, Xiaohu Qie, Mike Zheng Shou <br/>

项目网站 arXiv Hugging Face Spaces 在 Colab 中打开

<p align="center"> <img src="https://yellow-cdn.veclightyear.com/835a84d5/cbaa8660-5c58-40a0-9961-b6212ba0bb86.gif" width="1080px"/> <br> <em>给定一个视频-文本对作为输入,我们的方法 Tune-A-Video 微调预训练的文本到图像扩散模型用于文本到视频生成。</em> </p>

新闻

🚨 宣布 LOVEU-TGVE:一个基于 AI 的视频编辑 CVPR 比赛!提交截止日期为 6 月 5 日。不要错过!🤩

  • [2023/02/22] 使用 DDIM 反演改进一致性。
  • [2023/02/08] Colab 演示 发布!
  • [2023/02/03] 预训练的 Tune-A-Video 模型可在 Hugging Face 库 上获取!
  • [2023/01/28] 新功能:在个性化 DreamBooth 模型上微调视频。
  • [2023/01/28] 代码发布!

设置

要求

pip install -r requirements.txt

强烈建议安装 xformers 以提高 GPU 上的效率和速度。 要启用 xformers,请设置 enable_xformers_memory_efficient_attention=True(默认)。

权重

[Stable Diffusion] Stable Diffusion 是一个潜在的文本到图像扩散模型,能够根据任何文本输入生成逼真的图像。预训练的 Stable Diffusion 模型可以从 Hugging Face 下载(例如,Stable Diffusion v1-4v2-1)。您还可以使用在不同风格上训练的微调 Stable Diffusion 模型(例如,Modern DisneyAnything V4.0Redshift 等)。

[DreamBooth] DreamBooth 是一种方法,可以通过仅几张图像(3~5 张)个性化 Stable Diffusion 等文本到图像模型。在 DreamBooth 模型上微调视频允许对特定主题进行个性化的文本到视频生成。Hugging Face 上有一些公开的 DreamBooth 模型(例如,mr-potato-head)。您也可以按照这个训练示例训练自己的 DreamBooth 模型。

使用方法

训练

要微调文本到图像扩散模型用于文本到视频生成,请运行此命令:

accelerate launch train_tuneavideo.py --config="configs/man-skiing.yaml"

注意:微调一个 24 帧的视频通常需要 300~500 步,使用一个 A100 GPU 大约需要 10~15 分钟。 如果您的 GPU 内存有限,请减少 n_sample_frames

推理

训练完成后,运行推理:

from tuneavideo.pipelines.pipeline_tuneavideo import TuneAVideoPipeline from tuneavideo.models.unet import UNet3DConditionModel from tuneavideo.util import save_videos_grid import torch pretrained_model_path = "./checkpoints/stable-diffusion-v1-4" my_model_path = "./outputs/man-skiing" unet = UNet3DConditionModel.from_pretrained(my_model_path, subfolder='unet', torch_dtype=torch.float16).to('cuda') pipe = TuneAVideoPipeline.from_pretrained(pretrained_model_path, unet=unet, torch_dtype=torch.float16).to("cuda") pipe.enable_xformers_memory_efficient_attention() pipe.enable_vae_slicing() prompt = "spider man is skiing" ddim_inv_latent = torch.load(f"{my_model_path}/inv_latents/ddim_latent-500.pt").to(torch.float16) video = pipe(prompt, latents=ddim_inv_latent, video_length=24, height=512, width=512, num_inference_steps=50, guidance_scale=12.5).videos save_videos_grid(video, f"./{prompt}.gif")

结果

预训练 T2I(Stable Diffusion)

<table class="center"> <tr> <td style="text-align:center;"><b>输入视频</b></td> <td style="text-align:center;" colspan="3"><b>输出视频</b></td> </tr> <tr> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/d1696ac5-e6ce-4468-98dd-428b212f65df.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/0912b2e7-64a2-4823-bc1e-cdc48e784b69.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/d7203279-6342-4668-afb1-f63126d76f12.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/2b2acc67-39c0-472c-867a-3ce4fa7c970e.gif"></td> </tr> <tr> <td width=25% style="text-align:center;color:gray;">"一个男人在滑雪"</td> <td width=25% style="text-align:center;">"蜘蛛侠在海滩上滑雪,卡通风格"</td> <td width=25% style="text-align:center;">"神奇女侠戴着牛仔帽在滑雪"</td> <td width=25% style="text-align:center;">"一个男人穿着粉色衣服在日落时分滑雪"</td> </tr> <tr> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/01971ae5-4ed2-4628-9ca0-79f0d627571b.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/06931c01-2f50-4904-a6db-9a1c0e9a3f35.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/3f55ca96-6ba5-44ce-83c1-21d4bc3fff4c.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/64f27919-bad1-4b0f-a546-7394ba007e5e.gif"></td> </tr> <tr> <td width=25% style="text-align:center;color:gray;">"一只兔子在桌子上吃西瓜"</td> <td width=25% style="text-align:center;">"一只兔子<del>吃西瓜</del>在桌子上"</td> <td width=25% style="text-align:center;">"一只戴着太阳镜的猫在海滩上吃西瓜"</td> <td width=25% style="text-align:center;">"一只小狗在桌子上吃芝士汉堡,漫画风格"</td> </tr> <tr> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/df3eb1d7-a77d-48d8-b021-d279467880c8.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/9e2c7a55-66ce-4029-bc24-219713661d8f.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/ff222fa8-5693-48ac-9b14-71ee409f2f78.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/3e8aa384-2ffe-4f22-9079-ad5a587e4c47.gif"></td> </tr> <tr> <td width=25% style="text-align:center;color:gray;">"一辆吉普车在路上行驶"</td> <td width=25% style="text-align:center;">"一辆保时捷在海滩上行驶"</td> <td width=25% style="text-align:center;">"一辆汽车在路上行驶,卡通风格"</td> <td width=25% style="text-align:center;">"一辆汽车在雪地上行驶"</td> </tr> <tr> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/4e8d2edb-e892-4b14-8f79-7e2487d9b739.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/15a230ba-5bd8-42d5-859c-7f84e7d23882.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/49ffbe37-219d-4db3-8fdb-c3bca08e606b.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/854cad6c-f02f-4bdb-8abb-6aefa8e8fe47.gif"></td> </tr> <tr> <td width=25% style="text-align:center;color:gray;">"一个男人在运球"</td> <td width=25% style="text-align:center;">"詹姆斯·邦德在海滩上运球"</td> <td width=25% style="text-align:center;">"一位宇航员以卡通风格运球"</td> <td width=25% style="text-align:center;">"一个穿黑西装的乐高人在运球"</td> </tr> </table>

预训练的文本到图像模型(个性化DreamBooth)

<a href="https://huggingface.co/andite/anything-v4.0"><img src="https://yellow-cdn.veclightyear.com/835a84d5/0a4b2311-f66e-4d66-86cb-77f99b4ebf60.png" width="240px"/></a>

<table class="center"> <tr> <td style="text-align:center;"><b>输入视频</b></td> <td style="text-align:center;" colspan="3"><b>输出视频</b></td> </tr> <tr> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/fee2771f-c72b-464f-ae90-6bf8ffbb785b.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/783c563d-5799-421d-a1bf-9963db122c50.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/507972b0-5079-4de5-a7b3-3d59ae6eb47c.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/0f97825c-aa67-43aa-a59b-95e6b4f39db0.gif"></td> </tr> <tr> <td width=25% style="text-align:center;color:gray;">"一只熊在弹吉他"</td> <td width=25% style="text-align:center;">"一个女孩在弹吉他,白发,中等长度的头发,猫耳朵,闭着眼睛,可爱,围巾,夹克,户外,街道"</td> <td width=25% style="text-align:center;">"一个男孩在弹吉他,美少年,休闲装,室内,坐着,咖啡店,背景虚化"</td> <td width=25% style="text-align:center;">"一个女孩在弹吉他,红发,长发,美丽的眼睛,看着观众,可爱,连衣裙,海滩,大海"</td> </tr> </table>

<a href="https://huggingface.co/nitrosocke/mo-di-diffusion"><img src="https://yellow-cdn.veclightyear.com/835a84d5/3424afbf-1828-45c4-a8fc-172e50d6a859.png" width="240px"/></a>

<table class="center"> <tr> <td style="text-align:center;"><b>输入视频</b></td> <td style="text-align:center;" colspan="3"><b>输出视频</b></td> </tr> <tr> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/fee2771f-c72b-464f-ae90-6bf8ffbb785b.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/c18e6193-86d2-4300-ac86-5a811aa03bd2.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/79d51539-1223-4a16-9da0-d4ebf457d183.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/d578b933-34fe-434f-a763-0d069ea52b3c.gif"></td> </tr> <tr> <td width=25% style="text-align:center;color:gray;">"一只熊在弹吉他"</td> <td width=25% style="text-align:center;">"一只兔子在弹吉他,现代迪士尼风格"</td> <td width=25% style="text-align:center;">"一位英俊的王子在弹吉他,现代迪士尼风格"</td> <td width=25% style="text-align:center;">"一位戴着墨镜的魔法公主在舞台上弹吉他,现代迪士尼风格"</td> </tr> </table>

<a href="https://huggingface.co/sd-dreambooth-library/mr-potato-head"><img src="https://yellow-cdn.veclightyear.com/835a84d5/66159688-954d-4003-8a4b-6adddb2965a8.png" width="240px"/></a>

<table class="center"> <tr> <td style="text-align:center;"><b>输入视频</b></td> <td style="text-align:center;" colspan="3"><b>输出视频</b></td> </tr> <tr> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/fee2771f-c72b-464f-ae90-6bf8ffbb785b.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/d6a79351-a5d0-4daf-add9-a7713d678a79.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/dfc05b5f-6bd7-4913-9fcf-23ad39608510.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/525c0fe5-d966-4475-bc13-aaf13fff4c22.gif"></td> </tr> <tr> <td width=25% style="text-align:center;color:gray;">"一只熊在弹吉他"</td> <td width=25% style="text-align:center;">"乐高制作的薯头先生在雪地上弹吉他"</td> <td width=25% style="text-align:center;">"戴着墨镜的薯头先生在海滩上弹吉他"</td> <td width=25% style="text-align:center;">"薯头先生在梵高风格的星空下弹吉他"</td> </tr> </table>

引用

如果您使用了我们的工作,请引用我们的论文。

@inproceedings{wu2023tune, title={Tune-a-video: One-shot tuning of image diffusion models for text-to-video generation}, author={Wu, Jay Zhangjie and Ge, Yixiao and Wang, Xintao and Lei, Stan Weixian and Gu, Yuchao and Shi, Yufei and Hsu, Wynne and Shan, Ying and Qie, Xiaohu and Shou, Mike Zheng}, booktitle={Proceedings of the IEEE/CVF International Conference on Computer Vision}, pages={7623--7633}, year={2023} }

致谢

编辑推荐精选

Vora

Vora

免费创建高清无水印Sora视频

Vora是一个免费创建高清无水印Sora视频的AI工具

Refly.AI

Refly.AI

最适合小白的AI自动化工作流平台

无需编码,轻松生成可复用、可变现的AI自动化工作流

酷表ChatExcel

酷表ChatExcel

大模型驱动的Excel数据处理工具

基于大模型交互的表格处理系统,允许用户通过对话方式完成数据整理和可视化分析。系统采用机器学习算法解析用户指令,自动执行排序、公式计算和数据透视等操作,支持多种文件格式导入导出。数据处理响应速度保持在0.8秒以内,支持超过100万行数据的即时分析。

AI工具使用教程AI营销产品酷表ChatExcelAI智能客服
TRAE编程

TRAE编程

AI辅助编程,代码自动修复

Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。

热门AI工具生产力协作转型TraeAI IDE
AIWritePaper论文写作

AIWritePaper论文写作

AI论文写作指导平台

AIWritePaper论文写作是一站式AI论文写作辅助工具,简化了选题、文献检索至论文撰写的整个过程。通过简单设定,平台可快速生成高质量论文大纲和全文,配合图表、参考文献等一应俱全,同时提供开题报告和答辩PPT等增值服务,保障数据安全,有效提升写作效率和论文质量。

数据安全AI助手热门AI工具AI辅助写作AI论文工具论文写作智能生成大纲
博思AIPPT

博思AIPPT

AI一键生成PPT,就用博思AIPPT!

博思AIPPT,新一代的AI生成PPT平台,支持智能生成PPT、AI美化PPT、文本&链接生成PPT、导入Word/PDF/Markdown文档生成PPT等,内置海量精美PPT模板,涵盖商务、教育、科技等不同风格,同时针对每个页面提供多种版式,一键自适应切换,完美适配各种办公场景。

热门AI工具AI办公办公工具智能排版AI生成PPT博思AIPPT海量精品模板AI创作
潮际好麦

潮际好麦

AI赋能电商视觉革命,一站式智能商拍平台

潮际好麦深耕服装行业,是国内AI试衣效果最好的软件。使用先进AIGC能力为电商卖家批量提供优质的、低成本的商拍图。合作品牌有Shein、Lazada、安踏、百丽等65个国内外头部品牌,以及国内10万+淘宝、天猫、京东等主流平台的品牌商家,为卖家节省将近85%的出图成本,提升约3倍出图效率,让品牌能够快速上架。

iTerms

iTerms

企业专属的AI法律顾问

iTerms是法大大集团旗下法律子品牌,基于最先进的大语言模型(LLM)、专业的法律知识库和强大的智能体架构,帮助企业扫清合规障碍,筑牢风控防线,成为您企业专属的AI法律顾问。

SimilarWeb流量提升

SimilarWeb流量提升

稳定高效的流量提升解决方案,助力品牌曝光

稳定高效的流量提升解决方案,助力品牌曝光

Sora2视频免费生成

Sora2视频免费生成

最新版Sora2模型免费使用,一键生成无水印视频

最新版Sora2模型免费使用,一键生成无水印视频

下拉加载更多