Skip to content

Commit 187ea53

Browse files
Improve SD XL (huggingface#3968)
* improve sd xl * correct more * finish * make style * fix more
1 parent 8bf80fc commit 187ea53

21 files changed

+133
-76
lines changed

.github/workflows/push_tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ jobs:
6161
6262
- name: Install dependencies
6363
run: |
64+
apt-get update && apt-get install libsndfile1-dev libgl1 -y
6465
python -m pip install -e .[quality,test]
6566
6667
- name: Environment

.github/workflows/push_tests_fast.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060

6161
- name: Install dependencies
6262
run: |
63-
apt-get update && apt-get install libsndfile1-dev -y
63+
apt-get update && apt-get install libsndfile1-dev libgl1 -y
6464
python -m pip install -e .[quality,test]
6565
6666
- name: Environment

docs/source/en/_toctree.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@
247247
title: Safe Stable Diffusion
248248
- local: api/pipelines/stable_diffusion/stable_diffusion_2
249249
title: Stable Diffusion 2
250+
- local: api/pipelines/stable_diffusion/stable_diffusion_xl
251+
title: Stable Diffusion XL
250252
- local: api/pipelines/stable_diffusion/latent_upscale
251253
title: Stable-Diffusion-Latent-Upscaler
252254
- local: api/pipelines/stable_diffusion/upscale

docs/source/en/api/loaders.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ Adapters (textual inversion, LoRA, hypernetworks) allow you to modify a diffusio
3232

3333
[[autodoc]] loaders.LoraLoaderMixin
3434

35-
## FromCkptMixin
35+
## FromSingleFileMixin
3636

37-
[[autodoc]] loaders.FromCkptMixin
37+
[[autodoc]] loaders.FromSingleFileMixin

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ proposed by Chenlin Meng, Yutong He, Yang Song, Jiaming Song, Jiajun Wu, Jun-Yan
3131
- enable_xformers_memory_efficient_attention
3232
- disable_xformers_memory_efficient_attention
3333
- load_textual_inversion
34-
- from_ckpt
34+
- from_single_file
3535
- load_lora_weights
3636
- save_lora_weights
3737

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Available Checkpoints are:
4040
- enable_vae_tiling
4141
- disable_vae_tiling
4242
- load_textual_inversion
43-
- from_ckpt
43+
- from_single_file
4444
- load_lora_weights
4545
- save_lora_weights
4646

docs/source/en/using-diffusers/other-formats.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ This guide will show you how to convert other Stable Diffusion formats to be com
2626

2727
## PyTorch .ckpt
2828

29-
The checkpoint - or `.ckpt` - format is commonly used to store and save models. The `.ckpt` file contains the entire model and is typically several GBs in size. While you can load and use a `.ckpt` file directly with the [`~StableDiffusionPipeline.from_ckpt`] method, it is generally better to convert the `.ckpt` file to 🤗 Diffusers so both formats are available.
29+
The checkpoint - or `.ckpt` - format is commonly used to store and save models. The `.ckpt` file contains the entire model and is typically several GBs in size. While you can load and use a `.ckpt` file directly with the [`~StableDiffusionPipeline.from_single_file`] method, it is generally better to convert the `.ckpt` file to 🤗 Diffusers so both formats are available.
3030

3131
There are two options for converting a `.ckpt` file; use a Space to convert the checkpoint or convert the `.ckpt` file with a script.
3232

docs/source/en/using-diffusers/using_safetensors.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ from diffusers import DiffusionPipeline
2121
pipeline = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", use_safetensors=True)
2222
```
2323

24-
However, model weights are not necessarily stored in separate subfolders like in the example above. Sometimes, all the weights are stored in a single `.safetensors` file. In this case, if the weights are Stable Diffusion weights, you can load the file directly with the [`~diffusers.loaders.FromCkptMixin.from_ckpt`] method:
24+
However, model weights are not necessarily stored in separate subfolders like in the example above. Sometimes, all the weights are stored in a single `.safetensors` file. In this case, if the weights are Stable Diffusion weights, you can load the file directly with the [`~diffusers.loaders.FromSingleFileMixin.from_single_file`] method:
2525

2626
```py
2727
from diffusers import StableDiffusionPipeline
2828

29-
pipeline = StableDiffusionPipeline.from_ckpt(
29+
pipeline = StableDiffusionPipeline.from_single_file(
3030
"https://huggingface.co/WarriorMama777/OrangeMixs/blob/main/Models/AbyssOrangeMix/AbyssOrangeMix.safetensors"
3131
)
3232
```

examples/community/lpw_stable_diffusion.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from diffusers import DiffusionPipeline
1212
from diffusers.configuration_utils import FrozenDict
1313
from diffusers.image_processor import VaeImageProcessor
14-
from diffusers.loaders import FromCkptMixin, LoraLoaderMixin, TextualInversionLoaderMixin
14+
from diffusers.loaders import FromSingleFileMixin, LoraLoaderMixin, TextualInversionLoaderMixin
1515
from diffusers.models import AutoencoderKL, UNet2DConditionModel
1616
from diffusers.pipelines.stable_diffusion import StableDiffusionPipelineOutput, StableDiffusionSafetyChecker
1717
from diffusers.schedulers import KarrasDiffusionSchedulers
@@ -410,7 +410,7 @@ def preprocess_mask(mask, batch_size, scale_factor=8):
410410

411411

412412
class StableDiffusionLongPromptWeightingPipeline(
413-
DiffusionPipeline, TextualInversionLoaderMixin, LoraLoaderMixin, FromCkptMixin
413+
DiffusionPipeline, TextualInversionLoaderMixin, LoraLoaderMixin, FromSingleFileMixin
414414
):
415415
r"""
416416
Pipeline for text-to-image generation using Stable Diffusion without tokens length limit, and support parsing

src/diffusers/loaders.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,13 +1276,19 @@ def _convert_kohya_lora_to_diffusers(self, state_dict):
12761276
return new_state_dict, network_alpha
12771277

12781278

1279-
class FromCkptMixin:
1279+
class FromSingleFileMixin:
12801280
"""
12811281
Load model weights saved in the `.ckpt` format into a [`DiffusionPipeline`].
12821282
"""
12831283

12841284
@classmethod
1285-
def from_ckpt(cls, pretrained_model_link_or_path, **kwargs):
1285+
def from_ckpt(cls, *args, **kwargs):
1286+
deprecation_message = "The function `from_ckpt` is deprecated in favor of `from_single_file` and will be removed in diffusers v.0.21. Please make sure to use `StableDiffusionPipeline.from_single_file(...)` instead."
1287+
deprecate("from_ckpt", "0.21.0", deprecation_message, standard_warn=False)
1288+
return cls.from_single_file(*args, **kwargs)
1289+
1290+
@classmethod
1291+
def from_single_file(cls, pretrained_model_link_or_path, **kwargs):
12861292
r"""
12871293
Instantiate a [`DiffusionPipeline`] from pretrained pipeline weights saved in the `.ckpt` format. The pipeline
12881294
is set in evaluation mode (`model.eval()`) by default.
@@ -1361,16 +1367,16 @@ def from_ckpt(cls, pretrained_model_link_or_path, **kwargs):
13611367
>>> from diffusers import StableDiffusionPipeline
13621368
13631369
>>> # Download pipeline from huggingface.co and cache.
1364-
>>> pipeline = StableDiffusionPipeline.from_ckpt(
1370+
>>> pipeline = StableDiffusionPipeline.from_single_file(
13651371
... "https://huggingface.co/WarriorMama777/OrangeMixs/blob/main/Models/AbyssOrangeMix/AbyssOrangeMix.safetensors"
13661372
... )
13671373
13681374
>>> # Download pipeline from local file
13691375
>>> # file is downloaded under ./v1-5-pruned-emaonly.ckpt
1370-
>>> pipeline = StableDiffusionPipeline.from_ckpt("./v1-5-pruned-emaonly")
1376+
>>> pipeline = StableDiffusionPipeline.from_single_file("./v1-5-pruned-emaonly")
13711377
13721378
>>> # Enable float16 and move to GPU
1373-
>>> pipeline = StableDiffusionPipeline.from_ckpt(
1379+
>>> pipeline = StableDiffusionPipeline.from_single_file(
13741380
... "https://huggingface.co/runwayml/stable-diffusion-v1-5/blob/main/v1-5-pruned-emaonly.ckpt",
13751381
... torch_dtype=torch.float16,
13761382
... )

0 commit comments

Comments
 (0)