Skip to content

Commit 16677da

Browse files
committed
fix create_network_from_weights doesn't work
1 parent a384bf2 commit 16677da

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

networks/lora.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,9 @@ def get_block_index(lora_name: str, is_sdxl: bool = False) -> int:
757757

758758
# Create network from weights for inference, weights are not loaded here (because can be merged)
759759
def create_network_from_weights(multiplier, file, vae, text_encoder, unet, weights_sd=None, for_inference=False, **kwargs):
760+
# if unet is an instance of SdxlUNet2DConditionModel or subclass, set is_sdxl to True
761+
is_sdxl = unet is not None and issubclass(unet.__class__, SdxlUNet2DConditionModel)
762+
760763
if weights_sd is None:
761764
if os.path.splitext(file)[1] == ".safetensors":
762765
from safetensors.torch import load_file, safe_open
@@ -792,7 +795,7 @@ def create_network_from_weights(multiplier, file, vae, text_encoder, unet, weigh
792795
)
793796

794797
# block lr
795-
block_lr_weight = parse_block_lr_kwargs(kwargs)
798+
block_lr_weight = parse_block_lr_kwargs(is_sdxl, kwargs)
796799
if block_lr_weight is not None:
797800
network.set_block_lr_weight(block_lr_weight)
798801

0 commit comments

Comments
 (0)