Skip to content

Commit f767db7

Browse files
authored
Merge branch 'main' into patch-1
2 parents 0819573 + 37c9697 commit f767db7

File tree

9 files changed

+103
-27
lines changed

9 files changed

+103
-27
lines changed

.github/workflows/nightly_tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ jobs:
265265
266266
- name: Run PyTorch CUDA tests
267267
env:
268-
HF_TOKEN: ${{ secrets.HF_TOKEN }}
268+
HF_TOKEN: ${{ secrets.DIFFUSERS_HF_HUB_READ_TOKEN }}
269269
# https://pytorch.org/docs/stable/notes/randomness.html#avoiding-nondeterministic-algorithms
270270
CUBLAS_WORKSPACE_CONFIG: :16:8
271271
run: |
@@ -505,7 +505,7 @@ jobs:
505505
# shell: arch -arch arm64 bash {0}
506506
# env:
507507
# HF_HOME: /System/Volumes/Data/mnt/cache
508-
# HF_TOKEN: ${{ secrets.HF_TOKEN }}
508+
# HF_TOKEN: ${{ secrets.DIFFUSERS_HF_HUB_READ_TOKEN }}
509509
# run: |
510510
# ${CONDA_RUN} python -m pytest -n 1 -s -v --make-reports=tests_torch_mps \
511511
# --report-log=tests_torch_mps.log \
@@ -561,7 +561,7 @@ jobs:
561561
# shell: arch -arch arm64 bash {0}
562562
# env:
563563
# HF_HOME: /System/Volumes/Data/mnt/cache
564-
# HF_TOKEN: ${{ secrets.HF_TOKEN }}
564+
# HF_TOKEN: ${{ secrets.DIFFUSERS_HF_HUB_READ_TOKEN }}
565565
# run: |
566566
# ${CONDA_RUN} python -m pytest -n 1 -s -v --make-reports=tests_torch_mps \
567567
# --report-log=tests_torch_mps.log \

.github/workflows/push_tests.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ jobs:
187187
188188
- name: Run Flax TPU tests
189189
env:
190-
HF_TOKEN: ${{ secrets.HF_TOKEN }}
190+
HF_TOKEN: ${{ secrets.DIFFUSERS_HF_HUB_READ_TOKEN }}
191191
run: |
192192
python -m pytest -n 0 \
193193
-s -v -k "Flax" \
@@ -235,7 +235,7 @@ jobs:
235235
236236
- name: Run ONNXRuntime CUDA tests
237237
env:
238-
HF_TOKEN: ${{ secrets.HF_TOKEN }}
238+
HF_TOKEN: ${{ secrets.DIFFUSERS_HF_HUB_READ_TOKEN }}
239239
run: |
240240
python -m pytest -n 1 --max-worker-restart=0 --dist=loadfile \
241241
-s -v -k "Onnx" \
@@ -283,7 +283,7 @@ jobs:
283283
python utils/print_env.py
284284
- name: Run example tests on GPU
285285
env:
286-
HF_TOKEN: ${{ secrets.HF_TOKEN }}
286+
HF_TOKEN: ${{ secrets.DIFFUSERS_HF_HUB_READ_TOKEN }}
287287
RUN_COMPILE: yes
288288
run: |
289289
python -m pytest -n 1 --max-worker-restart=0 --dist=loadfile -s -v -k "compile" --make-reports=tests_torch_compile_cuda tests/
@@ -326,7 +326,7 @@ jobs:
326326
python utils/print_env.py
327327
- name: Run example tests on GPU
328328
env:
329-
HF_TOKEN: ${{ secrets.HF_TOKEN }}
329+
HF_TOKEN: ${{ secrets.DIFFUSERS_HF_HUB_READ_TOKEN }}
330330
run: |
331331
python -m pytest -n 1 --max-worker-restart=0 --dist=loadfile -s -v -k "xformers" --make-reports=tests_torch_xformers_cuda tests/
332332
- name: Failure short reports
@@ -372,7 +372,7 @@ jobs:
372372
373373
- name: Run example tests on GPU
374374
env:
375-
HF_TOKEN: ${{ secrets.HF_TOKEN }}
375+
HF_TOKEN: ${{ secrets.DIFFUSERS_HF_HUB_READ_TOKEN }}
376376
run: |
377377
python -m venv /opt/venv && export PATH="/opt/venv/bin:$PATH"
378378
python -m uv pip install timm

