• Stars
    star
    284
  • Rank 145,616 (Top 3 %)
  • Language
    Jupyter Notebook
  • License
    Apache License 2.0
  • Created over 1 year ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The official implementation for "Gen-L-Video: Multi-Text to Long Video Generation via Temporal Co-Denoising".

Gen-L-Video: Long Video Generation via Temporal Co-Denoising

This repository is the official implementation of Gen-L-Video.

Gen-L-Video: Multi-Text Conditioned Long Video Generation via Temporal Co-Denoising
Fu-Yun Wang, Wenshuo Chen, Guanglu Song, Han-Jia Ye, Yu Liu, Hongsheng Li

Project Website arXiv Open In Colab


Introduction โ€ข Comparisons โ€ข
Setup โ€ข Results โ€ข
Relevant Works โ€ข
Acknowledgments โ€ข Citation โ€ข Contact

Introduction

๐Ÿ”ฅ๐Ÿ”ฅ TL;DR: A universal methodology that extends short video diffusion models for efficient multi-text conditioned long video generation and editing.

Current methodologies for video generation and editing, while innovative, are often confined to extremely short videos (typically less than 24 frames) and are limited to a single text condition. These constraints significantly limit their applications given that real-world videos usually consist of multiple segments, each bearing different semantic information. To address this challenge, we introduce a novel paradigm dubbed as Gen-L-Video capable of extending off-the-shelf short video diffusion models for generating and editing videos comprising hundreds of frames with diverse semantic segments without introducing additional training, all while preserving content consistency.


Essentially, this procedure establishes an abstract long video generator and editor without necessitating any additional training, enabling the generation and editing of videos of any length using established short video generation and editing methodologies.

News

  • [2023.05.30]: Our paper is now available on arXiv.
  • [2023.05.30]: Our project page is now available on gen-long-video.
  • [2023.06.01]: Basic code framework is now open-sourced GLV.
  • [2023.06.01]: Scripts: one-shot-tuning, tuning-free-mix, tuning-free-inpaint is now available.
  • [2023.06.02]: Scripts for preparing control videos including canny, hough, hed, scribble,fake_scribble, pose, seg, depth, and normal is now available, following the instruction to get your own control videos.
  • [2023.06.04]: We now support very long Pose-to-Video generation with pretrained Follow-Your-Pose and extend it to multi-text conditioned without introducing higher computation or VRAM requirements.
  • [2023.06.04]: Colab demo released!
  • [2023.06.09]: We now support Video2Video generation (inspired by the image2image transition), capable of generating very realistic long videos of faces.

Setup

Clone the Repo

git clone https://github.com/G-U-N/Gen-L-Video
cd Gen-L-Video
# The repo might be too large to clone because many long gifs are over 100 M. Fork the repo, delete the statics, and then clone it. 

Install Environment via Anaconda

conda env create -f requirements.yml
conda activate glv
conda install pytorch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 pytorch-cuda=11.6 -c pytorch -c nvidia

Install Xformers

# (Optional) Makes the build much faster
pip install ninja
# Set TORCH_CUDA_ARCH_LIST if running and building on different GPU types
pip install -v -U git+https://github.com/facebookresearch/xformers.git@main#egg=xformers
# (this can take dozens of minutes)

Install SAM and Grounding DINO

pip install git+https://github.com/facebookresearch/segment-anything.git
pip install git+https://github.com/IDEA-Research/GroundingDINO.git

or

git clone https://github.com/facebookresearch/segment-anything.git
cd segment-anything
pip install -e .
cd ..
# If you have a CUDA environment, please make sure the environment variable CUDA_HOME is set. 
# If the cuda version of the system conflicts with the cudatoolkit version, See: https://github.com/G-U-N/Gen-L-Video/discussions/7
git clone https://github.com/IDEA-Research/GroundingDINO.git
cd GroundingDINO
pip install -e .

Note that if you are using GPU clusters that the management node has no access to GPU resources, you should submit the pip install -e . to the computing node as a computing task when building the GroundingDINO. Otherwise, it will not support detection computing through GPU.

Download Pretrained Weights

Make sure git-lfs is available. See: https://github.com/git-lfs/git-lfs/blob/main/INSTALLING.md

bash scripts/download_pretrained_models.sh

After downloading them, you should specify the absolute/relative path of them in the config files.

If you download all the above pretrained weights in the folder weights , set the configs files as follows:

  1. In configs/tuning-free-inpaint/girl-glass.yaml
sam_checkpoint: "weights/sam_vit_h_4b8939.pth"
groundingdino_checkpoint: "weights/groundingdino_swinb_cogcoor.pth"
controlnet_path: "weights/edit-anything-v0-3"
  1. In one-shot-tuning.py, set
adapter_paths={
    "pose":"weights/T2I-Adapter/models/t2iadapter_openpose_sd14v1.pth",
    "sketch":"weights/T2I-Adapter/models/t2iadapter_sketch_sd14v1.pth",
    "seg": "weights/T2I-Adapter/models/t2iadapter_seg_sd14v1.pth",
    "depth":"weights/T2I-Adapter/models/t2iadapter_depth_sd14v1.pth",
    "canny":"weights/T2I-Adapter/models/t2iadapter_canny_sd14v1.pth"
}
  1. In configs/one-shot-tuning/hike.yaml, set
