Improve model card: add paper info, links, and improve description
#212
by
nielsr
HF Staff
- opened
README.md
CHANGED
|
@@ -1,215 +1,88 @@
|
|
| 1 |
---
|
| 2 |
license: openrail++
|
|
|
|
| 3 |
tags:
|
| 4 |
- text-to-image
|
| 5 |
- stable-diffusion
|
| 6 |
---
|
| 7 |
-
# SD-XL 1.0-base Model Card
|
| 8 |
-

|
| 9 |
|
| 10 |
-
|
| 11 |
|
| 12 |
-
|
| 13 |
|
| 14 |
-
|
| 15 |
-
In a first step, the base model is used to generate (noisy) latents,
|
| 16 |
-
which are then further processed with a refinement model (available here: https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-1.0/) specialized for the final denoising steps.
|
| 17 |
-
Note that the base model can be used as a standalone module.
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
to the latents generated in the first step, using the same prompt. This technique is slightly slower than the first one, as it requires more function evaluations.
|
| 23 |
|
| 24 |
-
|
| 25 |
|
| 26 |
-
|
| 27 |
|
| 28 |
-
-
|
| 29 |
-
- **Model type:** Diffusion-based text-to-image generative model
|
| 30 |
-
- **License:** [CreativeML Open RAIL++-M License](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/blob/main/LICENSE.md)
|
| 31 |
-
- **Model Description:** This is a model that can be used to generate and modify images based on text prompts. It is a [Latent Diffusion Model](https://arxiv.org/abs/2112.10752) that uses two fixed, pretrained text encoders ([OpenCLIP-ViT/G](https://github.com/mlfoundations/open_clip) and [CLIP-ViT/L](https://github.com/openai/CLIP/tree/main)).
|
| 32 |
-
- **Resources for more information:** Check out our [GitHub Repository](https://github.com/Stability-AI/generative-models) and the [SDXL report on arXiv](https://arxiv.org/abs/2307.01952).
|
| 33 |
|
| 34 |
-
|
| 35 |
|
| 36 |
-
|
| 37 |
-
[Clipdrop](https://clipdrop.co/stable-diffusion) provides free SDXL inference.
|
| 38 |
|
| 39 |
-
|
| 40 |
-
- **Demo:** https://clipdrop.co/stable-diffusion
|
| 41 |
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
The SDXL base model performs significantly better than the previous variants, and the model combined with the refinement module achieves the best overall performance.
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
### 🧨 Diffusers
|
| 50 |
-
|
| 51 |
-
Make sure to upgrade diffusers to >= 0.19.0:
|
| 52 |
-
```
|
| 53 |
-
pip install diffusers --upgrade
|
| 54 |
-
```
|
| 55 |
-
|
| 56 |
-
In addition make sure to install `transformers`, `safetensors`, `accelerate` as well as the invisible watermark:
|
| 57 |
-
```
|
| 58 |
-
pip install invisible_watermark transformers accelerate safetensors
|
| 59 |
-
```
|
| 60 |
-
|
| 61 |
-
To just use the base model, you can run:
|
| 62 |
-
|
| 63 |
-
```py
|
| 64 |
-
from diffusers import DiffusionPipeline
|
| 65 |
-
import torch
|
| 66 |
-
|
| 67 |
-
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, use_safetensors=True, variant="fp16")
|
| 68 |
-
pipe.to("cuda")
|
| 69 |
-
|
| 70 |
-
# if using torch < 2.0
|
| 71 |
-
# pipe.enable_xformers_memory_efficient_attention()
|
| 72 |
-
|
| 73 |
-
prompt = "An astronaut riding a green horse"
|
| 74 |
-
|
| 75 |
-
images = pipe(prompt=prompt).images[0]
|
| 76 |
-
```
|
| 77 |
-
|
| 78 |
-
To use the whole base + refiner pipeline as an ensemble of experts you can run:
|
| 79 |
-
|
| 80 |
-
```py
|
| 81 |
-
from diffusers import DiffusionPipeline
|
| 82 |
-
import torch
|
| 83 |
-
|
| 84 |
-
# load both base & refiner
|
| 85 |
-
base = DiffusionPipeline.from_pretrained(
|
| 86 |
-
"stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, variant="fp16", use_safetensors=True
|
| 87 |
-
)
|
| 88 |
-
base.to("cuda")
|
| 89 |
-
refiner = DiffusionPipeline.from_pretrained(
|
| 90 |
-
"stabilityai/stable-diffusion-xl-refiner-1.0",
|
| 91 |
-
text_encoder_2=base.text_encoder_2,
|
| 92 |
-
vae=base.vae,
|
| 93 |
-
torch_dtype=torch.float16,
|
| 94 |
-
use_safetensors=True,
|
| 95 |
-
variant="fp16",
|
| 96 |
-
)
|
| 97 |
-
refiner.to("cuda")
|
| 98 |
-
|
| 99 |
-
# Define how many steps and what % of steps to be run on each experts (80/20) here
|
| 100 |
-
n_steps = 40
|
| 101 |
-
high_noise_frac = 0.8
|
| 102 |
-
|
| 103 |
-
prompt = "A majestic lion jumping from a big stone at night"
|
| 104 |
-
|
| 105 |
-
# run both experts
|
| 106 |
-
image = base(
|
| 107 |
-
prompt=prompt,
|
| 108 |
-
num_inference_steps=n_steps,
|
| 109 |
-
denoising_end=high_noise_frac,
|
| 110 |
-
output_type="latent",
|
| 111 |
-
).images
|
| 112 |
-
image = refiner(
|
| 113 |
-
prompt=prompt,
|
| 114 |
-
num_inference_steps=n_steps,
|
| 115 |
-
denoising_start=high_noise_frac,
|
| 116 |
-
image=image,
|
| 117 |
-
).images[0]
|
| 118 |
-
```
|
| 119 |
-
|
| 120 |
-
When using `torch >= 2.0`, you can improve the inference speed by 20-30% with torch.compile. Simple wrap the unet with torch compile before running the pipeline:
|
| 121 |
-
```py
|
| 122 |
-
pipe.unet = torch.compile(pipe.unet, mode="reduce-overhead", fullgraph=True)
|
| 123 |
```
|
| 124 |
|
| 125 |
-
|
| 126 |
-
instead of `.to("cuda")`:
|
| 127 |
|
| 128 |
-
|
| 129 |
-
- pipe.to("cuda")
|
| 130 |
-
+ pipe.enable_model_cpu_offload()
|
| 131 |
-
```
|
| 132 |
-
|
| 133 |
-
For more information on how to use Stable Diffusion XL with `diffusers`, please have a look at [the Stable Diffusion XL Docs](https://huggingface.co/docs/diffusers/api/pipelines/stable_diffusion/stable_diffusion_xl).
|
| 134 |
-
|
| 135 |
-
### Optimum
|
| 136 |
-
[Optimum](https://github.com/huggingface/optimum) provides a Stable Diffusion pipeline compatible with both [OpenVINO](https://docs.openvino.ai/latest/index.html) and [ONNX Runtime](https://onnxruntime.ai/).
|
| 137 |
-
|
| 138 |
-
#### OpenVINO
|
| 139 |
-
|
| 140 |
-
To install Optimum with the dependencies required for OpenVINO :
|
| 141 |
|
| 142 |
-
|
| 143 |
-
|
|
|
|
|
|
|
| 144 |
```
|
| 145 |
|
| 146 |
-
|
| 147 |
|
| 148 |
-
|
| 149 |
-
- from diffusers import StableDiffusionXLPipeline
|
| 150 |
-
+ from optimum.intel import OVStableDiffusionXLPipeline
|
| 151 |
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
|
| 162 |
-
#### ONNX
|
| 163 |
|
| 164 |
-
|
| 165 |
|
| 166 |
-
|
| 167 |
-
pip install optimum[onnxruntime]
|
| 168 |
-
```
|
| 169 |
|
| 170 |
-
|
| 171 |
|
| 172 |
-
```
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
prompt = "A majestic lion jumping from a big stone at night"
|
| 180 |
-
image = pipeline(prompt).images[0]
|
| 181 |
```
|
| 182 |
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
## Uses
|
| 187 |
-
|
| 188 |
-
### Direct Use
|
| 189 |
-
|
| 190 |
-
The model is intended for research purposes only. Possible research areas and tasks include
|
| 191 |
-
|
| 192 |
-
- Generation of artworks and use in design and other artistic processes.
|
| 193 |
-
- Applications in educational or creative tools.
|
| 194 |
-
- Research on generative models.
|
| 195 |
-
- Safe deployment of models which have the potential to generate harmful content.
|
| 196 |
-
- Probing and understanding the limitations and biases of generative models.
|
| 197 |
-
|
| 198 |
-
Excluded uses are described below.
|
| 199 |
-
|
| 200 |
-
### Out-of-Scope Use
|
| 201 |
-
|
| 202 |
-
The model was not trained to be factual or true representations of people or events, and therefore using the model to generate such content is out-of-scope for the abilities of this model.
|
| 203 |
-
|
| 204 |
-
## Limitations and Bias
|
| 205 |
-
|
| 206 |
-
### Limitations
|
| 207 |
|
| 208 |
-
|
| 209 |
-
- The model cannot render legible text
|
| 210 |
-
- The model struggles with more difficult tasks which involve compositionality, such as rendering an image corresponding to “A red cube on top of a blue sphere”
|
| 211 |
-
- Faces and people in general may not be generated properly.
|
| 212 |
-
- The autoencoding part of the model is lossy.
|
| 213 |
|
| 214 |
-
|
| 215 |
-
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: openrail++
|
| 3 |
+
library_name: diffusers
|
| 4 |
tags:
|
| 5 |
- text-to-image
|
| 6 |
- stable-diffusion
|
| 7 |
---
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
# Conceptrol: Concept Control of Zero-shot Personalized Image Generation
|
| 10 |
|
| 11 |
+
## Model Card
|
| 12 |
|
| 13 |
+
This model implements Conceptrol, a training-free method that boosts zero-shot personalized image generation across Stable Diffusion, SDXL, and FLUX. It works without additional training, data, or models.
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
<p align="center">
|
| 16 |
+
<img src="demo/teaser.png">
|
| 17 |
+
</p>
|
|
|
|
| 18 |
|
| 19 |
+
[Conceptrol: Concept Control of Zero-shot Personalized Image Generation](https://huggingface.co/papers/2503.06568)
|
| 20 |
|
| 21 |
+
**Abstract:**
|
| 22 |
|
| 23 |
+
Personalized image generation with text-to-image diffusion models generates unseen images based on reference image content. Zero-shot adapter methods such as IP-Adapter and OminiControl are especially interesting because they do not require test-time fine-tuning. However, they struggle to balance preserving personalized content and adherence to the text prompt. We identify a critical design flaw resulting in this performance gap: current adapters inadequately integrate personalization images with the textual descriptions. The generated images, therefore, replicate the personalized content rather than adhere to the text prompt instructions. Yet the base text-to-image has strong conceptual understanding capabilities that can be leveraged.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
+
We propose Conceptrol, a simple yet effective framework that enhances zero-shot adapters without adding computational overhead. Conceptrol constrains the attention of visual specification with a textual concept mask that improves subject-driven generation capabilities. It achieves as much as 89% improvement on personalization benchmarks over the vanilla IP-Adapter and can even outperform fine-tuning approaches such as Dreambooth LoRA.
|
| 26 |
|
| 27 |
+
## Quick Start
|
|
|
|
| 28 |
|
| 29 |
+
#### 1. Environment Setup
|
|
|
|
| 30 |
|
| 31 |
+
``` bash
|
| 32 |
+
conda create -n conceptrol python=3.10
|
| 33 |
+
conda activate conceptrol
|
| 34 |
+
pip install -r requirements.txt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
```
|
| 36 |
|
| 37 |
+
#### 2. Go to `demo_sd.ipynb` / `demo_sdxl.ipynb` / `demo_flux.py` for fun!
|
|
|
|
| 38 |
|
| 39 |
+
## Local Setup using Gradio
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
+
#### 1. Start Gradio Interface
|
| 42 |
+
``` bash
|
| 43 |
+
pip install gradio
|
| 44 |
+
gradio gradio_src/app.py
|
| 45 |
```
|
| 46 |
|
| 47 |
+
#### 2. Use the GUI!
|
| 48 |
|
| 49 |
+
## Supporting Models
|
|
|
|
|
|
|
| 50 |
|
| 51 |
+
| Model Name | Link |
|
| 52 |
+
|-----------------------|-------------------------------------------------------------|
|
| 53 |
+
| Stable Diffusion 1.5 | [stable-diffusion-v1-5/stable-diffusion-v1-5](https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5) |
|
| 54 |
+
| Realistic Vision V5.1 | [SG161222/Realistic_Vision_V5.1_noVAE](https://huggingface.co/SG161222/Realistic_Vision_V5.1_noVAE) |
|
| 55 |
+
| Stable Diffusion XL-1024 | [stabilityai/stable-diffusion-xl-base-1.0](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0) |
|
| 56 |
+
| Animagine XL v4.0 | [cagliostrolab/animagine-xl-4.0](https://huggingface.co/cagliostrolab/animagine-xl-4.0)|
|
| 57 |
+
| Realistic Vision XL V5.0 | [SG161222/RealVisXL_V5.0](https://huggingface.co/SG161222/RealVisXL_V5.0) |
|
| 58 |
+
| FLUX-schnell | [black-forest-labs/FLUX.1-schnell](https://huggingface.co/black-forest-labs/FLUX.1-schnell) |
|
| 59 |
|
| 60 |
+
| Adapter Name | Link |
|
| 61 |
+
|-----------------------|-------------------------------------------------------------|
|
| 62 |
+
| IP-Adapter | [h94/IP-Adapter](https://huggingface.co/h94/IP-Adapter/tree/main) |
|
| 63 |
+
| OminiControl | [Yuanshi/OminiControl](https://huggingface.co/Yuanshi/OminiControl) |
|
| 64 |
|
|
|
|
| 65 |
|
| 66 |
+
## Source Code
|
| 67 |
|
| 68 |
+
https://github.com/QY-H00/Conceptrol
|
|
|
|
|
|
|
| 69 |
|
| 70 |
+
## Citation
|
| 71 |
|
| 72 |
+
``` bibtex
|
| 73 |
+
@article{he2025conceptrol,
|
| 74 |
+
title={Conceptrol: Concept Control of Zero-shot Personalized Image Generation},
|
| 75 |
+
author={Qiyuan He and Angela Yao},
|
| 76 |
+
journal={arXiv preprint arXiv:2503.06568},
|
| 77 |
+
year={2025}
|
| 78 |
+
}
|
|
|
|
|
|
|
| 79 |
```
|
| 80 |
|
| 81 |
+
## Acknowledgement
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
+
We thank the following repositories for their great work:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
+
[diffusers](https://github.com/huggingface/diffusers),
|
| 86 |
+
[transformers](https://github.com/huggingface/transformers),
|
| 87 |
+
[IP-Adapter](https://github.com/tencent-ailab/IP-Adapter),
|
| 88 |
+
[OminiControl](https://github.com/Yuanshi9815/OminiControl)
|