该存储库是Tune-A-Video的官方实现。
Tune-A-Video:用于文本到视频生成的图像扩散模型的一次性调整
Jay Zhangjie Wu、
Yixiao Ge、
Xintao Wang、
Stan Weixian Lei、
Yuchao Gu、
Yufei Shi、
Wynne Hsu、
Ying Shan、
Xiaohu Qie、
Mike Zheng Shou
给定一个视频文本对作为输入,我们的方法 Tune-A-Video 对预先训练的文本到图像扩散模型进行微调,以生成文本到视频。
🚨 宣布LOVEU-TGVE:一项基于 AI 的视频编辑的 CVPR 竞赛!提交截止日期为 6 月 5 日。不要错过!🤩
- [2023 年 2 月 22 日] 使用 DDIM 反转提高了一致性。
- [2023 年 2 月 8 日] Colab 演示发布!
- [2023 年 2 月 3 日] 预先训练的 Tune-A-Video 模型可在Hugging Face Library上使用!
- [2023/01/28] 新功能:调整个性化DreamBooth模型的视频。
- [2023/01/28] 代码发布!
pip install -r requirements.txt
强烈建议安装xformersenable_xformers_memory_efficient_attention=True
,以提高 GPU 的效率和速度。要启用 xformers,请设置(默认)。
[稳定扩散] 稳定扩散是一种潜在的文本到图像扩散模型,能够根据任何文本输入生成照片般逼真的图像。预先训练的稳定扩散模型可以从 Hugging Face 下载(例如,稳定扩散 v1-4、v2-1)。您还可以使用针对不同风格训练的微调稳定扩散模型(例如,现代迪士尼、Anything V4.0、Redshift等)。
[DreamBooth] DreamBooth是一种个性化文本转图像模型的方法,例如仅给出主题的几张图像(3~5 张图像),即可生成稳定扩散。在 DreamBooth 模型上调整视频可以生成特定主题的个性化文本转视频。Hugging Face上有一些公共 DreamBooth 模型(例如mr-potato-head )。您还可以按照此训练示例训练自己的 DreamBooth 模型。
要微调文本到图像扩散模型以生成文本到视频,请运行以下命令:
accelerate launch train_tuneavideo.py --config="configs/man-skiing.yaml"
注意:使用一个 A100 GPU,调整 24 帧视频通常需要300~500
几个步骤,大约需要几分钟。如果您的 GPU 内存有限,请减少此步骤。10~15
n_sample_frames
训练完成后,运行推理:
from tuneavideo.pipelines.pipeline_tuneavideo import TuneAVideoPipeline from tuneavideo.models.unet import UNet3DConditionModel from tuneavideo.util import save_videos_grid import torchpretrained_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")
输入视频 | 输出视频 | ||
“一只熊在弹吉他” | “1girl 正在弹吉他,白发,中等长度的头发,猫耳朵,闭着眼睛,可爱,围巾,夹克,户外,街道” | “1boy 正在弹吉他, 美少年, 休闲, 室内, 坐着, 咖啡店, 背景虚化” | “1 个女孩正在弹吉他,红头发,长发,美丽的眼睛,看着观众,可爱,裙子,海滩,大海” |
输入视频 | 输出视频 | ||
“一只熊在弹吉他” | “一只兔子在弹吉他,现代迪士尼风格” | “一位英俊的王子正在弹吉他,现代迪士尼风格” | “一位戴着墨镜的魔法公主在舞台上弹吉他,现代迪士尼风格” |
输入视频 | 输出视频 | ||
“一只熊在弹吉他” | “乐高积木做的土豆先生在雪地上弹吉他” | “戴着墨镜的土豆先生在海滩上弹吉他” | “土豆先生在星夜里弹吉他,梵高风格” |
如果您使用我们的工作,请引用我们的论文。
@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} }