mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 17:24:32 +02:00
fix(lora): keep the loaded-network type contract under nunchaku
The nunchaku path replaced the loaded network list with the on-disk entries it composed from, so reading a loaded network back hit an object without the fields it expects: choosing the reported method reads len(net.modules) and raised on every set change, costing that generation its infotext and trigger tags. The adapter was already composed by then, so the image was unaffected. Wrap the composed set in Network objects and mutate the list in place.
This commit is contained in:
@@ -1,12 +1,19 @@
|
||||
import time
|
||||
from modules import shared, errors
|
||||
from modules.logger import log
|
||||
from modules.lora import lora_load, lora_common
|
||||
from modules.lora import lora_load, lora_common, network
|
||||
|
||||
|
||||
previously_loaded = [] # we maintain private state here
|
||||
|
||||
|
||||
def wrap_network(network_on_disk):
|
||||
net = network.Network(network_on_disk.name, network_on_disk)
|
||||
net.mentioned_name = network_on_disk.name
|
||||
network_on_disk.read_hash() # nothing else on this path fills the hash infotext reads
|
||||
return net
|
||||
|
||||
|
||||
def load_nunchaku(names, strengths):
|
||||
global previously_loaded # pylint: disable=global-statement
|
||||
strengths = [s[0] if isinstance(s, list) else s for s in strengths]
|
||||
@@ -26,7 +33,7 @@ def load_nunchaku(names, strengths):
|
||||
from nunchaku.lora.flux.compose import compose_lora
|
||||
composed_lora = compose_lora(loras)
|
||||
shared.sd_model.transformer.update_lora_params(composed_lora)
|
||||
lora_common.loaded_networks = [n[0] for n in networks] # used by infotext
|
||||
lora_common.loaded_networks[:] = [wrap_network(n[0]) for n in networks] # read by infotext and the trigger tags
|
||||
t1 = time.time()
|
||||
lora_common.timer.load = t1 - t0
|
||||
log.debug(f"Network load: type=LoRA method=nunchaku loras={names} strength={strengths} time={t1-t0:.3f}")
|
||||
|
||||
Reference in New Issue
Block a user