Skip to content

Commit a350d0c

Browse files
authored
Merge branch 'main' into redux
2 parents 7c93dd0 + 63b631f commit a350d0c

28 files changed

+1548
-27
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ Since RegEx is supported as a way for matching layer identifiers, it is crucial
9696
- all
9797
- __call__
9898

99+
## StableDiffusion3PAGImg2ImgPipeline
100+
[[autodoc]] StableDiffusion3PAGImg2ImgPipeline
101+
- all
102+
- __call__
99103

100104
## PixArtSigmaPAGPipeline
101105
[[autodoc]] PixArtSigmaPAGPipeline

docs/source/en/tutorials/basic_training.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ For convenience, create a `TrainingConfig` class containing the training hyperpa
7575

7676
... push_to_hub = True # whether to upload the saved model to the HF Hub
7777
... hub_model_id = "<your-username>/<my-awesome-model>" # the name of the repository to create on the HF Hub
78-
... hub_private_repo = False
78+
... hub_private_repo = None
7979
... overwrite_output_dir = True # overwrite the old model when re-running the notebook
8080
... seed = 0
8181

docs/source/ko/tutorials/basic_training.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ huggingface-cli login
7676
... output_dir = "ddpm-butterflies-128" # 로컬 및 HF Hub에 저장되는 모델명
7777

7878
... push_to_hub = True # 저장된 모델을 HF Hub에 업로드할지 여부
79-
... hub_private_repo = False
79+
... hub_private_repo = None
8080
... overwrite_output_dir = True # 노트북을 다시 실행할 때 이전 모델에 덮어씌울지
8181
... seed = 0
8282

src/diffusers/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@
339339
"StableDiffusion3Img2ImgPipeline",
340340
"StableDiffusion3InpaintPipeline",
341341
"StableDiffusion3PAGPipeline",
342+
"StableDiffusion3PAGImg2ImgPipeline",
342343
"StableDiffusion3Pipeline",
343344
"StableDiffusionAdapterPipeline",
344345
"StableDiffusionAttendAndExcitePipeline",
@@ -807,6 +808,7 @@
807808
StableDiffusion3ControlNetPipeline,
808809
StableDiffusion3Img2ImgPipeline,
809810
StableDiffusion3InpaintPipeline,
811+
StableDiffusion3PAGImg2ImgPipeline,
810812
StableDiffusion3PAGPipeline,
811813
StableDiffusion3Pipeline,
812814
StableDiffusionAdapterPipeline,

src/diffusers/configuration_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def save_config(self, save_directory: Union[str, os.PathLike], push_to_hub: bool
170170

171171
if push_to_hub:
172172
commit_message = kwargs.pop("commit_message", None)
173-
private = kwargs.pop("private", False)
173+
private = kwargs.pop("private", None)
174174
create_pr = kwargs.pop("create_pr", False)
175175
token = kwargs.pop("token", None)
176176
repo_id = kwargs.pop("repo_id", save_directory.split(os.path.sep)[-1])

src/diffusers/loaders/single_file_model.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ def from_single_file(cls, pretrained_model_link_or_path_or_dict: Optional[str] =
269269
pretrained_model_name_or_path=default_pretrained_model_config_name,
270270
subfolder=subfolder,
271271
local_files_only=local_files_only,
272+
token=token,
272273
)
273274
expected_kwargs, optional_kwargs = cls._get_signature_keys(cls)
274275

src/diffusers/loaders/single_file_utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@
127127
"sd35_large": {
128128
"pretrained_model_name_or_path": "stabilityai/stable-diffusion-3.5-large",
129129
},
130+
"sd35_medium": {
131+
"pretrained_model_name_or_path": "stabilityai/stable-diffusion-3.5-medium",
132+
},
130133
"animatediff_v1": {"pretrained_model_name_or_path": "guoyww/animatediff-motion-adapter-v1-5"},
131134
"animatediff_v2": {"pretrained_model_name_or_path": "guoyww/animatediff-motion-adapter-v1-5-2"},
132135
"animatediff_v3": {"pretrained_model_name_or_path": "guoyww/animatediff-motion-adapter-v1-5-3"},
@@ -527,7 +530,10 @@ def infer_diffusers_model_type(checkpoint):
527530
model_type = "stable_cascade_stage_b"
528531

529532
elif CHECKPOINT_KEY_NAMES["sd3"] in checkpoint and checkpoint[CHECKPOINT_KEY_NAMES["sd3"]].shape[-1] == 9216:
530-
model_type = "sd3"
533+
if checkpoint["model.diffusion_model.pos_embed"].shape[1] == 36864:
534+
model_type = "sd3"
535+
elif checkpoint["model.diffusion_model.pos_embed"].shape[1] == 147456:
536+
model_type = "sd35_medium"
531537

532538
elif CHECKPOINT_KEY_NAMES["sd35_large"] in checkpoint:
533539
model_type = "sd35_large"

src/diffusers/models/attention_processor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,6 +1171,7 @@ def __call__(
11711171
attn: Attention,
11721172
hidden_states: torch.FloatTensor,
11731173
encoder_hidden_states: torch.FloatTensor = None,
1174+
attention_mask: Optional[torch.FloatTensor] = None,
11741175
) -> torch.FloatTensor:
11751176
residual = hidden_states
11761177

src/diffusers/models/autoencoders/autoencoder_kl.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import torch.nn as nn
1818

1919
from ...configuration_utils import ConfigMixin, register_to_config
20+
from ...loaders import PeftAdapterMixin
2021
from ...loaders.single_file_model import FromOriginalModelMixin
2122
from ...utils import deprecate
2223
from ...utils.accelerate_utils import apply_forward_hook
@@ -34,7 +35,7 @@
3435
from .vae import Decoder, DecoderOutput, DiagonalGaussianDistribution, Encoder
3536

3637

37-
class AutoencoderKL(ModelMixin, ConfigMixin, FromOriginalModelMixin):
38+
class AutoencoderKL(ModelMixin, ConfigMixin, FromOriginalModelMixin, PeftAdapterMixin):
3839
r"""
3940
A VAE model with KL loss for encoding images into latents and decoding latent representations into images.
4041

src/diffusers/models/controlnets/controlnet_sd3.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,20 @@ def _set_gradient_checkpointing(self, module, value=False):
266266
if hasattr(module, "gradient_checkpointing"):
267267
module.gradient_checkpointing = value
268268

269+
# Notes: This is for SD3.5 8b controlnet, which shares the pos_embed with the transformer
270+
# we should have handled this in conversion script
271+
def _get_pos_embed_from_transformer(self, transformer):
272+
pos_embed = PatchEmbed(
273+
height=transformer.config.sample_size,
274+
width=transformer.config.sample_size,
275+
patch_size=transformer.config.patch_size,
276+
in_channels=transformer.config.in_channels,
277+
embed_dim=transformer.inner_dim,
278+
pos_embed_max_size=transformer.config.pos_embed_max_size,
279+
)
280+
pos_embed.load_state_dict(transformer.pos_embed.state_dict(), strict=True)
281+
return pos_embed
282+
269283
@classmethod
270284
def from_transformer(
271285
cls, transformer, num_layers=12, num_extra_conditioning_channels=1, load_weights_from_transformer=True

0 commit comments

Comments
 (0)