2023-05-10 13:25:25 +08:00
|
|
|
from modules import extra_networks, shared
|
2023-01-21 13:36:07 +08:00
|
|
|
from modules.hypernetworks import hypernetwork
|
|
|
|
|
|
|
|
|
|
|
|
class ExtraNetworkHypernet(extra_networks.ExtraNetwork):
|
|
|
|
def __init__(self):
|
|
|
|
super().__init__('hypernet')
|
|
|
|
|
|
|
|
def activate(self, p, params_list):
|
2023-01-28 22:18:47 +08:00
|
|
|
additional = shared.opts.sd_hypernetwork
|
|
|
|
|
2023-06-02 19:58:10 +08:00
|
|
|
if additional != "None" and additional in shared.hypernetworks and not any(x for x in params_list if x.items[0] == additional):
|
2023-05-10 03:17:58 +08:00
|
|
|
hypernet_prompt_text = f"<hypernet:{additional}:{shared.opts.extra_networks_default_multiplier}>"
|
|
|
|
p.all_prompts = [f"{prompt}{hypernet_prompt_text}" for prompt in p.all_prompts]
|
2023-01-28 22:18:47 +08:00
|
|
|
params_list.append(extra_networks.ExtraNetworkParams(items=[additional, shared.opts.extra_networks_default_multiplier]))
|
|
|
|
|
2023-01-21 13:36:07 +08:00
|
|
|
names = []
|
|
|
|
multipliers = []
|
|
|
|
for params in params_list:
|
2023-06-02 19:58:10 +08:00
|
|
|
assert params.items
|
2023-01-21 13:36:07 +08:00
|
|
|
|
|
|
|
names.append(params.items[0])
|
|
|
|
multipliers.append(float(params.items[1]) if len(params.items) > 1 else 1.0)
|
|
|
|
|
|
|
|
hypernetwork.load_hypernetworks(names, multipliers)
|
|
|
|
|
2023-01-21 21:15:53 +08:00
|
|
|
def deactivate(self, p):
|
2023-01-21 13:36:07 +08:00
|
|
|
pass
|