重新渲染视频:零镜头文本引导视频到视频翻译
杨帅、周一凡、刘紫薇和陈 在SIGGRAPH Asia 2023会议论文集
项目页面中更改洛伊
|纸 |补充视频 |输入数据和视频结果
摘要: 大型文本到图像扩散模型在生成高质量图像方面表现出了令人印象深刻的熟练程度。然而,当将这些模型应用于视频域时,确保视频帧之间的时间一致性仍然是一个巨大的挑战。该文提出一种新颖的零镜头文本引导视频到视频翻译框架,使图像模型适应视频。该框架包括两部分:关键帧翻译和完整视频翻译。第一部分使用适应的扩散模型来生成关键帧,并应用分层交叉帧约束来加强形状、纹理和颜色的一致性。第二部分通过时间感知补丁匹配和帧混合将关键帧传播到其他帧。我们的框架以低成本(无需重新训练或优化)实现了全局风格和局部纹理的时间一致性。改编与现有的图像扩散技术兼容,允许我们的框架利用它们,例如使用 LoRA 自定义特定主题,并使用 ControlNet 引入额外的空间指导。广泛的实验结果表明,我们提出的框架在渲染高质量和时间连贯的视频方面比现有方法有效。
特点:
请确保你的安装路径仅包含英文字母或 _
git submodule update --init --recursive)
git clone git@github.com:williamyang1991/Rerender_A_Video.git --recursive
cd Rerender_A_Video
pip install -r requirements.txt
你还可以从头开始创建新的 conda 环境。
conda env create -f environment.yml
conda activate rerender
需要 24GB 显存。请参考 https://github.com/williamyang1991/Rerender_A_Video/pull/23#issue-1900789461 以减少内存消耗。
./models
python install.py
rerender.py
python rerender.py --cfg config/real2sculpture.json
在运行上述 1-4 个步骤之前,你需要准备:
FileNotFoundError: [Errno 2] No such file or directory: 'xxxx.bin' or 'xxxx.jpg':确保你的路径仅包含英文字母或 _ (https://github.com/williamyang1991/Rerender_A_Video/issues/18#issuecomment-1723361433)
KeyError: 'dataset':将 Gradio 升级到最新版本 (https://github.com/williamyang1991/Rerender_A_Video/issues/14#issuecomment-1722778672)
ERR_ADDRESS_INVALID无法在浏览器中打开 webUI:在 webUI.py 中将 0.0.0.0 替换为 127.0.0.1 (https://github.com/williamyang1991/Rerender_A_Video/issues/19#issuecomment-1723685825)
CUDA out of memory: (https://github.com/williamyang1991/Rerender_A_Video/pull/23#issue-1900789461)
AttributeError: module 'keras.backend' has no attribute 'is_tensor':更新 einops (https://github.com/williamyang1991/Rerender_A_Video/issues/26#issuecomment-1726682446)
python webUI.py
Gradio 应用程序还允许你灵活更改推理选项。只需尝试一下即可了解更多详情。(对于WebUI,你需要在安装后下载revAnimated_v11并realisticVisionV20_v20)
./models/
上传你的视频,输入提示,选择种子,然后点击:
我们提供丰富的高级选项供你玩
sd_model_cfg.py
control_type = gr.Dropdown(['HED', 'canny', 'depth']
elif control_type == 'depth':
elif control_type == 'depth':
我们还提供了一个灵活的脚本来运行我们的方法。
rerender.py
通过命令行设置选项。例如
python rerender.py --input videos/pexels-antoni-shkraba-8048492-540x960-25fps.mp4 --output result/man/man.mp4 --prompt "a handsome man in van gogh painting"
该脚本将运行完整的管道。将在 创建一个工作目录,结果视频将另存为
result/man
result/man/man.mp4
通过配置文件设置选项。例如
python rerender.py --cfg config/van_gogh_man.json
该脚本将运行完整的管道。我们提供了目录中配置的一些示例。配置中的大多数选项与 WebUI 中的选项相同。请查看 WebUI 部分中的说明。
config
通过在配置中设置指定自定义模型。例如:
sd_model
{
"sd_model": "models/realisticVisionV20_v20.safetensors",
}
与WebUI类似,我们提供三步工作流程:重新渲染第一个关键帧,然后重新渲染完整关键帧,最后通过传播重新渲染完整视频。要仅运行一个步骤,请指定选项 ,并:
-one
-nb
-nr
python rerender.py --cfg config/van_gogh_man.json -one -nb
python rerender.py --cfg config/van_gogh_man.json -nb
python rerender.py --cfg config/van_gogh_man.json -nr
我们提供了一个单独的 Ebsynth python 脚本,其中包含通过示例设置视频样式中引入的时间混合算法,用于在关键帧之间插入样式。它可以独立于我们的重新渲染算法在你自己的风格化关键帧上工作。
video_blend.py
用法:
video_blend.py [-h] [--output OUTPUT] [--fps FPS] [--beg BEG] [--end END] [--itv ITV] [--key KEY]
[--n_proc N_PROC] [-ps] [-ne] [-tmp]
name
positional arguments:
name Path to input video
optional arguments:
-h, --help show this help message and exit
--output OUTPUT Path to output video
--fps FPS The FPS of output video
--beg BEG The index of the first frame to be stylized
--end END The index of the last frame to be stylized
--itv ITV The interval of key frame
--key KEY The subfolder name of stylized key frames
--n_proc N_PROC The max process count
-ps Use poisson gradient blending
-ne Do not run ebsynth (use previous ebsynth output)
-tmp Keep temporary output
例如,要在视频上运行 Ebsynth ,
man.mp4
videos/man/keys
0001.png
0011.png
videos/man/video
0001.png
0002.png
videos/man/blend.mp4
python video_blend.py videos/man \
--beg 1 \
--end 101 \
--itv 10 \
--key keys \
--output videos/man/blend.mp4 \
--fps 25.0 \
-ps
白色古希腊雕塑,米洛维纳斯,浅粉红色和蓝色背景 | 一个英俊的希腊男人 | 中国水墨画中的一座传统山峰 | 卡通老虎 |
中国水墨画中的天鹅,单色 | CG风格的美女 | 一个干净简单的白玉雕塑 | 深蓝色大海中的荧光水母 |
文本引导的虚拟角色生成。
视频风格化和视频编辑。
如果你发现这项工作对你的研究有用,请考虑引用我们的论文:
@inproceedings{yang2023rerender,
title = {Rerender A Video: Zero-Shot Text-Guided Video-to-Video Translation},
author = {Yang, Shuai and Zhou, Yifan and Liu, Ziwei and and Loy, Chen Change},
booktitle = {ACM SIGGRAPH Asia Conference Proceedings},
year = {2023},
}
该代码主要基于ControlNet,Stable Diffusion,GMFlow和 Ebsynth开发。