mirror of
https://github.com/huggingface/diffusers.git
synced 2026-01-29 07:22:12 +03:00
Fix: unet save_attn_procs at UNet2DconditionLoadersMixin (#8699)
* fix: unet save_attn_procs at custom diffusion * style: recover unchanaged parts(max line length 119) / mod: add condition * style: recover unchanaged parts(max line length 119) --------- Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
This commit is contained in:
@@ -457,6 +457,15 @@ class UNet2DConditionLoadersMixin:
|
||||
)
|
||||
if is_custom_diffusion:
|
||||
state_dict = self._get_custom_diffusion_state_dict()
|
||||
if save_function is None and safe_serialization:
|
||||
# safetensors does not support saving dicts with non-tensor values
|
||||
empty_state_dict = {k: v for k, v in state_dict.items() if not isinstance(v, torch.Tensor)}
|
||||
if len(empty_state_dict) > 0:
|
||||
logger.warning(
|
||||
f"Safetensors does not support saving dicts with non-tensor values. "
|
||||
f"The following keys will be ignored: {empty_state_dict.keys()}"
|
||||
)
|
||||
state_dict = {k: v for k, v in state_dict.items() if isinstance(v, torch.Tensor)}
|
||||
else:
|
||||
if not USE_PEFT_BACKEND:
|
||||
raise ValueError("PEFT backend is required for saving LoRAs using the `save_attn_procs()` method.")
|
||||
|
||||
Reference in New Issue
Block a user