Skip to content

Commit 3a0b42a

Browse files
Merge branch 'main' into test_device_map_auto_on_cpu
2 parents 4914837 + 7fb4b88 commit 3a0b42a

File tree

62 files changed

+2371
-269
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+2371
-269
lines changed

.github/workflows/pr_tests.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ concurrency:
1010
cancel-in-progress: true
1111

1212
env:
13+
DIFFUSERS_IS_CI: yes
1314
OMP_NUM_THREADS: 8
1415
MKL_NUM_THREADS: 8
1516
PYTEST_TIMEOUT: 60
@@ -41,6 +42,8 @@ jobs:
4142
python utils/print_env.py
4243
4344
- name: Run all fast tests on CPU
45+
env:
46+
HUGGING_FACE_HUB_TOKEN: ${{ secrets.HUGGING_FACE_HUB_TOKEN }}
4447
run: |
4548
python -m pytest -n 2 --max-worker-restart=0 --dist=loadfile -s -v --make-reports=tests_torch_cpu tests/
4649
@@ -90,6 +93,8 @@ jobs:
9093
9194
- name: Run all fast tests on MPS
9295
shell: arch -arch arm64 bash {0}
96+
env:
97+
HUGGING_FACE_HUB_TOKEN: ${{ secrets.HUGGING_FACE_HUB_TOKEN }}
9398
run: |
9499
${CONDA_RUN} python -m pytest -n 1 -s -v --make-reports=tests_torch_mps tests/
95100

.github/workflows/push_tests.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
- main
77

88
env:
9+
DIFFUSERS_IS_CI: yes
910
HF_HOME: /mnt/cache
1011
OMP_NUM_THREADS: 8
1112
MKL_NUM_THREADS: 8
@@ -34,7 +35,7 @@ jobs:
3435
run: |
3536
python -m pip install --upgrade pip
3637
python -m pip uninstall -y torch torchvision torchtext
37-
python -m pip install torch --extra-index-url https://download.pytorch.org/whl/cu116
38+
python -m pip install torch --extra-index-url https://download.pytorch.org/whl/cu117
3839
python -m pip install -e .[quality,test]
3940
python -m pip install git+https://github.com/huggingface/accelerate
4041
@@ -80,7 +81,7 @@ jobs:
8081
run: |
8182
python -m pip install --upgrade pip
8283
python -m pip uninstall -y torch torchvision torchtext
83-
python -m pip install torch --extra-index-url https://download.pytorch.org/whl/cu116
84+
python -m pip install torch --extra-index-url https://download.pytorch.org/whl/cu117
8485
python -m pip install -e .[quality,test,training]
8586
python -m pip install git+https://github.com/huggingface/accelerate
8687

README.md

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,7 @@ it before the pipeline and pass it to `from_pretrained`.
142142
```python
143143
from diffusers import LMSDiscreteScheduler
144144

145-
lms = LMSDiscreteScheduler(
146-
beta_start=0.00085,
147-
beta_end=0.012,
148-
beta_schedule="scaled_linear"
149-
)
145+
lms = LMSDiscreteScheduler.from_config("CompVis/stable-diffusion-v1-4", subfolder="scheduler")
150146

151147
pipe = StableDiffusionPipeline.from_pretrained(
152148
"runwayml/stable-diffusion-v1-5",
@@ -182,9 +178,9 @@ image.save("astronaut_rides_horse.png")
182178

183179
### JAX/Flax
184180

185-
To use StableDiffusion on TPUs and GPUs for faster inference you can leverage JAX/Flax.
181+
Diffusers offers a JAX / Flax implementation of Stable Diffusion for very fast inference. JAX shines specially on TPU hardware because each TPU server has 8 accelerators working in parallel, but it runs great on GPUs too.
186182

187-
Running the pipeline with default PNDMScheduler
183+
Running the pipeline with the default PNDMScheduler:
188184

189185
```python
190186
import jax
@@ -331,8 +327,25 @@ You can generate your own latents to reproduce results, or tweak your prompt on
331327

