本项目参考自 JDiffusion 的 DreamBooth-Lora 。
按照 JDiffusion 的环境安装一节 安装必要的依赖。
接着设置运行脚本的权限:
chmod u+x ./dreambooth/*.sh
- 首先从比赛云盘下载对应的数据集,推荐将数据集目录
B下载到./B下 - 将
train_all.sh中的HF_HOME设置为本地模型路径,root设置为项目所在目录,BASE_INSTANCE_DIR设置为数据集对应的目录,GPU_COUNT设置为对应可用的显卡数量,MAX_NUM设置为数据集中的风格个数; - 然后进入目标文件夹下:
cd ./dreambooth/, 运行bash train_all.sh即可训练。保存的模型会存放至./dreambooth/results/prompt_v1_cosine_test/style_[训练epoch数]epoch目录下,例如:./dreambooth/results/prompt_v1_cosine_test/style_300epoch。
- 将
test_all.sh中的HF_HOME设置为本地模型路径,将run_all.py中的root设置为项目所在目录,dataset_root修改为数据集对应的目录,将max_num修改为数据集中的风格个数; - 进入目标文件夹下:
cd ./dreambooth/,运行bash test_all.sh进行推理。模型生成的图片会输出到./dreambooth/results/prompt_v1_cosine_test/outputs_[保存点训练epoch数]ckpt_[推理轮数]steps_[种子值]seed文件夹下,例如:./dreambooth/results/prompt_v1_cosine_test/outputs_300ckpt_200steps_76587seed。
@inproceedings{ruiz2023dreambooth,
title={Dreambooth: Fine tuning text-to-image diffusion models for subject-driven generation},
author={Ruiz, Nataniel and Li, Yuanzhen and Jampani, Varun and Pritch, Yael and Rubinstein, Michael and Aberman, Kfir},
booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
year={2023}
}