mirror of
https://github.com/kohya-ss/sd-scripts.git
synced 2026-04-09 06:45:09 +00:00
fix create_network_from_weights doesn't work
This commit is contained in:
@@ -757,6 +757,9 @@ def get_block_index(lora_name: str, is_sdxl: bool = False) -> int:
|
|||||||
|
|
||||||
# Create network from weights for inference, weights are not loaded here (because can be merged)
|
# Create network from weights for inference, weights are not loaded here (because can be merged)
|
||||||
def create_network_from_weights(multiplier, file, vae, text_encoder, unet, weights_sd=None, for_inference=False, **kwargs):
|
def create_network_from_weights(multiplier, file, vae, text_encoder, unet, weights_sd=None, for_inference=False, **kwargs):
|
||||||
|
# if unet is an instance of SdxlUNet2DConditionModel or subclass, set is_sdxl to True
|
||||||
|
is_sdxl = unet is not None and issubclass(unet.__class__, SdxlUNet2DConditionModel)
|
||||||
|
|
||||||
if weights_sd is None:
|
if weights_sd is None:
|
||||||
if os.path.splitext(file)[1] == ".safetensors":
|
if os.path.splitext(file)[1] == ".safetensors":
|
||||||
from safetensors.torch import load_file, safe_open
|
from safetensors.torch import load_file, safe_open
|
||||||
@@ -792,7 +795,7 @@ def create_network_from_weights(multiplier, file, vae, text_encoder, unet, weigh
|
|||||||
)
|
)
|
||||||
|
|
||||||
# block lr
|
# block lr
|
||||||
block_lr_weight = parse_block_lr_kwargs(kwargs)
|
block_lr_weight = parse_block_lr_kwargs(is_sdxl, kwargs)
|
||||||
if block_lr_weight is not None:
|
if block_lr_weight is not None:
|
||||||
network.set_block_lr_weight(block_lr_weight)
|
network.set_block_lr_weight(block_lr_weight)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user