Global hypernetwork strentgth always = 1 with Hypernetwork-MonkeyPatch-Extension
Always used default value multiplier = 1.0
i'm tried add logs in to methods https://github.com/aria1th/Hypernetwork-MonkeyPatch-Extension/blob/4c87144b5dc67f00784cb35aa52fe30d96e49da0/patches/hypernetwork.py#L125 https://github.com/aria1th/Hypernetwork-MonkeyPatch-Extension/blob/4c87144b5dc67f00784cb35aa52fe30d96e49da0/patches/hypernetwork.py#L637
def forward(self, x, multiplier=None):
print(HypernetworkModule)
print(inspect.getmodule(HypernetworkModule))
print(f"multiplier = {multiplier}, HypernetworkModule.multiplier = {HypernetworkModule.multiplier}")
#traceback.print_stack()
if multiplier is None or not isinstance(multiplier, (int, float)):
return x + self.linear(x) * (HypernetworkModule.multiplier if not self.training else 1)
return x + self.linear(x) * multiplier
def apply_strength(value=None):
print(f'apply_strength(value={value}), shared.opts.sd_hypernetwork_strength: {shared.opts.sd_hypernetwork_strength}. Current: {HypernetworkModule.multiplier}')
print(inspect.getmodule(HypernetworkModule))
traceback.print_stack()
HypernetworkModule.multiplier = value if value is not None else shared.opts.sd_hypernetwork_strength
print(f'After: {HypernetworkModule.multiplier}')
And output when i'm set strength and then start generating image
apply_strength(value=None), shared.opts.sd_hypernetwork_strength: 0.556. Current: 0.75
<module 'extensions.Hypernetwork-MonkeyPatch-Extension.patches.hypernetwork' from '/content/gdrive/MyDrive/sd/stable-diffusion-webui/extensions/Hypernetwork-MonkeyPatch-Extension/patches/hypernetwork.py'>
File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/webui.py", line 213, in <module>
webui()
File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/webui.py", line 150, in webui
initialize()
File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/webui.py", line 85, in initialize
shared.opts.onchange("sd_hypernetwork_strength", modules.hypernetworks.hypernetwork.apply_strength)
File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/shared.py", line 554, in onchange
func()
File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/extensions/Hypernetwork-MonkeyPatch-Extension/patches/hypernetwork.py", line 645, in apply_strength
traceback.print_stack()
After: 0.556
Running on local URL: https://***.loca.lt:443
Connected
apply_strength(value=None), shared.opts.sd_hypernetwork_strength: 0.556. Current: 0.556
<module 'extensions.Hypernetwork-MonkeyPatch-Extension.patches.hypernetwork' from '/content/gdrive/MyDrive/sd/stable-diffusion-webui/extensions/Hypernetwork-MonkeyPatch-Extension/patches/hypernetwork.py'>
File "/usr/lib/python3.8/threading.py", line 890, in _bootstrap
self._bootstrap_inner()
File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.8/dist-packages/anyio/_backends/_asyncio.py", line 867, in run
result = context.run(func, *args)
File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/generation_parameters_copypaste.py", line 305, in paste_func
v = key(params)
File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/generation_parameters_copypaste.py", line 88, in <lambda>
(component_dict[k], lambda d, k=k, v=v: ui.apply_setting(k, d.get(v, None)))
File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/ui.py", line 419, in apply_setting
opts.data_labels[key].onchange()
File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/extensions/Hypernetwork-MonkeyPatch-Extension/patches/hypernetwork.py", line 645, in apply_strength
traceback.print_stack()
After: 0.556
0% 0/20 [00:00<?, ?it/s]
>>> forward called here <<<
<class 'patches.hypernetwork.HypernetworkModule'>
<module 'patches.hypernetwork' from '/content/gdrive/MyDrive/sd/stable-diffusion-webui/extensions/Hypernetwork-MonkeyPatch-Extension/patches/hypernetwork.py'>
multiplier = None, HypernetworkModule.multiplier = 0.75, self.training: False, cond: True mult: 0.75
<class 'patches.hypernetwork.HypernetworkModule'>
I'm change default value to 0.75 in .py file Actual value HypernetworkModule.multiplier = 0.556, but inside forward method it's return default value = 0.75
problem happening after import monkeypath-hypernetwork from this extension.
hypernetwork = importlib.import_module("extensions.Hypernetwork-MonkeyPatch-Extension.patches.hypernetwork")
adding the name check solved the problem, need to look for another fix
https://github.com/aria1th/Hypernetwork-MonkeyPatch-Extension/blob/4c87144b5dc67f00784cb35aa52fe30d96e49da0/patches/hypernetwork.py#L680

Any ideas?
updated: Shit, but works
try:
# backup
import modules
xy_grid = importlib.import_module("scripts.xy_grid")
hn = modules.hypernetworks.hypernetwork
hn_backup = [
hn.list_hypernetworks,
hn.load_hypernetwork,
hn.apply_hypernetwork,
hn.apply_strength,
hn.Hypernetwork,
hn.HypernetworkModule,
xy_grid.apply_hypernetwork_strength,
processing.create_infotext
]
hypernetwork = importlib.import_module("extensions.Hypernetwork-MonkeyPatch-Extension.patches.hypernetwork")
# restore
hn.list_hypernetworks = hn_backup[0]
hn.load_hypernetwork = hn_backup[1]
hn.apply_hypernetwork = hn_backup[2]
hn.apply_strength = hn_backup[3]
hn.Hypernetwork = hn_backup[4]
hn.HypernetworkModule = hn_backup[5]
xy_grid.apply_hypernetwork_strength = hn_backup[6]
processing.create_infotext = hn_backup[7]
print('Hypernetwork-MonkeyPatch-Extension found!')
monkeypatch_found = True
except ImportError:
from modules.hypernetworks import hypernetwork
print('Hypernetwork-MonkeyPatch-Extension not found')
monkeypatch_found = False