pretrained_model_path: "weights/anything-v4.0"

Then all the other weights are able to be automatically downloaded through the API of Hugging Face.

For users who are unable to download weights automatically

Here is an additional instruction for installing and running grounding dino.

# Notice: If you use 'pip install git+https://github.com/IDEA-Research/GroundingDINO.git'
# You should modify GroundingDINO_SwinB_cfg.py in python site-packages directory
# e.g. ~/miniconda3/envs/glv/lib/python3.8/site-packages/groundingdino/config/GroundingDINO_SwinB_cfg.py
cd GroundingDINO/groundingdino/config/ 
vim GroundingDINO_SwinB_cfg.py

set

text_encoder_type = "[Your Path]/bert-base-uncased"

Then

vim GroundingDINO/groundingdino/util/get_tokenlizer.py

Set

def get_pretrained_language_model(text_encoder_type):
    if text_encoder_type == "bert-base-uncased" or text_encoder_type.split("/")[-1]=="bert-base-uncased":
        return BertModel.from_pretrained(text_encoder_type)
    if text_encoder_type == "roberta-base":
        return RobertaModel.from_pretrained(text_encoder_type)
    raise ValueError("Unknown text_encoder_type {}".format(text_encoder_type))

Now you should be able to run your Grounding DINO with pre-downloaded bert weights.

Get your own control videos

git clone https://github.com/lllyasviel/ControlNet.git
cd ControlNet
git checkout f4748e3
mv ../process_data.py .
python process_data.py --v_path=../data --t_path=../t_data --c_path=../c_data --fps=10

Inference

  1. One-Shot Tuning Method
accelerate launch one-shot-tuning.py --control=[your control]

[your control] can be set as pose , depth, seg, sketch, canny.

pose and depth are recommended.

  1. Tuning-Free Method for videos with smooth semantic changes.
accelerate launch tuning-free-mix.py
  1. Tuning-Free Edit Anything in Videos.
accelerate launch tuning-free-inpaint.py
  1. Long video generation with pretrained.
accelerate launch follow-your-pose-long.py
  1. Tuning-Free Long Video2Video generation
# canny 
accelerate launch tuning-free-control.py --config=./configs/tuning-free-control/girl-glass.yaml 
# hed
accelerate launch tuning-free-control.py --config=./configs/tuning-free-control/girl.yaml

Comparisons

Method Long Video Multi-Text Conditioned Pretraining-Free Parallel Denoising Versatile
Tune-A-Video โŒ โŒ โœ” โŒ โŒ
LVDM โœ” โŒ โŒ โŒ โŒ
NUWA-XL โœ” โœ” โŒ โœ” โŒ
Gen-L-Video โœ” โœ” โœ” โœ” โœ”

Results

Most of the results can be generated with a single RTX 3090.

Multi-Text Conditioned Long Video Generation

demon_slayer_resize.mp4

This video containing clips bearing various semantic information.

Long Video with Smooth Semantic Changes

All the following videos are directly generated with the pretrained Stable Diffusion weight without additional training.

Videos with Smooth Semantic Changes
"A man is boating, village." โ†’ "A man is walking by, city, sunset." "A jeep car is running on the beach, sunny.โ€ โ†’ "a jeep car is running on the beach, night." "Lion, Grass, Rainy." โ†’ "Cat, Grass, Sun." "A man is skiing in the sea." โ†’ "A man is surfing in the snow."

Edit Anything in Video

All the following videos are directly generated with the pretrained Stable Diffusion weight without additional training.

Edit Anything in Videos
Source Video Mask of Sunglasses "Sunglasses" โ†’ "Pink Sunglasses" "Sunglasses" โ†’ "Cyberpunk Sunglasses with Neon Lights"
Source Video Mask of Man "Man" โ†’ "Bat Man" "Man" โ†’ "Iron Man"

Controllable Video

Controllable Video
Pose Control "Iron Man is fighting in the snow." "A Van Gogh style painting of a man dancing." "A man is running in the fire."
Depth Control "Dog in the sun."" "Tiger in the sun." "Girl in the sun."

Tuning-Free Long Video-to-Video Generation

Tuning-Free Long Video-to-Video Generation
"Girls." "Girls wearing sunglasses."

Long Video Generation with Pretrained Short Text-to-Video Diffusion Model

All the following videos are directly generated with the pre-trained VideoCrafter without additional training.

Long Video Generation with Pretrained Short Text-to-Video Diffusion Model
"Astronaut riding a horse." (Isolated) "Astronaut riding a horse." (Gen-L-Video) "Astronaut riding a horse, Loving Vincent Style." (Isolated) "Astronaut riding a horse, Loving Vincent Style." (Gen-L-Video)
"A monkey is drinking water." (Isolated) "A monkey is drinking water." (Gen-L-Video) "A car is moving on the road." (Isolated) "A car is moving on the road." (Gen-L-Video)

