Skip to content

Commit

Permalink
Merge pull request #16062 from AUTOMATIC1111/fix-infotext-Lora-hashes…
Browse files Browse the repository at this point in the history
…-fro-hires-fix-different-lora

fix infotext Lora hashes fro hires fix different lora
  • Loading branch information
AUTOMATIC1111 committed Jul 6, 2024
2 parents 68df281 + 109bbda commit 3bd4a08
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions extensions-builtin/Lora/extra_networks_lora.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ def __init__(self):
self.errors = {}
"""mapping of network names to the number of errors the network had during operation"""

remove_symbols = str.maketrans('', '', ":,")

def activate(self, p, params_list):
additional = shared.opts.sd_lora

Expand Down Expand Up @@ -43,22 +45,15 @@ def activate(self, p, params_list):
networks.load_networks(names, te_multipliers, unet_multipliers, dyn_dims)

if shared.opts.lora_add_hashes_to_infotext:
network_hashes = []
for item in networks.loaded_networks:
shorthash = item.network_on_disk.shorthash
if not shorthash:
continue

alias = item.mentioned_name
if not alias:
continue
if not getattr(p, "is_hr_pass", False) or not hasattr(p, "lora_hashes"):
p.lora_hashes = {}

alias = alias.replace(":", "").replace(",", "")

network_hashes.append(f"{alias}: {shorthash}")
for item in networks.loaded_networks:
if item.network_on_disk.shorthash and item.mentioned_name:
p.lora_hashes[item.mentioned_name.translate(self.remove_symbols)] = item.network_on_disk.shorthash

if network_hashes:
p.extra_generation_params["Lora hashes"] = ", ".join(network_hashes)
if p.lora_hashes:
p.extra_generation_params["Lora hashes"] = ', '.join(f'{k}: {v}' for k, v in p.lora_hashes.items())

def deactivate(self, p):
if self.errors:
Expand Down

0 comments on commit 3bd4a08

Please sign in to comment.