Project Icon

Gen-L-Video

无需额外训练实现多文本条件长视频生成和编辑

Gen-L-Video是一种扩展短视频扩散模型的视频生成方法,能实现多文本条件下的长视频生成和编辑。该方法无需额外训练即可处理数百帧的视频,并保持内容一致性。Gen-L-Video支持多语义段视频生成、平滑语义变化和视频内容编辑等功能,为长视频处理提供了一种通用解决方案。

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

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

Project Website arXiv Open In Colab

You might be interested in Gen-L^2, which works better.

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.

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

MethodLong VideoMulti-Text ConditionedPretraining-FreeParallel DenoisingVersatile
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

https://github.com/G-U-N/Gen-L-Video/assets/60997859/9b370894-708a-4ed2-a2ac-abfa93829ea6

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 VideoMask of Sunglasses"Sunglasses" → "Pink Sunglasses" "Sunglasses" → "Cyberpunk Sunglasses with Neon Lights"
Source VideoMask 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
项目侧边栏1项目侧边栏2
推荐项目
Project Cover

豆包MarsCode

豆包 MarsCode 是一款革命性的编程助手,通过AI技术提供代码补全、单测生成、代码解释和智能问答等功能,支持100+编程语言,与主流编辑器无缝集成,显著提升开发效率和代码质量。

Project Cover

AI写歌

Suno AI是一个革命性的AI音乐创作平台,能在短短30秒内帮助用户创作出一首完整的歌曲。无论是寻找创作灵感还是需要快速制作音乐,Suno AI都是音乐爱好者和专业人士的理想选择。

Project Cover

有言AI

有言平台提供一站式AIGC视频创作解决方案,通过智能技术简化视频制作流程。无论是企业宣传还是个人分享,有言都能帮助用户快速、轻松地制作出专业级别的视频内容。

Project Cover

Kimi

Kimi AI助手提供多语言对话支持,能够阅读和理解用户上传的文件内容,解析网页信息,并结合搜索结果为用户提供详尽的答案。无论是日常咨询还是专业问题,Kimi都能以友好、专业的方式提供帮助。

Project Cover

阿里绘蛙

绘蛙是阿里巴巴集团推出的革命性AI电商营销平台。利用尖端人工智能技术,为商家提供一键生成商品图和营销文案的服务,显著提升内容创作效率和营销效果。适用于淘宝、天猫等电商平台,让商品第一时间被种草。

Project Cover

吐司

探索Tensor.Art平台的独特AI模型,免费访问各种图像生成与AI训练工具,从Stable Diffusion等基础模型开始,轻松实现创新图像生成。体验前沿的AI技术,推动个人和企业的创新发展。

Project Cover

SubCat字幕猫

SubCat字幕猫APP是一款创新的视频播放器,它将改变您观看视频的方式!SubCat结合了先进的人工智能技术,为您提供即时视频字幕翻译,无论是本地视频还是网络流媒体,让您轻松享受各种语言的内容。

Project Cover

美间AI

美间AI创意设计平台,利用前沿AI技术,为设计师和营销人员提供一站式设计解决方案。从智能海报到3D效果图,再到文案生成,美间让创意设计更简单、更高效。

Project Cover

AIWritePaper论文写作

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

投诉举报邮箱: service@vectorlightyear.com
@2024 懂AI·鲁ICP备2024100362号-6·鲁公网安备37021002001498号