Skip to content

Commit a4ff0b7

Browse files
authored
Merge branch 'huggingface:main' into main
2 parents f40df28 + 1e7f965 commit a4ff0b7

File tree

205 files changed

+5316
-942
lines changed

Some content is hidden

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

205 files changed

+5316
-942
lines changed

.github/workflows/pr_quality.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ jobs:
2727
pip install .[quality]
2828
- name: Check quality
2929
run: |
30-
black --check --preview examples tests src utils scripts
31-
isort --check-only examples tests src utils scripts
32-
flake8 examples tests src utils scripts
30+
black --check examples tests src utils scripts
31+
ruff examples tests src utils scripts
3332
doc-builder style src/diffusers docs/source --max_len 119 --check_only --path_to_docs docs/source
3433
3534
check_repository_consistency:

.github/workflows/pr_tests.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ jobs:
3636
runner: docker-cpu
3737
image: diffusers/diffusers-onnxruntime-cpu
3838
report: onnx_cpu
39+
- name: PyTorch Example CPU tests on Ubuntu
40+
framework: pytorch_examples
41+
runner: docker-cpu
42+
image: diffusers/diffusers-pytorch-cpu
43+
report: torch_cpu
3944

4045
name: ${{ matrix.config.name }}
4146

@@ -90,6 +95,13 @@ jobs:
9095
--make-reports=tests_${{ matrix.config.report }} \
9196
tests/
9297
98+
- name: Run example PyTorch CPU tests
99+
if: ${{ matrix.config.framework == 'pytorch_examples' }}
100+
run: |
101+
python -m pytest -n 2 --max-worker-restart=0 --dist=loadfile \
102+
--make-reports=tests_${{ matrix.config.report }} \
103+
examples/test_examples.py
104+
93105
- name: Failure short reports
94106
if: ${{ failure() }}
95107
run: cat reports/tests_${{ matrix.config.report }}_failures_short.txt

