| 风格参考图 | 生成图1 | 生成图2 | 生成图3 |
|---|---|---|---|
![]() |
![]() |
![]() |
![]() |
| Cactus | Boat | Grass | Park |
![]() |
![]() |
![]() |
![]() |
| Dog | Bed | Leaf | Stadium |
本项目包含了第四届计图人工智能挑战赛 - 风格迁移图片生成(B榜)的代码实现。 本项目对参考的28种风格图片进行学习,在每种风格仅有3张参考图的条件下,设计了一套先生成,再风格注入的框架,其中风格注入模块是无训练的。 结果表明,对风格中特征的学习和主体的保留都取得了很好的效果。
本项目可在 1 张 4090 上运行,基础图片的训练时间约为 4 小时,推理出基础图片的时间约为 1.5 小时,对基础图片的风格调整,生成最终结果的时间大约为 4 小时,共计大约 9.5 小时。
- ubuntu 20.04 LTS
- python >= 3.9.0
- jittor >= 1.3.9.5
conda create -n jit python==3.9
conda activate jit
cd dreambooth
pip install -r requirements.txt
git clone https://github.com/JittorRepos/JDiffusion.git
cd JDiffusion
pip install -e .
安装JTorch版本的相关深度学习库:
pip install git+https://github.com/JittorRepos/jittor
pip install git+https://github.com/JittorRepos/jtorch
pip install git+https://github.com/JittorRepos/diffusers_jittor
pip install git+https://github.com/JittorRepos/transformers_jittor
使用的预训练模型为stabilityai/stable-diffusion-2-1 at main (huggingface.co)
参考风格数据(Style_B)见https://cloud.tsinghua.edu.cn/f/4caf92b9ac6444659597/?dl=1
下载解压到目录 ./B 内.
权重的训练可以运行以下命令:
cd stylebooth
bash train_all.sh
一键生成结果可以运行以下命令:
python test.py
@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},
pages={22500--22510},
year={2023}
}
@inproceedings{chung2024style,
title={Style injection in diffusion: A training-free approach for adapting large-scale diffusion models for style transfer},
author={Chung, Jiwoo and Hyun, Sangeek and Heo, Jae-Pil},
booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
pages={8795--8805},
year={2024}
}
如果有任何疑问请在issue中提出