.github/workflows/release_tests_fast.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ jobs:
8181
python utils/print_env.py
8282
- name: Slow PyTorch CUDA checkpoint tests on Ubuntu
8383
env:
84-
HF_TOKEN: ${{ secrets.HF_TOKEN }}
84+
HF_TOKEN: ${{ secrets.DIFFUSERS_HF_HUB_READ_TOKEN }}
8585
# https://pytorch.org/docs/stable/notes/randomness.html#avoiding-nondeterministic-algorithms
8686
CUBLAS_WORKSPACE_CONFIG: :16:8
8787
run: |
@@ -135,7 +135,7 @@ jobs:
135135
136136
- name: Run PyTorch CUDA tests
137137
env:
138-
HF_TOKEN: ${{ secrets.HF_TOKEN }}
138+
HF_TOKEN: ${{ secrets.DIFFUSERS_HF_HUB_READ_TOKEN }}
139139
# https://pytorch.org/docs/stable/notes/randomness.html#avoiding-nondeterministic-algorithms
140140
CUBLAS_WORKSPACE_CONFIG: :16:8
141141
run: |
@@ -186,7 +186,7 @@ jobs:
186186
187187
- name: Run PyTorch CUDA tests
188188
env:
189-
HF_TOKEN: ${{ secrets.HF_TOKEN }}
189+
HF_TOKEN: ${{ secrets.DIFFUSERS_HF_HUB_READ_TOKEN }}
190190
# https://pytorch.org/docs/stable/notes/randomness.html#avoiding-nondeterministic-algorithms
191191
CUBLAS_WORKSPACE_CONFIG: :16:8
192192
run: |
@@ -241,7 +241,7 @@ jobs:
241241
242242
- name: Run slow Flax TPU tests
243243
env:
244-
HF_TOKEN: ${{ secrets.HF_TOKEN }}
244+
HF_TOKEN: ${{ secrets.DIFFUSERS_HF_HUB_READ_TOKEN }}
245245
run: |
246246
python -m pytest -n 0 \
247247
-s -v -k "Flax" \
@@ -289,7 +289,7 @@ jobs:
289289
290290
- name: Run slow ONNXRuntime CUDA tests
291291
env:
292-
HF_TOKEN: ${{ secrets.HF_TOKEN }}
292+
HF_TOKEN: ${{ secrets.DIFFUSERS_HF_HUB_READ_TOKEN }}
293293
run: |
294294
python -m pytest -n 1 --max-worker-restart=0 --dist=loadfile \
295295
-s -v -k "Onnx" \
@@ -337,7 +337,7 @@ jobs:
337337
python utils/print_env.py
338338
- name: Run example tests on GPU
339339
env:
340-
HF_TOKEN: ${{ secrets.HF_TOKEN }}
340+
HF_TOKEN: ${{ secrets.DIFFUSERS_HF_HUB_READ_TOKEN }}
341341
RUN_COMPILE: yes
342342
run: |
343343
python -m pytest -n 1 --max-worker-restart=0 --dist=loadfile -s -v -k "compile" --make-reports=tests_torch_compile_cuda tests/
@@ -380,7 +380,7 @@ jobs:
380380
python utils/print_env.py
381381
- name: Run example tests on GPU
382382
env:
383-
HF_TOKEN: ${{ secrets.HF_TOKEN }}
383+
HF_TOKEN: ${{ secrets.DIFFUSERS_HF_HUB_READ_TOKEN }}
384384
run: |
385385
python -m pytest -n 1 --max-worker-restart=0 --dist=loadfile -s -v -k "xformers" --make-reports=tests_torch_xformers_cuda tests/
386386
- name: Failure short reports
@@ -426,7 +426,7 @@ jobs:
426426
427427
- name: Run example tests on GPU
428428
env:
429-
HF_TOKEN: ${{ secrets.HF_TOKEN }}
429+
HF_TOKEN: ${{ secrets.DIFFUSERS_HF_HUB_READ_TOKEN }}
430430
run: |
431431
python -m venv /opt/venv && export PATH="/opt/venv/bin:$PATH"
432432
python -m uv pip install timm

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,53 @@ image.save("output.png")
309309

