mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 01:04:32 +02:00
update lora logic
This commit is contained in:
@@ -25,8 +25,6 @@ Stuff to be added...
|
||||
|
||||
Stuff to be investigated...
|
||||
|
||||
- Best practices for **Apple M1**
|
||||
- Best practices for **AMD GPUs**
|
||||
- Torch Compile
|
||||
- `Torch-DirectML`
|
||||
- `TensorRT`
|
||||
@@ -64,6 +62,7 @@ Tech that can be integrated as part of the core workflow...
|
||||
should fix most issues with NaN or black images
|
||||
- add built-in Gradio themes
|
||||
- fix setup race conditions
|
||||
- fix requirements
|
||||
- reduce requirements
|
||||
- more AMD specific work
|
||||
- initial work on Apple platform support
|
||||
- additional PR merges
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import glob
|
||||
import os
|
||||
import re
|
||||
import torch
|
||||
from typing import Union
|
||||
import torch
|
||||
|
||||
from modules import shared, devices, sd_models, errors
|
||||
|
||||
@@ -139,9 +139,7 @@ def load_lora(name, filename):
|
||||
lora_key_parts = key_diffusers.split(".", 1)
|
||||
key_diffusers_without_lora_parts = lora_key_parts[0]
|
||||
lora_key = lora_key_parts[1] if len(lora_key_parts) > 1 else ""
|
||||
|
||||
key = convert_diffusers_name_to_compvis(key_diffusers_without_lora_parts, is_sd2)
|
||||
|
||||
sd_module = shared.sd_model.lora_layer_mapping.get(key, None)
|
||||
|
||||
if sd_module is None:
|
||||
@@ -173,7 +171,6 @@ def load_lora(name, filename):
|
||||
else:
|
||||
print(f'Lora layer {key_diffusers} matched a layer with unsupported type: {type(sd_module).__name__}')
|
||||
continue
|
||||
assert False, f'Lora layer {key_diffusers} matched a layer with unsupported type: {type(sd_module).__name__}'
|
||||
|
||||
with torch.no_grad():
|
||||
module.weight.copy_(weight)
|
||||
@@ -321,10 +318,10 @@ def lora_reset_cached_weight(self: Union[torch.nn.Conv2d, torch.nn.Linear]):
|
||||
setattr(self, "lora_weights_backup", None)
|
||||
|
||||
|
||||
def lora_Linear_forward(self, input):
|
||||
def lora_Linear_forward(self, lora_input):
|
||||
lora_apply_weights(self)
|
||||
|
||||
return torch.nn.Linear_forward_before_lora(self, input)
|
||||
return torch.nn.Linear_forward_before_lora(self, lora_input)
|
||||
|
||||
|
||||
def lora_Linear_load_state_dict(self, *args, **kwargs):
|
||||
@@ -333,10 +330,10 @@ def lora_Linear_load_state_dict(self, *args, **kwargs):
|
||||
return torch.nn.Linear_load_state_dict_before_lora(self, *args, **kwargs)
|
||||
|
||||
|
||||
def lora_Conv2d_forward(self, input):
|
||||
def lora_Conv2d_forward(self, lora_input):
|
||||
lora_apply_weights(self)
|
||||
|
||||
return torch.nn.Conv2d_forward_before_lora(self, input)
|
||||
return torch.nn.Conv2d_forward_before_lora(self, lora_input)
|
||||
|
||||
|
||||
def lora_Conv2d_load_state_dict(self, *args, **kwargs):
|
||||
|
||||
Submodule extensions-builtin/sd-webui-controlnet updated: a8f45816e3...5eadd24830
Reference in New Issue
Block a user