332328
For more details, check out [the Stable Diffusion notebook](https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers/stable_diffusion.ipynb) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers/stable_diffusion.ipynb)
333329
and have a look into the [release notes](https://github.com/huggingface/diffusers/releases/tag/v0.2.0).
334-
335-
## Examples
330+
331+
## Fine-Tuning Stable Diffusion
332+
333+
Fine-tuning techniques make it possible to adapt Stable Diffusion to your own dataset, or add new subjects to it. These are some of the techniques supported in `diffusers`:
334+
335+
Textual Inversion is a technique for capturing novel concepts from a small number of example images in a way that can later be used to control text-to-image pipelines. It does so by learning new 'words' in the embedding space of the pipeline's text encoder. These special words can then be used within text prompts to achieve very fine-grained control of the resulting images.
336+
337+
- Textual Inversion. Capture novel concepts from a small set of sample images, and associate them with new "words" in the embedding space of the text encoder. Please, refer to [our training examples](https://github.com/huggingface/diffusers/tree/main/examples/textual_inversion) or [documentation](https://huggingface.co/docs/diffusers/training/text_inversion) to try for yourself.
338+
339+
- Dreambooth. Another technique to capture new concepts in Stable Diffusion. This method fine-tunes the UNet (and, optionally, also the text encoder) of the pipeline to achieve impressive results. Please, refer to [our training examples](https://github.com/huggingface/diffusers/tree/main/examples/dreambooth) and [training report](https://wandb.ai/psuraj/dreambooth/reports/Dreambooth-Training-Analysis--VmlldzoyNzk0NDc3) for additional details and training recommendations.
340+
341+
- Full Stable Diffusion fine-tuning. If you have a more sizable dataset with a specific look or style, you can fine-tune Stable Diffusion so that it outputs images following those examples. This was the approach taken to create [a Pokémon Stable Diffusion model](https://huggingface.co/justinpinkney/pokemon-stable-diffusion) (by Justing Pinkney / Lambda Labs), [a Japanese specific version of Stable Diffusion](https://huggingface.co/spaces/rinna/japanese-stable-diffusion) (by [Rinna Co.](https://github.com/rinnakk/japanese-stable-diffusion/) and others. You can start at [our text-to-image fine-tuning example](https://github.com/huggingface/diffusers/tree/main/examples/text_to_image) and go from there.
342+
343+
344+
## Stable Diffusion Community Pipelines
345+
346+
The release of Stable Diffusion as an open source model has fostered a lot of interesting ideas and experimentation. Our [Community Examples folder](https://github.com/huggingface/diffusers/tree/main/examples/community) contains many ideas worth exploring, like interpolating to create animated videos, using CLIP Guidance for additional prompt fidelity, term weighting, and much more! Take a look and [contribute your own](https://huggingface.co/docs/diffusers/using-diffusers/custom_pipelines).
347+
348+
## Other Examples
336349

337350
There are many ways to try running Diffusers! Here we outline code-focused tools (primarily using `DiffusionPipeline`s and Google Colab) and interactive web-tools.
338351

docs/source/_toctree.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@
4646
- local: training/unconditional_training
4747
title: "Unconditional Image Generation"
4848
- local: training/text_inversion
49-
title: "Text Inversion"
49+
title: "Textual Inversion"
50+
- local: training/dreambooth
51+
title: "Dreambooth"
5052
- local: training/text2image
51-
title: "Text-to-image"
53+
title: "Text-to-image fine-tuning"
5254
title: "Training"
5355
- sections:
5456
- local: conceptual/stable_diffusion

docs/source/api/schedulers.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Original implementation can be found [here](https://github.com/crowsonkb/k-diffu
8989

9090
[[autodoc]] PNDMScheduler
9191

92-
#### variance exploding stochastic differential equation (SDE) scheduler
92+
#### variance exploding stochastic differential equation (VE-SDE) scheduler
9393

9494
Original paper can be found [here](https://arxiv.org/abs/2011.13456).
9595

@@ -99,7 +99,9 @@ Original paper can be found [here](https://arxiv.org/abs/2011.13456).
9999

100100
Original implementation can be found [here](https://github.com/crowsonkb/v-diffusion-pytorch/blob/987f8985e38208345c1959b0ea767a625831cc9b/diffusion/sampling.py#L296).
101101

102-
#### variance preserving stochastic differential equation (SDE) scheduler
102+
[[autodoc]] IPNDMScheduler
103+
104+
#### variance preserving stochastic differential equation (VP-SDE) scheduler
103105

104106
Original paper can be found [here](https://arxiv.org/abs/2011.13456).
105107

docs/source/conceptual/stable_diffusion.mdx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,4 @@ specific language governing permissions and limitations under the License.
1212

1313
# Stable Diffusion
1414

15-
Under construction 🚧
16-
17-
For now please visit this [very in-detail blog post](https://huggingface.co/blog/stable_diffusion)
15+
Please visit this [very in-detail blog post](https://huggingface.co/blog/stable_diffusion) on Stable Diffusion!

docs/source/installation.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ The `main` version is useful for staying up-to-date with the latest developments
5353
For instance, if a bug has been fixed since the last official release but a new release hasn't been rolled out yet.
5454
However, this means the `main` version may not always be stable.
5555
We strive to keep the `main` version operational, and most issues are usually resolved within a few hours or a day.
56-
If you run into a problem, please open an [Issue](https://github.com/huggingface/transformers/issues) so we can fix it even sooner!
56+
If you run into a problem, please open an [Issue](https://github.com/huggingface/transformers/issues), so we can fix it even sooner!
5757

5858
## Editable install
5959

docs/source/optimization/fp16.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ We present some techniques and ideas to optimize 🤗 Diffusers _inference_ for
1818
| ---------------- | ------- | ------- |
1919
| original | 9.50s | x1 |
2020
| cuDNN auto-tuner | 9.37s | x1.01 |
21-
| autocast (fp16) | 5.47s | x1.91 |
22-
| fp16 | 3.61s | x2.91 |
23-
| channels last | 3.30s | x2.87 |
21+
| autocast (fp16) | 5.47s | x1.74 |
22+
| fp16 | 3.61s | x2.63 |
23+
| channels last | 3.30s | x2.88 |
2424
| traced UNet | 3.21s | x2.96 |
2525

2626
<em>

docs/source/quicktour.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ you could use it as follows:
121121
```python
122122
>>> from diffusers import LMSDiscreteScheduler
123123

124-
>>> scheduler = LMSDiscreteScheduler(beta_start=0.00085, beta_end=0.012, beta_schedule="scaled_linear")
124+
>>> scheduler = LMSDiscreteScheduler.from_config("runwayml/stable-diffusion-v1-5", subfolder="scheduler")
125125

126126
>>> generator = StableDiffusionPipeline.from_pretrained(
127127
... "runwayml/stable-diffusion-v1-5", scheduler=scheduler, use_auth_token=AUTH_TOKEN

0 commit comments

Comments
 (0)