310310
When unloading the Control LoRA weights, call `pipe.unload_lora_weights(reset_to_overwritten_params=True)` to reset the `pipe.transformer` completely back to its original form. The resultant pipeline can then be used with methods like [`DiffusionPipeline.from_pipe`]. More details about this argument are available in [this PR](https://github.com/huggingface/diffusers/pull/10397).
311311

312+
## IP-Adapter
313+
314+
<Tip>
315+
316+
Check out [IP-Adapter](../../../using-diffusers/ip_adapter) to learn more about how IP-Adapters work.
317+
318+
</Tip>
319+
320+
An IP-Adapter lets you prompt Flux with images, in addition to the text prompt. This is especially useful when describing complex concepts that are difficult to articulate through text alone and you have reference images.
321+
322+
```python
323+
import torch
324+
from diffusers import FluxPipeline
325+
from diffusers.utils import load_image
326+
327+
pipe = FluxPipeline.from_pretrained(
328+
"black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16
329+
).to("cuda")
330+
331+
image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/flux_ip_adapter_input.jpg").resize((1024, 1024))
332+
333+
pipe.load_ip_adapter(
334+
"XLabs-AI/flux-ip-adapter",
335+
weight_name="ip_adapter.safetensors",
336+
image_encoder_pretrained_model_name_or_path="openai/clip-vit-large-patch14"
337+
)
338+
pipe.set_ip_adapter_scale(1.0)
339+
340+
image = pipe(
341+
width=1024,
342+
height=1024,
343+
prompt="wearing sunglasses",
344+
negative_prompt="",
345+
true_cfg=4.0,
346+
generator=torch.Generator().manual_seed(4444),
347+
ip_adapter_image=image,
348+
).images[0]
349+
350+
image.save('flux_ip_adapter_output.jpg')
351+
```
352+
353+
<div class="justify-center">
354+
<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/flux_ip_adapter_output.jpg"/>
355+
<figcaption class="mt-2 text-sm text-center text-gray-500">IP-Adapter examples with prompt "wearing sunglasses"</figcaption>
356+
</div>
357+
358+
312359
## Running FP16 inference
313360

314361
Flux can generate high-quality images with FP16 (i.e. to accelerate inference on Turing/Volta GPUs) but produces different outputs compared to FP32/BF16. The issue is that some activations in the text encoders have to be clipped when running in FP16, which affects the overall image. Forcing text encoders to run with FP32 inference thus removes this output difference. See [here](https://github.com/huggingface/diffusers/pull/9097#issuecomment-2272292516) for details.

docs/source/en/installation.md

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,60 @@ You should install 🤗 Diffusers in a [virtual environment](https://docs.python
2323
If you're unfamiliar with Python virtual environments, take a look at this [guide](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/).
2424
A virtual environment makes it easier to manage different projects and avoid compatibility issues between dependencies.
2525

26-
Start by creating a virtual environment in your project directory:
26+
Create a virtual environment with Python or [uv](https://docs.astral.sh/uv/) (refer to [Installation](https://docs.astral.sh/uv/getting-started/installation/) for installation instructions), a fast Rust-based Python package and project manager.
27+
28+
<hfoptions id="install">
29+
<hfoption id="uv">
2730

2831
```bash
29-
python -m venv .env
32+
uv venv my-env
33+
source my-env/bin/activate
3034
```
3135

32-
Activate the virtual environment:
36+
</hfoption>
37+
<hfoption id="Python">
3338

3439
```bash
35-
source .env/bin/activate
40+
python -m venv my-env
41+
source my-env/bin/activate
3642
```
3743

38-
You should also install 🤗 Transformers because 🤗 Diffusers relies on its models:
44+
</hfoption>
45+
</hfoptions>
46+
47+
You should also install 🤗 Transformers because 🤗 Diffusers relies on its models.
3948

4049

4150
<frameworkcontent>
4251
<pt>
43-
Note - PyTorch only supports Python 3.8 - 3.11 on Windows.
52+
53+
PyTorch only supports Python 3.8 - 3.11 on Windows. Install Diffusers with uv.
54+
55+
```bash
56+
uv install diffusers["torch"] transformers
57+
```
58+
59+
You can also install Diffusers with pip.
60+
4461
```bash
4562
pip install diffusers["torch"] transformers
4663
```
64+
4765
</pt>
4866
<jax>
67+
68+
Install Diffusers with uv.
69+
70+
```bash
71+
uv pip install diffusers["flax"] transformers
72+
```
73+
74+
You can also install Diffusers with pip.
75+
4976
```bash
5077
pip install diffusers["flax"] transformers
5178
```
79+
5280
</jax>
5381
</frameworkcontent>
5482

docs/source/en/optimization/para_attn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ However, it is hard to decide when to reuse the cache to ensure quality generate
2929
This achieves a 2x speedup on FLUX.1-dev and HunyuanVideo inference with very good quality.
3030

3131
<figure>
32-
<img src="https://huggingface.co/datasets/chengzeyi/documentation-images/resolve/main/diffusers/para-attn/ada-cache.png" alt="Cache in Diffusion Transformer" />
32+
<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/para-attn/ada-cache.png" alt="Cache in Diffusion Transformer" />
3333
<figcaption>How AdaCache works, First Block Cache is a variant of it</figcaption>
3434
</figure>
3535

src/diffusers/pipelines/flux/pipeline_flux_controlnet_inpainting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -930,8 +930,8 @@ def __call__(
930930
if isinstance(self.controlnet, FluxControlNetModel):
931931
control_image = self.prepare_image(
932932
image=control_image,
933-
width=height,
934-
height=width,
933+
width=width,
934+
height=height,
935935
batch_size=batch_size * num_images_per_prompt,
936936
num_images_per_prompt=num_images_per_prompt,
937937
device=device,

src/diffusers/utils/import_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@
149149
"onnxruntime-openvino",
150150
"ort_nightly_directml",
151151
"onnxruntime-rocm",
152+
"onnxruntime-migraphx",
152153
"onnxruntime-training",
153154
)
154155
_onnxruntime_version = None

tests/schedulers/test_scheduler_flax.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,8 @@ def test_full_loop_no_noise(self):
338338
assert abs(result_sum - 255.0714) < 1e-2
339339
assert abs(result_mean - 0.332124) < 1e-3
340340
else:
341-
assert abs(result_sum - 255.1113) < 1e-1
342-
assert abs(result_mean - 0.332176) < 1e-3
341+
assert abs(result_sum - 270.2) < 1e-1
342+
assert abs(result_mean - 0.3519494) < 1e-3
343343

344344

345345
@require_flax

0 commit comments

Comments
 (0)