You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[SDXL] Partial diffusion support for Text2Img and Img2Img Pipelines (#4015)
* diffusers#4003 - initial implementation of max_inference_steps
* diffusers#4003 - initial implementation of max_inference_steps and first_inference_step for img2img
* diffusers#4003 - use first_inference_step as an input arg for get_timestamps in img2img
* diffusers#4003 Do not add noise during img2img when we have a defined first timestep
* diffusers#4003 Mild updates after revert
* diffusers#4003 Missing change
* Show implementation with denoising_start and end
* Apply suggestions from code review
* Update src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py
Co-authored-by: Pedro Cuenca <pedro@huggingface.co>
* move to 0.19.0dev
* Apply suggestions from code review
* add exhaustive tests
* add docs
* finish
* Apply suggestions from code review
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
* make style
---------
Co-authored-by: bghira <bghira@users.github.com>
Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
Co-authored-by: Pedro Cuenca <pedro@huggingface.co>
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
The image can be refined by making use of [stabilityai/stable-diffusion-xl-refiner-0.9](https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-0.9).
63
-
In this case, you only have to output the `latents` from the base model.
62
+
In addition to the [base model checkpoint](https://huggingface.co/stabilityai/stable-diffusion-xl-base-0.9),
63
+
StableDiffusion-XL also includes a [refiner checkpoint](huggingface.co/stabilityai/stable-diffusion-xl-refiner-0.9)
64
+
that is specialized in denoising low-noise stage images to generate images of improved high-frequency quality.
65
+
This refiner checkpoint can be used as a "second-step" pipeline after having run the base checkpoint to improve
66
+
image quality.
67
+
68
+
When using the refiner, one can easily
69
+
- 1.) employ the base model and refiner as an *Ensemble of Expert Denoisers* as first proposed in [eDiff-I](https://research.nvidia.com/labs/dir/eDiff-I/) or
70
+
- 2.) simply run the refiner in [SDEdit](https://arxiv.org/abs/2108.01073) fashion after the base model.
71
+
72
+
**Note**: The idea of using SD-XL base & refiner as an ensemble of experts was first brought forward by
73
+
a couple community contributors which also helped shape the following `diffusers` implementation, namely:
74
+
-[SytanSD](https://github.com/SytanSD)
75
+
-[bghira](https://github.com/bghira)
76
+
-[Birch-san](https://github.com/Birch-san)
77
+
78
+
#### 1.) Ensemble of Expert Denoisers
79
+
80
+
When using the base and refiner model as an ensemble of expert of denoisers, the base model should serve as the
81
+
expert for the high-noise diffusion stage and the refiner serves as the expert for the low-noise diffusion stage.
82
+
83
+
The advantage of 1.) over 2.) is that it requires less overall denoising steps and therefore should be significantly
84
+
faster. The drawback is that one cannot really inspect the output of the base model; it will still be heavily denoised.
85
+
86
+
To use the base model and refiner as an ensemble of expert denoisers, make sure to define the fraction
87
+
of timesteps which should be run through the high-noise denoising stage (*i.e.* the base model) and the low-noise
88
+
denoising stage (*i.e.* the refiner model) respectively. This fraction should be set as the [`~StableDiffusionXLPipeline.__call__.denoising_end`] of the base model
89
+
and as the [`~StableDiffusionXLImg2ImgPipeline.__call__.denoising_start`] of the refiner model.
90
+
91
+
Let's look at an example.
92
+
First, we import the two pipelines. Since the text encoders and variational autoencoder are the same
93
+
you don't have to load those again for the refiner.
64
94
65
95
```py
66
-
from diffusers importStableDiffusionXLPipeline, StableDiffusionXLImg2ImgPipeline
0 commit comments