Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
from diffusers.training_utils import cast_training_params, resolve_interpolation_mode
from diffusers.utils import (
check_min_version,
convert_state_dict_to_diffusers,
convert_unet_state_dict_to_peft,
is_wandb_available,
)
Expand Down Expand Up @@ -121,7 +120,7 @@ def log_validation(vae, args, accelerator, weight_dtype, step, unet=None, is_fin
if unet is None:
raise ValueError("Must provide a `unet` when doing intermediate validation.")
unet = accelerator.unwrap_model(unet)
state_dict = convert_state_dict_to_diffusers(get_peft_model_state_dict(unet))
state_dict = get_peft_model_state_dict(unet)
to_load = state_dict
else:
to_load = args.output_dir
Expand Down Expand Up @@ -888,9 +887,7 @@ def main(args):
def save_model_hook(models, weights, output_dir):
if accelerator.is_main_process:
unet_ = accelerator.unwrap_model(unet)
# also save the checkpoints in native `diffusers` format so that it can be easily
# be independently loaded via `load_lora_weights()`.
state_dict = convert_state_dict_to_diffusers(get_peft_model_state_dict(unet_))
state_dict = get_peft_model_state_dict(unet_)
StableDiffusionXLPipeline.save_lora_weights(output_dir, unet_lora_layers=state_dict)

for _, model in enumerate(models):
Expand Down Expand Up @@ -1442,7 +1439,7 @@ def compute_time_ids(original_size, crops_coords_top_left):
accelerator.wait_for_everyone()
if accelerator.is_main_process:
unet = accelerator.unwrap_model(unet)
unet_lora_state_dict = convert_state_dict_to_diffusers(get_peft_model_state_dict(unet))
unet_lora_state_dict = get_peft_model_state_dict(unet)
StableDiffusionXLPipeline.save_lora_weights(args.output_dir, unet_lora_layers=unet_lora_state_dict)

if args.push_to_hub:
Expand Down
Loading