hako-mikan / sd-webui-lora-block-weight

1.12k stars 100 forks source link

XYZ plot does not work on webui1.5.1 #94

Closed rainn00o closed 1 year ago

rainn00o commented 1 year ago

I write this prompt, , delete all extensions, but xyz plot still doesn't work, and have no error report.

hako-mikan commented 1 year ago

Are you using with API option?

rainn00o commented 1 year ago

I used the lbw in auto1111's webui 1.5.1. I didn’t use the api option.

hisonWarren commented 1 year ago

same problem here

RexLeeGrey commented 1 year ago

same problem

MemeLord3 commented 1 year ago

This issue appears to be caused by https://github.com/hako-mikan/sd-webui-lora-block-weight/issues/96#issue-1841031944 The plugin is reading settings from the second copy of the UI (If you can't see it, you can select it from the scripts dropdown). If you select "LoRA Block Weight" from the scripts dropdown and configure that version of the UI, XYZ appears to work.

RexLeeGrey commented 1 year ago

activating extra network lora with arguments [<modules.extra_networks.ExtraNetworkParams object at 0x000001CD4DF6B010>]: ValueError Traceback (most recent call last): File "D:\AIGC\sd-webui-aki-v4.2\modules\extra_networks.py", line 104, in activate extra_network.activate(p, extra_network_args) File "D:\AIGC\sd-webui-aki-v4.2\extensions-builtin\Lora\extra_networks_lora.py", line 28, in activate unet_multiplier = float(params.positional[2]) if len(params.positional) > 2 else te_multiplier ValueError: could not convert string to float: 'XYZ'

MemeLord3 commented 1 year ago

activating extra network lora with arguments [<modules.extra_networks.ExtraNetworkParams object at 0x000001CD4DF6B010>]: ValueError Traceback (most recent call last): File "D:\AIGC\sd-webui-aki-v4.2\modules\extra_networks.py", line 104, in activate extra_network.activate(p, extra_network_args) File "D:\AIGC\sd-webui-aki-v4.2\extensions-builtin\Lora\extra_networks_lora.py", line 28, in activate unet_multiplier = float(params.positional[2]) if len(params.positional) > 2 else te_multiplier ValueError: could not convert string to float: 'XYZ'

use the format <lora:yourlora:1:lbw=XYZ> webui now treats the first 2 parameters as unet weight and te weight so you need to use the named syntax (the 'lbw=' prefix)

There are also 2 copies of the plugins UI being displayed at the moment and it ignores whatever you set in the first copy of the ui.

RexLeeGrey commented 1 year ago

:lbw=

Thank you, now it works!

hako-mikan commented 1 year ago

I couldn't find the cause. I added debug mode. Generate XYZ with the conditions you want to use with debug is checked. Tell me the results you see at the command prompt.

MemeLord3 commented 1 year ago

In txt2img.py, if you print out 'args', you'll see that all the settings for the "LoRA Block Weight" UI are in there twice. Once for the UI in the top section and again for the UI in the scripts section.

The lora_block_weight.py Script object methods are gertting called with the second copy of the arguments (the args generated from the UI in the scripts section)

There is no issue with XYZ other than the UI being broken and changing 'Disable' to 'XYZ plot' in the first "LoRA Block Weight" section has no effect due to the second "LoRA Block Weight" section overriding the args.

LoonLi commented 1 year ago

I met the same problem. Lora block weight worked after adding "lbw=", but it didn't work for XYZ plot, both script and LBW build-in.

There are no error message, and the generated images all shared the same blocked weight. Here is an example I generated with sd-webui 1.6.0: https://1drv.ms/i/s!Am69M-1d1c6fg6xhJIWFDe_ZXjNnTw?e=imTA7w

And this one is generated with sd-webui 1.4.0: https://1drv.ms/i/s!Am69M-1d1c6fg6xg9T9gN4WS8bvkcw?e=RGP27g

In this case, the XYZ plot started from "ALL", so it generated three identical images with all blocked weights equal to 1. If start XYZ plot from "NONE", it will generate three images with blocked weights equal to 0.

In txt2img.py, if you print out 'args', you'll see that all the settings for the "LoRA Block Weight" UI are in there twice. Once for the UI in the top section and again for the UI in the scripts section.

The lora_block_weight.py Script object methods are gertting called with the second copy of the arguments (the args generated from the UI in the scripts section)

There is no issue with XYZ other than the UI being broken and changing 'Disable' to 'XYZ plot' in the first "LoRA Block Weight" section has no effect due to the second "LoRA Block Weight" section overriding the args.

I checked the "args" variable in txt2img.py, but I didn't find there are duplicated "LoRA Block Weight".

Without this XYZ plot problem, I feel like the version 1.6.0 is more friendly for me. Hope this issue can be solved.

weimo1997 commented 1 year ago

呜呜呜,有解决方法吗我也用不了

hako-mikan commented 1 year ago

Tell me result with debug checked.

LoonLi commented 1 year ago

Thank you for your reply. I will give you the terminal output.

Here is the example that used XYZ plot with prompt S/R to plot lbw equals MIDD, ALL, and NONE:

LoRA Block weight (lora): agnes_digital_r4_lora: 1.0 x [1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0]
nets
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  7.33it/s]
{'isnet': True, 'isxl': False, 'islora': True, 'enable LBW': True, 'registerd': False}                                                                                  | 20/60 [00:02<00:04,  8.17it/s]
LoRA Block weight (lora): agnes_digital_r4_lora: 1.0 x [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
nets
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  8.15it/s]
{'isnet': True, 'isxl': False, 'islora': True, 'enable LBW': True, 'registerd': False}█████████████████████████████████                                                 | 40/60 [00:05<00:02,  8.14it/s]
LoRA Block weight (lora): agnes_digital_r4_lora: 1.0 x [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
nets
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  8.16it/s]
{'isnet': True, 'isxl': False, 'islora': True, 'enable LBW': True, 'registerd': False}██████████████████████████████████████████████████████████████████████████████████| 60/60 [00:08<00:00,  8.15it/s]
Total progress: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 60/60 [00:09<00:00,  6.44it/s]
Total progress: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 60/60 [00:09<00:00,  8.15it/s]

All generated results were blocked by MIDD.

LoonLi commented 1 year ago

I SOLVE IT!

I have some progress. I think the method network_apply_weights in extensions-builtin/Lora/networks.py may be responsible for this issue. It saved the model weights so that images generated in the same batch share the same lora weights.

I managed to force webui reload model weights for each image but it seems that this reloading is not complete. I add following code in extensions/sd-webui-lora-block-weight/scripts/lora_block_weight.py:

def lbw(lora,lwei,elemental):
    elemental = elemental.split(",")
    for name, layer in shared.sd_model.named_modules():
        if not getattr(layer, "network_current_names", None) is None:
            setattr(layer, "network_current_names", ())
    for key in lora.modules.keys():
    # ...

With these codes, the images generated by XYZ plot changed, but the result for lbw=NONE still remain some features from the lora. OK, it just worked. I think these codes can just solve this issue.

hako-mikan commented 1 year ago

XYZplot cannot be used concurrently with the XYZ plot in the web-ui. If other scripts are active in the script section, the XYZ plot of the LoRA Block Weight will be disabled.