print(f'Lora layer {key_lora} matched a layer with unsupported type: {type(sd_module).__name__}')
continue
raiseAssertionError(f"Lora layer {key_lora} matched a layer with unsupported type: {type(sd_module).__name__}")
matched_networks[key].w[network_part]=weight
withtorch.no_grad():
module.weight.copy_(weight)
forkey,weightsinmatched_networks.items():
net_module=None
fornettypeinmodule_types:
net_module=nettype.create_module(net,weights)
ifnet_moduleisnotNone:
break
module.to(device=devices.cpu,dtype=devices.dtype)
ifnet_moduleisNone:
raiseAssertionError(f"Could not find a module type (out of {', '.join([x.__class__.__name__ for x in module_types])}) that would accept those keys: {', '.join(weights.w)}")
iflora_key=="lora_up.weight":
lora_module.up=module
eliflora_key=="lora_down.weight":
lora_module.down=module
else:
raiseAssertionError(f"Bad Lora layer name: {key_lora} - must end in lora_up.weight, lora_down.weight or alpha")
net.modules[key]=net_module
ifkeys_failed_to_match:
print(f"Failed to match keys when loading Lora {lora_on_disk.filename}: {keys_failed_to_match}")
print(f"Failed to match keys when loading network {network_on_disk.filename}: {keys_failed_to_match}")
"sd_lora":shared.OptionInfo("None","Add Lora to prompt",gr.Dropdown,lambda:{"choices":["None",*lora.available_loras]},refresh=lora.list_available_loras),
"sd_lora":shared.OptionInfo("None","Add network to prompt",gr.Dropdown,lambda:{"choices":["None",*networks.available_networks]},refresh=networks.list_available_networks),
"lora_preferred_name":shared.OptionInfo("Alias from file","When adding to prompt, refer to Lora by",gr.Radio,{"choices":["Alias from file","Filename"]}),
"lora_add_hashes_to_infotext":shared.OptionInfo(True,"Add Lora hashes to infotext"),
"lora_functional":shared.OptionInfo(False,"Lora: use old method that takes longer when you have multiple Loras active and produces same results as kohya-ss/sd-webui-additional-networks extension"),
"lora_functional":shared.OptionInfo(False,"Lora/Networks: use old method that takes longer when you have multiple Loras active and produces same results as kohya-ss/sd-webui-additional-networks extension"),