Doubiiu / DynamiCrafter

[ECCV 2024, Oral] DynamiCrafter: Animating Open-domain Images with Video Diffusion Priors
https://doubiiu.github.io/projects/DynamiCrafter/
Apache License 2.0
2.46k stars 197 forks source link
image-animation image-to-video video-generation

DynamiCrafter: Animating Open-domain Images with Video Diffusion Priors

     
[![Open in OpenXLab](https://cdn-static.openxlab.org.cn/app-center/openxlab_app.svg)](https://openxlab.org.cn/apps/detail/JinboXING/DynamiCrafter)            _**[Jinbo Xing](https://doubiiu.github.io/), [Menghan Xia](https://menghanxia.github.io), [Yong Zhang](https://yzhang2016.github.io), [Haoxin Chen](), [Wangbo Yu](),
[Hanyuan Liu](https://github.com/hyliu), [Gongye Liu](), [Xintao Wang](https://xinntao.github.io/), [Ying Shan](https://scholar.google.com/citations?hl=en&user=4oXBp9UAAAAJ&view_op=list_works&sortby=pubdate), [Tien-Tsin Wong](https://ttwong12.github.io/myself.html)**_

From CUHK and Tencent AI Lab. at European Conference on Computer Vision (ECCV) 2024, Oral

๐Ÿ”† Introduction

๐Ÿ”ฅ๐Ÿ”ฅ Training / Fine-tuning code is available NOW!!!

๐Ÿ”ฅ We 1024x576 version ranks 1st on the I2V benchmark list from VBench!
๐Ÿ”ฅ Generative frame interpolation / looping video generation model weights (320x512) have been released!
๐Ÿ”ฅ New Update Rolls Out for DynamiCrafter! Better Dynamic, Higher Resolution, and Stronger Coherence!
๐Ÿค— DynamiCrafter can animate open-domain still images based on text prompt by leveraging the pre-trained video diffusion priors. Please check our project page and paper for more information.

๐Ÿ‘€ Seeking comparisons with Stable Video Diffusion and PikaLabs? Click the image below.

1.1. Showcases (576x1024)

1.2. Showcases (320x512)

1.3. Showcases (256x256)

"bear playing guitar happily, snowing" "boy walking on the street"
### 2. Applications #### 2.1 Storytelling video generation (see project page for more details)
#### 2.2 Generative frame interpolation
Input starting frame Input ending frame Generated video
#### 2.3 Looping video generation
## ๐Ÿ“ Changelog - __[2024.06.14]__: ๐Ÿ”ฅ๐Ÿ”ฅ Release training code for interpolation. - __[2024.05.24]__: Release WebVid10M-motion annotations. - __[2024.05.05]__: Release training code. - __[2024.03.14]__: Release generative frame interpolation and looping video models (320x512). - __[2024.02.05]__: Release high-resolution models (320x512 & 576x1024). - __[2023.12.02]__: Launch the local Gradio demo. - __[2023.11.29]__: Release the main model at a resolution of 256x256. - __[2023.11.27]__: Launch the project page and update the arXiv preprint.
## ๐Ÿงฐ Models |Model|Resolution|GPU Mem. & Inference Time (A100, ddim 50steps)|Checkpoint| |:---------|:---------|:--------|:--------| |DynamiCrafter1024|576x1024|18.3GB & 75s (`perframe_ae=True`)|[Hugging Face](https://huggingface.co/Doubiiu/DynamiCrafter_1024/blob/main/model.ckpt)| |DynamiCrafter512|320x512|12.8GB & 20s (`perframe_ae=True`)|[Hugging Face](https://huggingface.co/Doubiiu/DynamiCrafter_512/blob/main/model.ckpt)| |DynamiCrafter256|256x256|11.9GB & 10s (`perframe_ae=False`)|[Hugging Face](https://huggingface.co/Doubiiu/DynamiCrafter/blob/main/model.ckpt)| |DynamiCrafter512_interp|320x512|12.8GB & 20s (`perframe_ae=True`)|[Hugging Face](https://huggingface.co/Doubiiu/DynamiCrafter_512_Interp/blob/main/model.ckpt)| Currently, our DynamiCrafter can support generating videos of up to 16 frames with a resolution of 576x1024. The inference time can be reduced by using fewer DDIM steps. GPU memory consumed on RTX 4090 reported by @noguchis in [Twitter](https://x.com/noguchis/status/1754488826016432341?s=20): 18.3GB (576x1024), 12.8GB (320x512), 11.9GB (256x256). ## โš™๏ธ Setup ### Install Environment via Anaconda (Recommended) ```bash conda create -n dynamicrafter python=3.8.5 conda activate dynamicrafter pip install -r requirements.txt ``` ## ๐Ÿ’ซ Inference ### 1. Command line ### Image-to-Video Generation 1) Download pretrained models via Hugging Face, and put the `model.ckpt` with the required resolution in `checkpoints/dynamicrafter_[1024|512|256]_v1/model.ckpt`. 2) Run the commands based on your devices and needs in terminal. ```bash # Run on a single GPU: # Select the model based on required resolutions: i.e., 1024|512|320: sh scripts/run.sh 1024 # Run on multiple GPUs for parallel inference: sh scripts/run_mp.sh 1024 ``` ### Generative Frame Interpolation / Looping Video Generation Download pretrained model DynamiCrafter512_interp and put the `model.ckpt` in `checkpoints/dynamicrafter_512_interp_v1/model.ckpt`. ```bash sh scripts/run_application.sh interp # Generate frame interpolation sh scripts/run_application.sh loop # Looping video generation ``` ### 2. Local Gradio demo ### Image-to-Video Generation 1. Download the pretrained models and put them in the corresponding directory according to the previous guidelines. 2. Input the following commands in terminal (choose a model based on the required resolution: 1024, 512 or 256). ```bash python gradio_app.py --res 1024 ``` ### Generative Frame Interpolation / Looping Video Generation Download the pretrained model and put it in the corresponding directory according to the previous guidelines. ```bash python gradio_app_interp_and_loop.py ``` ## ๐Ÿ’ฅ Training / Fine-tuning ### Image-to-Video Generation 0. Download the WebVid Dataset, and important items in `.csv` are `page_dir`, `videoid`, and `name`. 1. Download the pretrained models and put them in the corresponding directory according to the previous guidelines. 2. Change `` path in `training_[1024|512]_v1.0/run.sh` 3. Carefully check all paths in `training_[1024|512]_v1.0/config.yaml`, including `model:pretrained_checkpoint`, `data:data_dir`, and `data:meta_path`. 4. Input the following commands in terminal (choose a model based on the required resolution: 1024 or 512). We adopt `DDPShardedStrategy` by default for training, please make sure it is available in your pytorch_lightning. ```bash sh configs/training_1024_v1.0/run.sh ## fine-tune DynamiCrafter1024 ``` 5. All the checkpoints/tensorboard record/loginfo will be saved in ``. ### Generative Frame Interpolation Download pretrained model DynamiCrafter512_interp and put the `model.ckpt` in `checkpoints/dynamicrafter_512_interp_v1/model.ckpt`. Follow the same fine-tuning procedure in "Image-to-Video Generation", and run the script below: ```bash sh configs/training_512_v1.0/run_interp.sh ``` ## ๐ŸŽ WebVid-10M-motion annotations (~2.6M) The annoations of our WebVid-10M-motion is available on [Huggingface Dataset](https://huggingface.co/datasets/Doubiiu/webvid10m_motion). In addition to the original annotations, we add three more motion-related annotations: `dynamic_confidence`, `dynamic_wording`, and `dynamic_source_category`. Please refer to our [supplementary document](https://arxiv.org/pdf/2310.12190) (Section D) for more details. ## ๐Ÿค Community Support 1. ComfyUI and pruned models (bf16): [ComfyUI-DynamiCrafterWrapper](https://github.com/kijai/ComfyUI-DynamiCrafterWrapper) (Thanks to [kijai](https://twitter.com/kijaidesign)) |Model|Resolution|GPU Mem. |Checkpoint| |:---------|:---------|:--------|:--------| |DynamiCrafter1024|576x1024|10GB |[Hugging Face](https://huggingface.co/Kijai/DynamiCrafter_pruned/blob/main/dynamicrafter_1024_v1_bf16.safetensors)| |DynamiCrafter512_interp|320x512|8GB |[Hugging Face](https://huggingface.co/Kijai/DynamiCrafter_pruned/blob/main/dynamicrafter_512_interp_v1_bf16.safetensors)| 2. ComfyUI: [ComfyUI-DynamiCrafter](https://github.com/chaojie/ComfyUI-DynamiCrafter) (Thanks to [chaojie](https://github.com/chaojie)) 3. ComfyUI: [ComfyUI_Native_DynamiCrafter](https://github.com/ExponentialML/ComfyUI_Native_DynamiCrafter) (Thanks to [ExponentialML](https://github.com/ExponentialML)) 4. Docker: [DynamiCrafter_docker](https://github.com/maximofn/DynamiCrafter_docker) (Thanks to [maximofn](https://github.com/maximofn)) ## ๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ Crafter Family [VideoCrafter1](https://github.com/AILab-CVC/VideoCrafter): Framework for high-quality video generation. [ScaleCrafter](https://github.com/YingqingHe/ScaleCrafter): Tuning-free method for high-resolution image/video generation. [TaleCrafter](https://github.com/AILab-CVC/TaleCrafter): An interactive story visualization tool that supports multiple characters. [LongerCrafter](https://github.com/arthur-qiu/LongerCrafter): Tuning-free method for longer high-quality video generation. [MakeYourVideo, might be a Crafter:)](https://doubiiu.github.io/projects/Make-Your-Video/): Video generation/editing with textual and structural guidance. [StyleCrafter](https://gongyeliu.github.io/StyleCrafter.github.io/): Stylized-image-guided text-to-image and text-to-video generation. [ViewCrafter](https://github.com/Drexubery/ViewCrafter): Novel view synthesis by taming camera-pose-controlled DynamiCrafter. ## ๐Ÿ˜‰ Citation Please consider citing our paper if our code and dataset annotations are useful: ```bib @article{xing2023dynamicrafter, title={DynamiCrafter: Animating Open-domain Images with Video Diffusion Priors}, author={Xing, Jinbo and Xia, Menghan and Zhang, Yong and Chen, Haoxin and Yu, Wangbo and Liu, Hanyuan and Wang, Xintao and Wong, Tien-Tsin and Shan, Ying}, journal={arXiv preprint arXiv:2310.12190}, year={2023} } ``` ## ๐Ÿ™ Acknowledgements We would like to thank [AK(@_akhaliq)](https://twitter.com/_akhaliq?lang=en) for the help of setting up hugging face online demo, and [camenduru](https://twitter.com/camenduru) for providing the replicate & colab online demo, and [Xinliang](https://github.com/dailingx) for his support and contribution to the open source project. ## ๐Ÿ“ข Disclaimer This project strives to impact the domain of AI-driven video generation positively. Users are granted the freedom to create videos using this tool, but they are expected to comply with local laws and utilize it responsibly. The developers do not assume any responsibility for potential misuse by users. ****