.github/workflows/push_tests.yml

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,153 @@ jobs:
154154
with:
155155
name: examples_test_reports
156156
path: reports
157+
158+
run_fast_tests:
159+
strategy:
160+
fail-fast: false
161+
matrix:
162+
config:
163+
- name: Fast PyTorch CPU tests on Ubuntu
164+
framework: pytorch
165+
runner: docker-cpu
166+
image: diffusers/diffusers-pytorch-cpu
167+
report: torch_cpu
168+
- name: Fast Flax CPU tests on Ubuntu
169+
framework: flax
170+
runner: docker-cpu
171+
image: diffusers/diffusers-flax-cpu
172+
report: flax_cpu
173+
- name: Fast ONNXRuntime CPU tests on Ubuntu
174+
framework: onnxruntime
175+
runner: docker-cpu
176+
image: diffusers/diffusers-onnxruntime-cpu
177+
report: onnx_cpu
178+
- name: PyTorch Example CPU tests on Ubuntu
179+
framework: pytorch_examples
180+
runner: docker-cpu
181+
image: diffusers/diffusers-pytorch-cpu
182+
report: torch_cpu
183+
184+
name: ${{ matrix.config.name }}
185+
186+
runs-on: ${{ matrix.config.runner }}
187+
188+
container:
189+
image: ${{ matrix.config.image }}
190+
options: --shm-size "16gb" --ipc host -v /mnt/hf_cache:/mnt/cache/
191+
192+
defaults:
193+
run:
194+
shell: bash
195+
196+
steps:
197+
- name: Checkout diffusers
198+
uses: actions/checkout@v3
199+
with:
200+
fetch-depth: 2
201+
202+
- name: Install dependencies
203+
run: |
204+
apt-get update && apt-get install libsndfile1-dev -y
205+
python -m pip install -e .[quality,test]
206+
python -m pip install -U git+https://github.com/huggingface/transformers
207+
python -m pip install git+https://github.com/huggingface/accelerate
208+
209+
- name: Environment
210+
run: |
211+
python utils/print_env.py
212+
213+
- name: Run fast PyTorch CPU tests
214+
if: ${{ matrix.config.framework == 'pytorch' }}
215+
run: |
216+
python -m pytest -n 2 --max-worker-restart=0 --dist=loadfile \
217+
-s -v -k "not Flax and not Onnx" \
218+
--make-reports=tests_${{ matrix.config.report }} \
219+
tests/
220+
221+
- name: Run fast Flax TPU tests
222+
if: ${{ matrix.config.framework == 'flax' }}
223+
run: |
224+
python -m pytest -n 2 --max-worker-restart=0 --dist=loadfile \
225+
-s -v -k "Flax" \
226+
--make-reports=tests_${{ matrix.config.report }} \
227+
tests/
228+
229+
- name: Run fast ONNXRuntime CPU tests
230+
if: ${{ matrix.config.framework == 'onnxruntime' }}
231+
run: |
232+
python -m pytest -n 2 --max-worker-restart=0 --dist=loadfile \
233+
-s -v -k "Onnx" \
234+
--make-reports=tests_${{ matrix.config.report }} \
235+
tests/
236+
237+
- name: Run example PyTorch CPU tests
238+
if: ${{ matrix.config.framework == 'pytorch_examples' }}
239+
run: |
240+
python -m pytest -n 2 --max-worker-restart=0 --dist=loadfile \
241+
--make-reports=tests_${{ matrix.config.report }} \
242+
examples/test_examples.py
243+
244+
- name: Failure short reports
245+
if: ${{ failure() }}
246+
run: cat reports/tests_${{ matrix.config.report }}_failures_short.txt
247+
248+
- name: Test suite reports artifacts
249+
if: ${{ always() }}
250+
uses: actions/upload-artifact@v2
251+
with:
252+
name: pr_${{ matrix.config.report }}_test_reports
253+
path: reports
254+
255+
run_fast_tests_apple_m1:
256+
name: Fast PyTorch MPS tests on MacOS
257+
runs-on: [ self-hosted, apple-m1 ]
258+
259+
steps:
260+
- name: Checkout diffusers
261+
uses: actions/checkout@v3
262+
with:
263+
fetch-depth: 2
264+
265+
- name: Clean checkout
266+
shell: arch -arch arm64 bash {0}
267+
run: |
268+
git clean -fxd
269+
270+
- name: Setup miniconda
271+
uses: ./.github/actions/setup-miniconda
272+
with:
273+
python-version: 3.9
274+
275+
- name: Install dependencies
276+
shell: arch -arch arm64 bash {0}
277+
run: |
278+
${CONDA_RUN} python -m pip install --upgrade pip
279+
${CONDA_RUN} python -m pip install -e .[quality,test]
280+
${CONDA_RUN} python -m pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cpu
281+
${CONDA_RUN} python -m pip install git+https://github.com/huggingface/accelerate
282+
${CONDA_RUN} python -m pip install -U git+https://github.com/huggingface/transformers
283+
284+
- name: Environment
285+
shell: arch -arch arm64 bash {0}
286+
run: |
287+
${CONDA_RUN} python utils/print_env.py
288+
289+
- name: Run fast PyTorch tests on M1 (MPS)
290+
shell: arch -arch arm64 bash {0}
291+
env:
292+
HF_HOME: /System/Volumes/Data/mnt/cache
293+
HUGGING_FACE_HUB_TOKEN: ${{ secrets.HUGGING_FACE_HUB_TOKEN }}
294+
run: |
295+
${CONDA_RUN} python -m pytest -n 0 -s -v --make-reports=tests_torch_mps tests/
296+
297+
- name: Failure short reports
298+
if: ${{ failure() }}
299+
run: cat reports/tests_torch_mps_failures_short.txt
300+
301+
- name: Test suite reports artifacts
302+
if: ${{ always() }}
303+
uses: actions/upload-artifact@v2
304+
with:
305+
name: pr_torch_mps_test_reports
306+
path: reports

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,6 @@ tags
169169

