DiffMorpher:释放图像变形扩散模型的能力
凯文 张 艺凡 周旭东 许心刚 潘✉ 戴博
✉通讯作者
网络演示
非常感谢OpenXLab对 NVIDIA A100 GPU 的支持!
要求
要安装要求,请首先在您的环境中运行以下命令:
pip install -r requirements.txt
要使用 CUDA 正确运行代码,您可以注释掉torch
和torchvision
,并根据PyTorchrequirement.txt
上的说明安装适当版本的torch
和。torchvision
您还可以从Huggingface下载预训练模型Stable Diffusion v2.1-base,并将其指定到本地目录。model_path
运行Gradio UI
要启动 DiffMorpher 的 Gradio UI,请在您的环境中运行以下命令:
python app.py
然后,默认情况下,您可以通过http://127.0.0.1:7860访问 UI 。
运行代码
您还可以使用以下命令运行代码:
python main.py
--image_path_0 [image_path_0] --image_path_1 [image_path_1]
--prompt_0 [prompt_0] --prompt_1 [prompt_1]
--output_path [output_path]
--use_adain --use_reschedule --save_inter
该脚本还支持以下选项:
--image_path_0
:第一张图片的路径(默认:“”)--prompt_0
:提示第一张图片(默认:“”)--image_path_1
:第二张图片的路径(默认:“”)--prompt_1
:第二张图片的提示(默认:“”)--model_path
:预训练模型路径(默认:“stabilityai/stable-diffusion-2-1-base”)--output_path
:输出图像的路径(默认:“”)--save_lora_dir
:输出lora目录的路径(默认:“./lora”)--load_lora_path_0
:第一张图片的lora目录路径(默认:“”)--load_lora_path_1
:第二张图片的lora目录路径(默认:“”)--use_adain
:使用 AdaIN(默认值:False)--use_reschedule
:使用重新安排采样(默认值:False)--lamb
:超参数�∈[0,1]对于 self-attention 替换,其中更大�表示更多替换(默认值:0.6)--fix_lora_value
:修复lora值(默认:LoRA Interpolation,不固定)--save_inter
:保存中间结果(默认:False)--num_frames
:要生成的帧数(默认值:50)--duration
:每帧的持续时间(默认值:50)
例子:
python main.py
--image_path_0 ./assets/Trump.jpg --image_path_1 ./assets/Biden.jpg
--prompt_0 "A photo of an American man" --prompt_1 "A photo of an American man"
--output_path "./results/Trump_Biden"
--use_adain --use_reschedule --save_inter
python main.py
--image_path_0 ./assets/vangogh.jpg --image_path_1 ./assets/pearlgirl.jpg
--prompt_0 "An oil painting of a man" --prompt_1 "An oil painting of a woman"
--output_path "./results/vangogh_pearlgirl"
--use_adain --use_reschedule --save_inter
python main.py
--image_path_0 ./assets/lion.png --image_path_1 ./assets/tiger.png
--prompt_0 "A photo of a lion" --prompt_1 "A photo of a tiger"
--output_path "./results/lion_tiger"
--use_adain --use_reschedule --save_inter
执照
与 DiffMorpher 算法相关的代码已获得LICENSE许可。
然而,这个项目主要建立在开源库differs之上,该库遵循单独的许可条款Apache License 2.0。(也为社区干杯!)
引文
@article{zhang2023diffmorpher,
title={DiffMorpher: Unleashing the Capability of Diffusion Models for Image Morphing},
author={Zhang, Kaiwen and Zhou, Yifan and Xu, Xudong and Pan, Xingang and Dai, Bo},
journal={arXiv preprint arXiv:2312.07409},
year={2023}
}