Gen-L-Video

Gen-L-Video

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

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

Gen-L-Video长视频生成多文本条件视频编辑无需预训练Github开源项目

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 <font color=#FF2000> universal</font> methodology that extends short video diffusion models for efficient <font color=#FF2000>multi-text conditioned long video</font> 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.

<p align="center"> <img src="./statics/imgs/lvdm.png" width="1080px"/> <br> <em>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.</em> </p>

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

<table class="center"> <tr> <td>Method</td> <td>Long Video</td> <td>Multi-Text Conditioned</td> <td>Pretraining-Free</td> <td>Parallel Denoising</td> <td>Versatile</td> </tr> <tr> <td>Tune-A-Video</td> <td>❌</td> <td>❌</td> <td>✔</td> <td>❌</td> <td>❌</td> </tr> <tr> <td>LVDM</td> <td>✔</td> <td>❌</td> <td>❌</td> <td>❌</td> <td>❌</td> </tr> <tr> <td>NUWA-XL</td> <td>✔</td> <td>✔</td> <td>❌</td> <td>✔</td> <td>❌</td> </tr> <tr> <td>Gen-L-Video</td> <td>✔</td> <td>✔</td> <td>✔</td> <td>✔</td> <td>✔</td> </tr> </table>

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.

<img src="./statics/imgs/example.png" width=800px>

Long Video with Smooth Semantic Changes

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

<table class="center"> <tr> <td style="text-align:center;" colspan="4"><b>Videos with Smooth Semantic Changes</b></td> </tr> <tr> <td><img src="./statics/gifs/boat-walk-mix.gif"></td> <td><img src="./statics/gifs/car-turn-beach-mix.gif"></td> <td><img src="./statics/gifs/lion-cat-mix.gif"></td> <td><img src="./statics/gifs/surf-skiing-mix.gif"></td> </tr> <tr> <td width=25% style="text-align:center;">"A man is boating, village." → "A man is walking by, city, sunset."</td> <td width=25% style="text-align:center;">"A jeep car is running on the beach, sunny.” → "a jeep car is running on the beach, night."</td> <td width=25% style="text-align:center;">"Lion, Grass, Rainy." → "Cat, Grass, Sun." </td> <td width=25% style="text-align:center;">"A man is skiing in the sea." → "A man is surfing in the snow."</td> </tr> </table>

Edit Anything in Video

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

<table class="center"> <tr> <td style="text-align:center;" colspan="4"><b>Edit Anything in Videos</b></td> </tr> <tr> <td><img src="./statics/gifs/girl-glass-source.gif"></td> <td><img src="./statics/gifs/girl-glass-mask.gif"></td> <td><img src="./statics/gifs/girl-glass-pink.gif"></td> <td><img src="./statics/gifs/girl-glass-cyberpunk.gif"></td> </tr> <tr> <td width=25% style="text-align:center;">Source Video</td> <td width=25% style="text-align:center;">Mask of Sunglasses</td> <td width=25% style="text-align:center;">"Sunglasses" → "Pink Sunglasses" </td> <td width=25% style="text-align:center;">"Sunglasses" → "Cyberpunk Sunglasses with Neon Lights"</td> </tr> <tr> <td><img src="./statics/gifs/man-surfing-source.gif"></td> <td><img src="./statics/gifs/man-surfing-mask.gif"></td> <td><img src="./statics/gifs/man-surfing-batman.gif"></td> <td><img src="./statics/gifs/man-surfing-ironman.gif"></td> </tr> <tr> <td width=25% style="text-align:center;">Source Video</td> <td width=25% style="text-align:center;">Mask of Man</td> <td width=25% style="text-align:center;">"Man" → "Bat Man" </td> <td width=25% style="text-align:center;">"Man" → "Iron Man"</td> </tr> </table>

Controllable Video

<table class="center"> <tr> <td style="text-align:center;" colspan="4"><b>Controllable Video</b></td> </tr> <tr> <td><img src="./statics/gifs/tennis-pose.gif"></td> <td><img src="./statics/gifs/iron-man-tennis.gif"></td> <td><img src="./statics/gifs/vangogh-tennis.gif"></td> <td><img src="./statics/gifs/fire-tennis.gif"></td> </tr> <tr> <td width=25% style="text-align:center;">Pose Control</td> <td width=25% style="text-align:center;">"Iron Man is fighting in the snow."</td> <td width=25% style="text-align:center;">"A Van Gogh style painting of a man dancing."</td> <td width=25% style="text-align:center;">"A man is running in the fire."</td> </tr> <tr> <td><img src="./statics/gifs/cat-in-the-sun-depth.gif"></td> <td><img src="./statics/gifs/dog-in-the-sun.gif"></td> <td><img src="./statics/gifs/tiger-in-the-sun.gif"></td> <td><img src="./statics/gifs/girl-in-the-sun.gif"></td> </tr> <tr> <td width=25% style="text-align:center;">Depth Control</td> <td width=25% style="text-align:center;">"Dog in the sun.""</td> <td width=25% style="text-align:center;">"Tiger in the sun."</td> <td width=25% style="text-align:center;">"Girl in the sun."</td> </tr> </table>

Tuning-Free Long Video-to-Video Generation

<table class="center"> <tr> <td style="text-align:center;" colspan="2"><b>Tuning-Free Long Video-to-Video Generation</b></td> </tr> <tr> <td><img src="./statics/gifs/girl.gif"></td> <td><img src="./statics/gifs/girl-glass.gif"></td> </tr> <tr> <td width=50% style="text-align:center;"> "Girls."</td> <td width=50% style="text-align:center;"> "Girls wearing sunglasses."</td> </tr> </table>

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.