170170
# dependencies
171171
/transformers
172+
173+
# ruff
174+
.ruff_cache

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ Follow these steps to start contributing ([supported Python versions](https://gi
177177
$ make style
178178
```
179179

180-
🧨 Diffusers also uses `flake8` and a few custom scripts to check for coding mistakes. Quality
180+
🧨 Diffusers also uses `ruff` and a few custom scripts to check for coding mistakes. Quality
181181
control runs in CI, however you can also run the same checks with:
182182

183183
```bash

Makefile

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ modified_only_fixup:
99
$(eval modified_py_files := $(shell python utils/get_modified_files.py $(check_dirs)))
1010
@if test -n "$(modified_py_files)"; then \
1111
echo "Checking/fixing $(modified_py_files)"; \
12-
black --preview $(modified_py_files); \
13-
isort $(modified_py_files); \
14-
flake8 $(modified_py_files); \
12+
black $(modified_py_files); \
13+
ruff $(modified_py_files); \
1514
else \
1615
echo "No library .py files were modified"; \
1716
fi
@@ -41,9 +40,8 @@ repo-consistency:
4140
# this target runs checks on all files
4241

4342
quality:
44-
black --check --preview $(check_dirs)
45-
isort --check-only $(check_dirs)
46-
flake8 $(check_dirs)
43+
black --check $(check_dirs)
44+
ruff $(check_dirs)
4745
doc-builder style src/diffusers docs/source --max_len 119 --check_only --path_to_docs docs/source
4846
python utils/check_doc_toc.py
4947

@@ -57,8 +55,8 @@ extra_style_checks:
5755
# this target runs checks on all files and potentially modifies some of them
5856

5957
style:
60-
black --preview $(check_dirs)
61-
isort $(check_dirs)
58+
black $(check_dirs)
59+
ruff $(check_dirs) --fix
6260
${MAKE} autogenerate_code
6361
${MAKE} extra_style_checks
6462

docs/source/en/_toctree.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@
145145
title: Image-Variation
146146
- local: api/pipelines/stable_diffusion/upscale
147147
title: Super-Resolution
148+
- local: api/pipelines/stable_diffusion/latent_upscale
149+
title: Stable-Diffusion-Latent-Upscaler
148150
- local: api/pipelines/stable_diffusion/pix2pix
149151
title: InstructPix2Pix
150152
title: Stable Diffusion
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!--Copyright 2023 The HuggingFace Team. All rights reserved.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4+
the License. You may obtain a copy of the License at
5+
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
8+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9+
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10+
specific language governing permissions and limitations under the License.
11+
-->
12+
13+
# Stable Diffusion Latent Upscaler
14+
15+
## StableDiffusionLatentUpscalePipeline
16+
17+
The Stable Diffusion Latent Upscaler model was created by [Katherine Crowson](https://github.com/crowsonkb/k-diffusion) in collaboration with [Stability AI](https://stability.ai/). It can be used on top of any [`StableDiffusionUpscalePipeline`] checkpoint to enhance its output image resolution by a factor of 2.
18+
19+
A notebook that demonstrates the original implementation can be found here:
20+
- [Stable Diffusion Upscaler Demo](https://colab.research.google.com/drive/1o1qYJcFeywzCIdkfKJy7cTpgZTCM2EI4)
21+
22+
Available Checkpoints are:
23+
- *stabilityai/latent-upscaler*: [stabilityai/sd-x2-latent-upscaler](https://huggingface.co/stabilityai/sd-x2-latent-upscaler)
24+
25+
26+
[[autodoc]] StableDiffusionLatentUpscalePipeline
27+
- all
28+
- __call__
29+
- enable_sequential_cpu_offload
30+
- enable_attention_slicing
31+
- disable_attention_slicing
32+
- enable_xformers_memory_efficient_attention
33+
- disable_xformers_memory_efficient_attention

docs/source/en/api/pipelines/stable_diffusion/overview.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ For more details about how Stable Diffusion works and how it differs from the ba
3131
| [StableDiffusionDepth2ImgPipeline](./depth2img) | **Experimental** *Depth-to-Image Text-Guided Generation * | | Coming soon
3232
| [StableDiffusionImageVariationPipeline](./image_variation) | **Experimental** *Image Variation Generation * | | [🤗 Stable Diffusion Image Variations](https://huggingface.co/spaces/lambdalabs/stable-diffusion-image-variations)
3333
| [StableDiffusionUpscalePipeline](./upscale) | **Experimental** *Text-Guided Image Super-Resolution * | | Coming soon
34+
| [StableDiffusionLatentUpscalePipeline](./latent_upscale) | **Experimental** *Text-Guided Image Super-Resolution * | | Coming soon
3435
| [StableDiffusionInstructPix2PixPipeline](./pix2pix) | **Experimental** *Text-Based Image Editing * | | [InstructPix2Pix: Learning to Follow Image Editing Instructions](https://huggingface.co/spaces/timbrooks/instruct-pix2pix)
3536

3637

docs/source/en/conceptual/contribution.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ Follow these steps to start contributing ([supported Python versions](https://gi
177177
$ make style
178178
```
179179

180-
🧨 Diffusers also uses `flake8` and a few custom scripts to check for coding mistakes. Quality
180+
🧨 Diffusers also uses `ruff` and a few custom scripts to check for coding mistakes. Quality
181181
control runs in CI, however you can also run the same checks with:
182182

183183
```bash

0 commit comments

Comments
 (0)