Follow-Your-Pose: Long Video Generation with Pretrained Pose-to-Video

The original generated videos (gifs) are over 100 MB, we compress them to upload them to GitHub.

Long Video Generation with Pretrained Pose-to-Video
"Astronaut in the beach." "Astronaut in the beach."
"Hulk in the sea." "Stormtroopers in the beach."

Additional Results

Additional Results

Relevant Works

Tune-A-Video: One-Shot Tuning of Image Diffusion Models for Text-to-Video Generation. [paper] [code]

Fate-Zero: Fusing Attentions for Zero-shot Text-based Video Editing. [paper] [code]

Pix2Video: Video Editing using Image Diffusion. [paper] [code]

VideoCrafter: A Toolkit for Text-to-Video Generation and Editing. [paper] [code]

ControlVideo: Training-free Controllable Text-to-Video Generation. [paper] [code]

Text2Video-Zero: Text-to-Image Diffusion Models are Zero-Shot Video Generators. [paper] [code]

Other relevant works about video generation/editing can be obtained by this repo: Awesome-Video-Diffusion.

Acknowledgments

Citation

If you use any content of this repo for your work, please cite the following bib entry:

@article{wang2023gen,
  title={Gen-L-Video: Multi-Text to Long Video Generation via Temporal Co-Denoising},
  author={Wang, Fu-Yun and Chen, Wenshuo and Song, Guanglu and Ye, Han-Jia and Liu, Yu and Li, Hongsheng},
  journal={arXiv preprint arXiv:2305.18264},
  year={2023}
}

Contact

I welcome collaborations from individuals/institutions who share a common interest in my work. Whether you have ideas to contribute, suggestions for improvements, or would like to explore partnership opportunities, I am open to discussing any form of collaboration. Please feel free to contact the author: Fu-Yun Wang ([email protected]). Enjoy the code.

More Repositories

1

PyCIL

PyCIL: A Python Toolbox for Class-Incremental Learning
Python
804
star
2

AnimateLCM

[SIGGRAPH ASIA 2024 TCS] AnimateLCM: Computation-Efficient Personalized Style Video Generation without Personalized Video Data
Python
592
star
3

Phased-Consistency-Model

[NeurIPS 2024] Boosting the performance of consistency models with PCM!
Python
355
star
4

Be-Your-Outpainter

[ECCV 2024] Be-Your-Outpainter https://arxiv.org/abs/2403.13745
Python
211
star
5

Rectified-Diffusion

Rectified Diffusion: Straightness Is Not Your Need
Python
100
star
6

Motion-I2V

[SIGGRAPH 2024] Motion I2V: Consistent and Controllable Image-to-Video Generation with Explicit Motion Modeling
Python
95
star
7

a-PyTorch-Tutorial-to-Class-Incremental-Learning

a PyTorch Tutorial to Class-Incremental Learning | a Distributed Training Template of CIL with core code less than 100 lines.
Python
82
star
8

ECCV22-FOSTER

The official implementation for ECCV22 paper: "FOSTER: Feature Boosting and Compression for Class-Incremental Learning" in PyTorch.
Python
51
star
9

Awesome-Consistency-Models

Awesome List of Consistency Models
33
star
10

Pix2Video.pytorch

Implementation of the paper "Pix2Video: Video Editing using Image Diffusion"
Python
26
star
11

T2I-HumanFeedback

Implementations of Baseline Methods for Aligning Text2Img Diffusion Models with Human FeedBack
20
star
12

Awesome-Tuned-Text2Img-Diffusion

Awesome papers/projects about fine-tuning text2img diffusion models for new/reference concepts/domains.
16
star
13

ICLR23-BEEF

The implementation for ICLR2023 paper: "BEEF: Bi-Compatible Class-Incremental Learning via Energy-Based Expansion and Fusion" in PyTorch.
Python
14
star
14

Gen-L-2

Long video generation with short video diffusion models.
12
star
15

Stable-Consistency-Tuning

Stable Consistency Tuning: Understanding and Improving Consistency models
8
star
16

Mask-detector

An AI model to detect whether the man in the video is wearing the mask.
Java
5
star
17

2021NJUAP

ๅ—ไบฌๅคงๅญฆ2021้ซ˜็บง็จ‹ๅบ่ฎพ่ฎก่ฏพ่ฎพไธŽไฝœไธš
C++
4
star
18

Parallel-Computing-Project

Parallel algorithms (quick-sort, merge-sort , enumeration-sort) implemented by p-threads and CUDA
C++
3
star
19

ICS2020-workbench

ICS2020 mini-labs
C
3
star
20

G-U-N

2
star
21

Restricted-Boltzmann-Machine-for-AutoEncoder

reproduce and expansion: Hinton, Geoffrey E., and Ruslan R. Salakhutdinov. "Reducing the dimensionality of data with neural networks." science 313.5786 (2006): 504-507.
Python
2
star
22

cpp-2048-mcts

linuxไธ‹็š„C++็‰ˆ2048ๅฐๆธธๆˆไธŽๆ™บ่ƒฝAgent
C++
1
star