Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,93 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
---
|
| 4 |
+
language:
|
| 5 |
+
- en
|
| 6 |
+
pipeline_tag: text-to-image
|
| 7 |
+
---
|
| 8 |
+
# BizGen: Advancing Article-level Visual Text Rendering for Infographics Generation
|
| 9 |
+
|
| 10 |
+
<a href="https://arxiv.org/abs/2406.04314"><img src="https://img.shields.io/badge/Paper-arXiv-red?style=for-the-badge" height=22.5></a>
|
| 11 |
+
<a href="https://github.com/RockeyCoss/SPO"><img src="https://img.shields.io/badge/Gihub-Code-succees?style=for-the-badge&logo=GitHub" height=22.5></a>
|
| 12 |
+
<a href="https://rockeycoss.github.io/spo.github.io/"><img src="https://img.shields.io/badge/Project-Page-blue?style=for-the-badge" height=22.5></a>
|
| 13 |
+
|
| 14 |
+
<table>
|
| 15 |
+
<tr>
|
| 16 |
+
<td><img src="assets/imgs/0.png" alt="teaser example 0" width="200"/></td>
|
| 17 |
+
<td><img src="assets/imgs/1.png" alt="teaser example 1" width="200"/></td>
|
| 18 |
+
<td><img src="assets/imgs/2.png" alt="teaser example 2" width="200"/></td>
|
| 19 |
+
<td><img src="assets/imgs/3.png" alt="teaser example 3" width="200"/></td>
|
| 20 |
+
</tr>
|
| 21 |
+
</table>
|
| 22 |
+
|
| 23 |
+
## Abstract
|
| 24 |
+
<p>
|
| 25 |
+
Generating visually appealing images is fundamental to modern text-to-image generation models.
|
| 26 |
+
A potential solution to better aesthetics is direct preference optimization (DPO),
|
| 27 |
+
which has been applied to diffusion models to improve general image quality including prompt alignment and aesthetics.
|
| 28 |
+
Popular DPO methods propagate preference labels from clean image pairs to all the intermediate steps along the two generation trajectories.
|
| 29 |
+
However, preference labels provided in existing datasets are blended with layout and aesthetic opinions, which would disagree with aesthetic preference.
|
| 30 |
+
Even if aesthetic labels were provided (at substantial cost), it would be hard for the two-trajectory methods to capture nuanced visual differences at different steps.
|
| 31 |
+
</p>
|
| 32 |
+
<p>
|
| 33 |
+
To improve aesthetics economically, this paper uses existing generic preference data and introduces step-by-step preference optimization
|
| 34 |
+
(SPO) that discards the propagation strategy and allows fine-grained image details to be assessed. Specifically,
|
| 35 |
+
at each denoising step, we 1) sample a pool of candidates by denoising from a shared noise latent,
|
| 36 |
+
2) use a step-aware preference model to find a suitable win-lose pair to supervise the diffusion model, and
|
| 37 |
+
3) randomly select one from the pool to initialize the next denoising step.
|
| 38 |
+
This strategy ensures that diffusion models focus on the subtle, fine-grained visual differences
|
| 39 |
+
instead of layout aspect. We find that aesthetic can be significantly enhanced by accumulating these
|
| 40 |
+
improved minor differences.
|
| 41 |
+
</p>
|
| 42 |
+
<p>
|
| 43 |
+
When fine-tuning Stable Diffusion v1.5 and SDXL, SPO yields significant
|
| 44 |
+
improvements in aesthetics compared with existing DPO methods while not sacrificing image-text alignment
|
| 45 |
+
compared with vanilla models. Moreover, SPO converges much faster than DPO methods due to the step-by-step
|
| 46 |
+
alignment of fine-grained visual details.
|
| 47 |
+
</p>
|
| 48 |
+
|
| 49 |
+
## Model Description
|
| 50 |
+
|
| 51 |
+
This model is fine-tuned from [stable-diffusion-xl-base-1.0](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0). It has been trained on 4,000 prompts for 10 epochs.
|
| 52 |
+
|
| 53 |
+
This is a merged checkpoint that combines the LoRA checkpoint with the base model [stable-diffusion-xl-base-1.0](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0). If you want to access the LoRA checkpoint, please visit [SPO-SDXL_4k-p_10ep_LoRA](https://huggingface.co/SPO-Diffusion-Models/SPO-SDXL_4k-p_10ep_LoRA). We also provide a LoRA checkpoint compatible with [stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui), which can be accessed [here](https://civitai.com/models/510261?modelVersionId=567119).
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
## A quick example
|
| 57 |
+
```python
|
| 58 |
+
from diffusers import StableDiffusionXLPipeline, UNet2DConditionModel
|
| 59 |
+
import torch
|
| 60 |
+
|
| 61 |
+
# load pipeline
|
| 62 |
+
inference_dtype = torch.float16
|
| 63 |
+
pipe = StableDiffusionXLPipeline.from_pretrained(
|
| 64 |
+
"SPO-Diffusion-Models/SPO-SDXL_4k-p_10ep",
|
| 65 |
+
torch_dtype=inference_dtype,
|
| 66 |
+
)
|
| 67 |
+
vae = AutoencoderKL.from_pretrained(
|
| 68 |
+
'madebyollin/sdxl-vae-fp16-fix',
|
| 69 |
+
torch_dtype=inference_dtype,
|
| 70 |
+
)
|
| 71 |
+
pipe.vae = vae
|
| 72 |
+
pipe.to('cuda')
|
| 73 |
+
|
| 74 |
+
generator=torch.Generator(device='cuda').manual_seed(42)
|
| 75 |
+
image = pipe(
|
| 76 |
+
prompt='a child and a penguin sitting in front of the moon',
|
| 77 |
+
guidance_scale=5.0,
|
| 78 |
+
generator=generator,
|
| 79 |
+
output_type='pil',
|
| 80 |
+
).images[0]
|
| 81 |
+
image.save('moon.png')
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
## Citation
|
| 85 |
+
If you find our work or codebase useful, please consider giving us a star and citing our work.
|
| 86 |
+
```
|
| 87 |
+
@article{liang2024step,
|
| 88 |
+
title={Aesthetic Post-Training Diffusion Models from Generic Preferences with Step-by-step Preference Optimization},
|
| 89 |
+
author={Liang, Zhanhao and Yuan, Yuhui and Gu, Shuyang and Chen, Bohan and Hang, Tiankai and Cheng, Mingxi and Li, Ji and Zheng, Liang},
|
| 90 |
+
journal={arXiv preprint arXiv:2406.04314},
|
| 91 |
+
year={2024}
|
| 92 |
+
}
|
| 93 |
+
```
|