<table class="center"> <tr> <td style="text-align:center;" colspan="4"><b>Long Video Generation with Pretrained Short Text-to-Video Diffusion Model</b></td> </tr> <tr> <td><img src="./statics/gifs/ride-horse-iso-1.gif"></td> <td><img src="./statics/gifs/ride-horse-2.gif"></td> <td><img src="./statics/gifs/ride-horse-iso-2.gif"></td> <td><img src="./statics/gifs/ride-horse-4.gif"></td> </tr> <tr> <td width=25% style="text-align:center;"> "Astronaut riding a horse." (Isolated)</td> <td width=25% style="text-align:center;">"Astronaut riding a horse." (Gen-L-Video)</td> <td width=25% style="text-align:center;">"Astronaut riding a horse, Loving Vincent Style." (Isolated)</td> <td width=25% style="text-align:center;">"Astronaut riding a horse, Loving Vincent Style." (Gen-L-Video)</td> </tr> <tr> <td><img src="./statics/gifs/monkey-drinking-iso.gif"></td> <td><img src="./statics/gifs/monkey-drinking.gif"></td> <td><img src="./statics/gifs/car-moving-iso.gif"></td> <td><img src="./statics/gifs/car-moving.gif"></td> </tr> <tr> <td width=25% style="text-align:center;">"A monkey is drinking water." (Isolated)</td> <td width=25% style="text-align:center;">"A monkey

编辑推荐精选

TRAE编程

TRAE编程

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

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

热门AI工具生产力协作转型TraeAI IDE
蛙蛙写作

蛙蛙写作

AI小说写作助手,一站式润色、改写、扩写

蛙蛙写作—国内先进的AI写作平台,涵盖小说、学术、社交媒体等多场景。提供续写、改写、润色等功能,助力创作者高效优化写作流程。界面简洁,功能全面,适合各类写作者提升内容品质和工作效率。

AI助手AI工具AI写作工具AI辅助写作蛙蛙写作学术助手办公助手营销助手
问小白

问小白

全能AI智能助手,随时解答生活与工作的多样问题

问小白,由元石科技研发的AI智能助手,快速准确地解答各种生活和工作问题,包括但不限于搜索、规划和社交互动,帮助用户在日常生活中提高效率,轻松管理个人事务。

聊天机器人AI助手热门AI工具AI对话
Transly

Transly

实时语音翻译/同声传译工具

Transly是一个多场景的AI大语言模型驱动的同声传译、专业翻译助手,它拥有超精准的音频识别翻译能力,几乎零延迟的使用体验和支持多国语言可以让你带它走遍全球,无论你是留学生、商务人士、韩剧美剧爱好者,还是出国游玩、多国会议、跨国追星等等,都可以满足你所有需要同传的场景需求,线上线下通用,扫除语言障碍,让全世界的语言交流不再有国界。

讯飞智文

讯飞智文

一键生成PPT和Word,让学习生活更轻松

讯飞智文是一个利用 AI 技术的项目,能够帮助用户生成 PPT 以及各类文档。无论是商业领域的市场分析报告、年度目标制定,还是学生群体的职业生涯规划、实习避坑指南,亦或是活动策划、旅游攻略等内容,它都能提供支持,帮助用户精准表达,轻松呈现各种信息。

热门AI工具AI办公办公工具讯飞智文AI在线生成PPTAI撰写助手多语种文档生成AI自动配图
讯飞星火

讯飞星火

深度推理能力全新升级,全面对标OpenAI o1

科大讯飞的星火大模型,支持语言理解、知识问答和文本创作等多功能,适用于多种文件和业务场景,提升办公和日常生活的效率。讯飞星火是一个提供丰富智能服务的平台,涵盖科技资讯、图像创作、写作辅助、编程解答、科研文献解读等功能,能为不同需求的用户提供便捷高效的帮助,助力用户轻松获取信息、解决问题,满足多样化使用场景。

模型训练热门AI工具内容创作智能问答AI开发讯飞星火大模型多语种支持智慧生活
Spark-TTS

Spark-TTS

一种基于大语言模型的高效单流解耦语音令牌文本到语音合成模型

Spark-TTS 是一个基于 PyTorch 的开源文本到语音合成项目,由多个知名机构联合参与。该项目提供了高效的 LLM(大语言模型)驱动的语音合成方案,支持语音克隆和语音创建功能,可通过命令行界面(CLI)和 Web UI 两种方式使用。用户可以根据需求调整语音的性别、音高、速度等参数,生成高质量的语音。该项目适用于多种场景,如有声读物制作、智能语音助手开发等。

咔片PPT

咔片PPT

AI助力,做PPT更简单!

咔片是一款轻量化在线演示设计工具,借助 AI 技术,实现从内容生成到智能设计的一站式 PPT 制作服务。支持多种文档格式导入生成 PPT,提供海量模板、智能美化、素材替换等功能,适用于销售、教师、学生等各类人群,能高效制作出高品质 PPT,满足不同场景演示需求。

讯飞绘文

讯飞绘文

选题、配图、成文,一站式创作,让内容运营更高效

讯飞绘文,一个AI集成平台,支持写作、选题、配图、排版和发布。高效生成适用于各类媒体的定制内容,加速品牌传播,提升内容营销效果。

AI助手热门AI工具AI创作AI辅助写作讯飞绘文内容运营个性化文章多平台分发
材料星

材料星

专业的AI公文写作平台,公文写作神器

AI 材料星,专业的 AI 公文写作辅助平台,为体制内工作人员提供高效的公文写作解决方案。拥有海量公文文库、9 大核心 AI 功能,支持 30 + 文稿类型生成,助力快速完成领导讲话、工作总结、述职报告等材料,提升办公效率,是体制打工人的得力写作神器。

下拉加载更多