Skip to content

Commit b8b0fd1

Browse files
authored
Merge branch 'main' into feat/check-doc-listing
2 parents f3443d0 + fe5f035 commit b8b0fd1

File tree

68 files changed

+6441
-323
lines changed

Some content is hidden

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

68 files changed

+6441
-323
lines changed

.github/workflows/build_docker_images.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ jobs:
2525
steps:
2626
- name: Set up Docker Buildx
2727
uses: docker/setup-buildx-action@v1
28-
28+
2929
- name: Check out code
3030
uses: actions/checkout@v3
31-
31+
3232
- name: Find Changed Dockerfiles
3333
id: file_changes
3434
uses: jitterbit/get-changed-files@v1
3535
with:
3636
format: 'space-delimited'
3737
token: ${{ secrets.GITHUB_TOKEN }}
38-
38+
3939
- name: Build Changed Docker Images
4040
run: |
4141
CHANGED_FILES="${{ steps.file_changes.outputs.all }}"
@@ -52,7 +52,7 @@ jobs:
5252
build-and-push-docker-images:
5353
runs-on: [ self-hosted, intel-cpu, 8-cpu, ci ]
5454
if: github.event_name != 'pull_request'
55-
55+
5656
permissions:
5757
contents: read
5858
packages: write
@@ -69,6 +69,7 @@ jobs:
6969
- diffusers-flax-tpu
7070
- diffusers-onnxruntime-cpu
7171
- diffusers-onnxruntime-cuda
72+
- diffusers-doc-builder
7273

7374
steps:
7475
- name: Checkout repository

.github/workflows/build_documentation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
package: diffusers
2222
notebook_folder: diffusers_doc
2323
languages: en ko zh ja pt
24-
24+
custom_container: diffusers/diffusers-doc-builder
2525
secrets:
2626
token: ${{ secrets.HUGGINGFACE_PUSH }}
2727
hf_token: ${{ secrets.HF_DOC_BUILD_PUSH }}

.github/workflows/build_pr_documentation.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ jobs:
2020
install_libgl1: true
2121
package: diffusers
2222
languages: en ko zh ja pt
23+
custom_container: diffusers/diffusers-doc-builder
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Check running SLOW tests from a PR (only GPU)
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
docker_image:
7+
default: 'diffusers/diffusers-pytorch-cuda'
8+
description: 'Name of the Docker image'
9+
required: true
10+
branch:
11+
description: 'PR Branch to test on'
12+
required: true
13+
test:
14+
description: 'Tests to run (e.g.: `tests/models`).'
15+
required: true
16+
17+
env:
18+
DIFFUSERS_IS_CI: yes
19+
IS_GITHUB_CI: "1"
20+
HF_HOME: /mnt/cache
21+
OMP_NUM_THREADS: 8
22+
MKL_NUM_THREADS: 8
23+
PYTEST_TIMEOUT: 600
24+
RUN_SLOW: yes
25+
26+
jobs:
27+
run_tests:
28+
name: "Run a test on our runner from a PR"
29+
runs-on: [single-gpu, nvidia-gpu, t4, ci]
30+
container:
31+
image: ${{ github.event.inputs.docker_image }}
32+
options: --gpus 0 --privileged --ipc host -v /mnt/cache/.cache/huggingface:/mnt/cache/
33+
34+
steps:
35+
- name: Validate test files input
36+
id: validate_test_files
37+
env:
38+
PY_TEST: ${{ github.event.inputs.test }}
39+
run: |
40+
if [[ ! "$PY_TEST" =~ ^tests/ ]]; then
41+
echo "Error: The input string must start with 'tests/'."
42+
exit 1
43+
fi
44+
45+
if [[ ! "$PY_TEST" =~ ^tests/(models|pipelines) ]]; then
46+
echo "Error: The input string must contain either 'models' or 'pipelines' after 'tests/'."
47+
exit 1
48+
fi
49+
50+
if [[ "$PY_TEST" == *";"* ]]; then
51+
echo "Error: The input string must not contain ';'."
52+
exit 1
53+
fi
54+
echo "$PY_TEST"
55+
56+
- name: Checkout PR branch
57+
uses: actions/checkout@v4
58+
with:
59+
ref: ${{ github.event.inputs.branch }}
60+
repository: ${{ github.event.pull_request.head.repo.full_name }}
61+
62+
63+
- name: Install pytest
64+
run: |
65+
python -m venv /opt/venv && export PATH="/opt/venv/bin:$PATH"
66+
python -m uv pip install -e [quality,test]
67+
python -m uv pip install peft
68+
69+
- name: Run tests
70+
env:
71+
PY_TEST: ${{ github.event.inputs.test }}
72+
run: |
73+
pytest "$PY_TEST"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Please refer to the [How to use Stable Diffusion in Apple Silicon](https://huggi
7777

7878
## Quickstart
7979

80-
Generating outputs is super easy with 🤗 Diffusers. To generate an image from text, use the `from_pretrained` method to load any pretrained diffusion model (browse the [Hub](https://huggingface.co/models?library=diffusers&sort=downloads) for 22000+ checkpoints):
80+
Generating outputs is super easy with 🤗 Diffusers. To generate an image from text, use the `from_pretrained` method to load any pretrained diffusion model (browse the [Hub](https://huggingface.co/models?library=diffusers&sort=downloads) for 25.000+ checkpoints):
8181

8282
```python
8383
from diffusers import DiffusionPipeline
@@ -219,7 +219,7 @@ Also, say 👋 in our public Discord channel <a href="https://discord.gg/G7tWnz9
219219
- https://github.com/deep-floyd/IF
220220
- https://github.com/bentoml/BentoML
221221
- https://github.com/bmaltais/kohya_ss
222-
- +9000 other amazing GitHub repositories 💪
222+
- +11.000 other amazing GitHub repositories 💪
223223

224224
Thank you for using us ❤️.
225225

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
FROM ubuntu:20.04
2+
LABEL maintainer="Hugging Face"
3+
LABEL repository="diffusers"
4+
5+
ENV DEBIAN_FRONTEND=noninteractive
6+
7+
RUN apt-get -y update \
8+
&& apt-get install -y software-properties-common \
9+
&& add-apt-repository ppa:deadsnakes/ppa
10+
11+
RUN apt install -y bash \
12+
build-essential \
13+
git \
14+
git-lfs \
15+
curl \
16+
ca-certificates \
17+
libsndfile1-dev \
18+
python3.10 \
19+
python3-pip \
20+
libgl1 \
21+
zip \
22+
wget \
23+
python3.10-venv && \
24+
rm -rf /var/lib/apt/lists
25+
26+
# make sure to use venv
27+
RUN python3.10 -m venv /opt/venv
28+
ENV PATH="/opt/venv/bin:$PATH"
29+
30+
# pre-install the heavy dependencies (these can later be overridden by the deps from setup.py)
31+
RUN python3.10 -m pip install --no-cache-dir --upgrade pip uv==0.1.11 && \
32+
python3.10 -m uv pip install --no-cache-dir \
33+
torch \
34+
torchvision \
35+
torchaudio \
36+
invisible_watermark \
37+
--extra-index-url https://download.pytorch.org/whl/cpu && \
38+
python3.10 -m uv pip install --no-cache-dir \
39+
accelerate \
40+
datasets \
41+
hf-doc-builder \
42+
huggingface-hub \
43+
Jinja2 \
44+
librosa \
45+
numpy \
46+
scipy \
47+
tensorboard \
48+
transformers \
49+
matplotlib \
50+
setuptools==69.5.1
51+
52+
CMD ["/bin/bash"]

docs/source/en/_toctree.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@
9393
title: Trajectory Consistency Distillation-LoRA
9494
- local: using-diffusers/svd
9595
title: Stable Video Diffusion
96+
- local: using-diffusers/marigold_usage
97+
title: Marigold Computer Vision
9698
title: Specific pipeline examples
9799
- sections:
98100
- local: training/overview
@@ -295,6 +297,8 @@
295297
title: Latent Diffusion
296298
- local: api/pipelines/ledits_pp
297299
title: LEDITS++
300+
- local: api/pipelines/marigold
301+
title: Marigold
298302
- local: api/pipelines/panorama
299303
title: MultiDiffusion
300304
- local: api/pipelines/musicldm
@@ -445,4 +449,4 @@
445449
title: Video Processor
446450
title: Internal classes
447451
isExpanded: false
448-
title: API
452+
title: API

docs/source/en/api/loaders/single_file.md

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ specific language governing permissions and limitations under the License.
1212

1313
# Loading Pipelines and Models via `from_single_file`
1414

15-
The `from_single_file` method allows you to load supported pipelines using a single checkpoint file as opposed to the folder format used by Diffusers. This is useful if you are working with many of the Stable Diffusion Web UI's (such as A1111) that extensively rely on a single file to distribute all the components of a diffusion model.
15+
The `from_single_file` method allows you to load supported pipelines using a single checkpoint file as opposed to Diffusers' multiple folders format. This is useful if you are working with Stable Diffusion Web UI's (such as A1111) that rely on a single file format to distribute all the components of a model.
1616

17-
The `from_single_file` method also supports loading models in their originally distributed format. This means that supported models that have been finetuned with other services can be loaded directly into supported Diffusers model objects and pipelines.
17+
The `from_single_file` method also supports loading models in their originally distributed format. This means that supported models that have been finetuned with other services can be loaded directly into Diffusers model objects and pipelines.
1818

1919
## Pipelines that currently support `from_single_file` loading
2020

@@ -59,7 +59,7 @@ pipe = StableDiffusionXLPipeline.from_single_file(ckpt_path)
5959

6060
## Setting components in a Pipeline using `from_single_file`
6161

62-
Swap components of the pipeline by passing them directly to the `from_single_file` method. e.g If you would like use a different scheduler than the pipeline default.
62+
Set components of a pipeline by passing them directly to the `from_single_file` method. For example, here we are swapping out the pipeline's default scheduler with the `DDIMScheduler`.
6363

6464
```python
6565
from diffusers import StableDiffusionXLPipeline, DDIMScheduler
@@ -71,13 +71,15 @@ pipe = StableDiffusionXLPipeline.from_single_file(ckpt_path, scheduler=scheduler
7171

7272
```
7373

74+
Here we are passing in a ControlNet model to the `StableDiffusionControlNetPipeline`.
75+
7476
```python
75-
from diffusers import StableDiffusionPipeline, ControlNetModel
77+
from diffusers import StableDiffusionControlNetPipeline, ControlNetModel
7678

7779
ckpt_path = "https://huggingface.co/runwayml/stable-diffusion-v1-5/blob/main/v1-5-pruned-emaonly.safetensors"
7880

79-
controlnet = ControlNetModel.from_pretrained("https://huggingface.co/runwayml/stable-diffusion-v1-5/blob/main/v1-5-pruned-emaonly.safetensors")
80-
pipe = StableDiffusionPipeline.from_single_file(ckpt_path, controlnet=controlnet)
81+
controlnet = ControlNetModel.from_pretrained("lllyasviel/control_v11p_sd15_canny")
82+
pipe = StableDiffusionControlNetPipeline.from_single_file(ckpt_path, controlnet=controlnet)
8183

8284
```
8385

@@ -93,7 +95,7 @@ model = StableCascadeUNet.from_single_file(ckpt_path)
9395

9496
## Using a Diffusers model repository to configure single file loading
9597

96-
Under the hood, `from_single_file` will try to determine a model repository to use to configure the components of the pipeline. You can also pass in a repository id to the `config` argument of the `from_single_file` method to explicitly set the repository to use.
98+
Under the hood, `from_single_file` will try to automatically determine a model repository to use to configure the components of a pipeline. You can also explicitly set the model repository to configure the pipeline with the `config` argument.
9799

98100
```python
99101
from diffusers import StableDiffusionXLPipeline
@@ -105,9 +107,19 @@ pipe = StableDiffusionXLPipeline.from_single_file(ckpt_path, config=repo_id)
105107

106108
```
107109

110+
In the example above, since we explicitly passed `repo_id="segmind/SSD-1B"` to the `config` argument, it will use this [configuration file](https://huggingface.co/segmind/SSD-1B/blob/main/unet/config.json) from the `unet` subfolder in `"segmind/SSD-1B"` to configure the `unet` component of the pipeline; Similarly, it will use the `config.json` file from `vae` subfolder to configure the `vae` model, `config.json` file from `text_encoder` folder to configure `text_encoder` and so on.
111+
112+
<Tip>
113+
114+
Most of the time you do not need to explicitly set a `config` argument. `from_single_file` will automatically map the checkpoint to the appropriate model repository. However, this option can be useful in cases where model components in the checkpoint might have been changed from what was originally distributed, or in cases where a checkpoint file might not have the necessary metadata to correctly determine the configuration to use for the pipeline.
115+
116+
</Tip>
117+
108118
## Override configuration options when using single file loading
109119

110-
Override the default model or pipeline configuration options when using `from_single_file` by passing in the relevant arguments directly to the `from_single_file` method. Any argument that is supported by the model or pipeline class can be configured in this way:
120+
Override the default model or pipeline configuration options by providing the relevant arguments directly to the `from_single_file` method. Any argument supported by the model or pipeline class can be configured in this way:
121+
122+
### Setting a pipeline configuration option
111123

112124
```python
113125
from diffusers import StableDiffusionXLInstructPix2PixPipeline
@@ -117,6 +129,8 @@ pipe = StableDiffusionXLInstructPix2PixPipeline.from_single_file(ckpt_path, conf
117129

118130
```
119131

132+
### Setting a model configuration option
133+
120134
```python
121135
from diffusers import UNet2DConditionModel
122136

@@ -125,10 +139,6 @@ model = UNet2DConditionModel.from_single_file(ckpt_path, upcast_attention=True)
125139

126140
```
127141

128-
In the example above, since we explicitly passed `repo_id="segmind/SSD-1B"`, it will use this [configuration file](https://huggingface.co/segmind/SSD-1B/blob/main/unet/config.json) from the "unet" subfolder in `"segmind/SSD-1B"` to configure the unet component included in the checkpoint; Similarly, it will use the `config.json` file from `"vae"` subfolder to configure the vae model, `config.json` file from text_encoder folder to configure text_encoder and so on.
129-
130-
Note that most of the time you do not need to explicitly a `config` argument, `from_single_file` will automatically map the checkpoint to a repo id (we will discuss this in more details in next section). However, this can be useful in cases where model components might have been changed from what was originally distributed or in cases where a checkpoint file might not have the necessary metadata to correctly determine the configuration to use for the pipeline.
131-
132142
<Tip>
133143

134144
To learn more about how to load single file weights, see the [Load different Stable Diffusion formats](../../using-diffusers/other-formats) loading guide.
@@ -137,9 +147,11 @@ To learn more about how to load single file weights, see the [Load different Sta
137147

138148
## Working with local files
139149

140-
As of `diffusers>=0.28.0` the `from_single_file` method will attempt to configure a pipeline or model by first inferring the model type from the checkpoint file and then using the model type to determine the appropriate model repo configuration to use from the Hugging Face Hub. For example, any single file checkpoint based on the Stable Diffusion XL base model will use the [`stabilityai/stable-diffusion-xl-base-1.0`](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0) model repo to configure the pipeline.
150+
As of `diffusers>=0.28.0` the `from_single_file` method will attempt to configure a pipeline or model by first inferring the model type from the keys in the checkpoint file. This inferred model type is then used to determine the appropriate model repository on the Hugging Face Hub to configure the model or pipeline.
151+
152+
For example, any single file checkpoint based on the Stable Diffusion XL base model will use the [`stabilityai/stable-diffusion-xl-base-1.0`](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0) model repository to configure the pipeline.
141153

142-
If you are working in an environment with restricted internet access, it is recommended to download the config files and checkpoints for the model to your preferred directory and pass the local paths to the `pretrained_model_link_or_path` and `config` arguments of the `from_single_file` method.
154+
If you are working in an environment with restricted internet access, it is recommended that you download the config files and checkpoints for the model to your preferred directory and pass the local paths to the `pretrained_model_link_or_path` and `config` arguments of the `from_single_file` method.
143155

144156
```python
145157
from huggingface_hub import hf_hub_download, snapshot_download
@@ -211,13 +223,14 @@ pipe = StableDiffusionXLPipeline.from_single_file(my_local_checkpoint_path, conf
211223
```
212224

213225
<Tip>
214-
Disabling symlinking means that the `huggingface_hub` caching mechanism has no way to determine whether a file has already been downloaded to the local directory. This means that the `hf_hub_download` and `snapshot_download` functions will download files to the local directory each time they are executed. If you are disabling symlinking, it is recommended that you separate the model download and loading steps to avoid downloading the same file multiple times.
226+
227+
As of `huggingface_hub>=0.23.0` the `local_dir_use_symlinks` argument isn't necessary for the `hf_hub_download` and `snapshot_download` functions.
215228

216229
</Tip>
217230

218231
## Using the original configuration file of a model
219232

220-
If you would like to configure the parameters of the model components in the pipeline using the orignal YAML configuration file, you can pass a local path or url to the original configuration file to the `original_config` argument of the `from_single_file` method.
233+
If you would like to configure the model components in a pipeline using the orignal YAML configuration file, you can pass a local path or url to the original configuration file via the `original_config` argument.
221234

222235
```python
223236
from diffusers import StableDiffusionXLPipeline
@@ -229,13 +242,12 @@ original_config = "https://raw.githubusercontent.com/Stability-AI/generative-mod
229242
pipe = StableDiffusionXLPipeline.from_single_file(ckpt_path, original_config=original_config)
230243
```
231244

232-
In the example above, the `original_config` file is only used to configure the parameters of the individual model components of the pipeline. For example it will be used to configure parameters such as the `in_channels` of the `vae` model and `unet` model. It is not used to determine the type of component objects in the pipeline.
245+
<Tip>
233246

247+
When using `original_config` with `local_files_only=True`, Diffusers will attempt to infer the components of the pipeline based on the type signatures of pipeline class, rather than attempting to fetch the configuration files from a model repository on the Hugging Face Hub. This is to prevent backward breaking changes in existing code that might not be able to connect to the internet to fetch the necessary configuration files.
234248

235-
<Tip>
236-
When using `original_config` with local_files_only=True`, Diffusers will attempt to infer the components based on the type signatures of pipeline class, rather than attempting to fetch the pipeline config from the Hugging Face Hub. This is to prevent backwards breaking changes in existing code that might not be able to connect to the internet to fetch the necessary pipeline config files.
249+
This is not as reliable as providing a path to a local model repository using the `config` argument and might lead to errors when configuring the pipeline. To avoid this, please run the pipeline with `local_files_only=False` once to download the appropriate pipeline configuration files to the local cache.
237250

238-
This is not as reliable as providing a path to a local config repo and might lead to errors when configuring the pipeline. To avoid this, please run the pipeline with `local_files_only=False` once to download the appropriate pipeline config files to the local cache.
239251
</Tip>
240252

241253

docs/source/en/api/pipelines/i2vgenxl.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Sample output with I2VGenXL:
4747
* Unlike SVD, it additionally accepts text prompts as inputs.
4848
* It can generate higher resolution videos.
4949
* When using the [`DDIMScheduler`] (which is default for this pipeline), less than 50 steps for inference leads to bad results.
50+
* This implementation is 1-stage variant of I2VGenXL. The main figure in the [I2VGen-XL](https://arxiv.org/abs/2311.04145) paper shows a 2-stage variant, however, 1-stage variant works well. See [this discussion](https://github.com/huggingface/diffusers/discussions/7952) for more details.
5051

5152
## I2VGenXLPipeline
5253
[[autodoc]] I2VGenXLPipeline

0 commit comments

Comments
 (0)