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

Block weight multiplier is ignored

Closed this issue · 6 comments

lora:whatever:1:1:lbw=ALL gives you the same result as lora:whatever:-10:-10:lbw=ALL, because the multipliers variable is ignored in the load_loras_blocks function. It should give you the lora weighted at -10,-10,-10,...,-10,-10.

I get the expected result if I add these two lines to the beginning of the load_loras_blocks function:

    for i in range(len(multipliers)):
        lwei[i] = [j * multipliers[i] for j in lwei[i]]

Use these two lines code will bring an IndexError.
*** Error running after_extra_networks_activate: E:\AI\webui\extensions\sd-webui-lora-block-weight\scripts\lora_block_weight.py
Traceback (most recent call last):
File "E:\AI\webui\modules\scripts.py", line 639, in after_extra_networks_activate
script.after_extra_networks_activate(p, *script_args, **kwargs)
File "E:\AI\webui\extensions\sd-webui-lora-block-weight\scripts\lora_block_weight.py", line 344, in after_extra_networks_activate
loradealer(self, kwargs["prompts"] ,self.lratios,self.elementals,kwargs["extra_network_data"])
File "E:\AI\webui\extensions\sd-webui-lora-block-weight\scripts\lora_block_weight.py", line 659, in loradealer
if len(lorars) > 0: load_loras_blocks(self, lorans,lorars,multipliers,elements,ltype)
File "E:\AI\webui\extensions\sd-webui-lora-block-weight\scripts\lora_block_weight.py", line 689, in load_loras_blocks
lwei[i] = [j * multipliers[i] for j in lwei[i]]
IndexError: list index out of range

Well, I don't know if there is any difference, but it is an error.

Use these two lines code will bring an IndexError. *** Error running after_extra_networks_activate: E:\AI\webui\extensions\sd-webui-lora-block-weight\scripts\lora_block_weight.py Traceback (most recent call last): File "E:\AI\webui\modules\scripts.py", line 639, in after_extra_networks_activate script.after_extra_networks_activate(p, *script_args, **kwargs) File "E:\AI\webui\extensions\sd-webui-lora-block-weight\scripts\lora_block_weight.py", line 344, in after_extra_networks_activate loradealer(self, kwargs["prompts"] ,self.lratios,self.elementals,kwargs["extra_network_data"]) File "E:\AI\webui\extensions\sd-webui-lora-block-weight\scripts\lora_block_weight.py", line 659, in loradealer if len(lorars) > 0: load_loras_blocks(self, lorans,lorars,multipliers,elements,ltype) File "E:\AI\webui\extensions\sd-webui-lora-block-weight\scripts\lora_block_weight.py", line 689, in load_loras_blocks lwei[i] = [j * multipliers[i] for j in lwei[i]] IndexError: list index out of range

Parameter:
(masterpiece,best quality:1.2),
1girl, Hishi Miracle (umamusume), white hair, short hair,
(horse ears, horse tail), smile,
looking at viewer, arms at sides,
ear covers, blue shirt, collared shirt, blue coat, open coat, white ascot, brooch, jewelry, white gloves, long sleeves, belt, black pants, thigh strap, tailcoat,
(rain, city:1.4), cowboy shot,
lora:UmaMusume_AIO:0.75:0.6:lbw=LC-NP lora:neg4all_bdsqlsz_V3.5:1.0 lora:add_detail:1.0 lora:vectorer:-1.0
Negative prompt: (worst quality, low quality:1.4),
(depth of field, bokeh, blurry:1.4),
(lip, nose, tooth, rouge, lipstick, eyeshadow:1.4),
(realistic, muscular, abs:1.1),
(bad art, bad anatomy:1.4),
blurred, text, watermark,
Steps: 25, Sampler: Restart, CFG scale: 7, Seed: 3964176970, Size: 512x768, Model hash: 4b7a7a90a3, Model: TestSMGH, VAE hash: d5c0f70662, VAE: anythingKlF8Anime2VaeFtMse840000_anything.safetensors, Denoising strength: 0.4, Token merging ratio: 0.4, Token merging ratio hr: 0.4, NGMS: 0.5, ADetailer model: hand_yolov8s.pt, ADetailer prompt: "(masterpiece, best quality, nice hands, perfect hands),", ADetailer negative prompt: "(worst quality, low quality:1.4), ", ADetailer confidence: 0.5, ADetailer dilate erode: 4, ADetailer mask blur: 4, ADetailer denoising strength: 0.45, ADetailer inpaint only masked: True, ADetailer inpaint padding: 32, ADetailer version: 23.11.0, Hires upscale: 1.5, Hires upscaler: 2x-sudo-RealESRGAN, Lora hashes: "UmaMusume_AIO: 3766e98e697e, neg4all_bdsqlsz_V3.5: b1b5db66e2f6, add_detail: 7c6bad76eb54, vectorer: ab6273356e44", NegPiP Active: True, Discard penultimate sigma: True, Version: 1.1.1-2053-gc8660a90

Use these two lines code will bring an IndexError. *** Error running after_extra_networks_activate: E:\AI\webui\extensions\sd-webui-lora-block-weight\scripts\lora_block_weight.py Traceback (most recent call last): File "E:\AI\webui\modules\scripts.py", line 639, in after_extra_networks_activate script.after_extra_networks_activate(p, *script_args, **kwargs) File "E:\AI\webui\extensions\sd-webui-lora-block-weight\scripts\lora_block_weight.py", line 344, in after_extra_networks_activate loradealer(self, kwargs["prompts"] ,self.lratios,self.elementals,kwargs["extra_network_data"]) File "E:\AI\webui\extensions\sd-webui-lora-block-weight\scripts\lora_block_weight.py", line 659, in loradealer if len(lorars) > 0: load_loras_blocks(self, lorans,lorars,multipliers,elements,ltype) File "E:\AI\webui\extensions\sd-webui-lora-block-weight\scripts\lora_block_weight.py", line 689, in load_loras_blocks lwei[i] = [j * multipliers[i] for j in lwei[i]] IndexError: list index out of range

Parameter: (masterpiece,best quality:1.2), 1girl, Hishi Miracle (umamusume), white hair, short hair, (horse ears, horse tail), smile, looking at viewer, arms at sides, ear covers, blue shirt, collared shirt, blue coat, open coat, white ascot, brooch, jewelry, white gloves, long sleeves, belt, black pants, thigh strap, tailcoat, (rain, city:1.4), cowboy shot, lora:UmaMusume_AIO:0.75:0.6:lbw=LC-NP lora:neg4all_bdsqlsz_V3.5:1.0 lora:add_detail:1.0 lora:vectorer:-1.0 Negative prompt: (worst quality, low quality:1.4), (depth of field, bokeh, blurry:1.4), (lip, nose, tooth, rouge, lipstick, eyeshadow:1.4), (realistic, muscular, abs:1.1), (bad art, bad anatomy:1.4), blurred, text, watermark, Steps: 25, Sampler: Restart, CFG scale: 7, Seed: 3964176970, Size: 512x768, Model hash: 4b7a7a90a3, Model: TestSMGH, VAE hash: d5c0f70662, VAE: anythingKlF8Anime2VaeFtMse840000_anything.safetensors, Denoising strength: 0.4, Token merging ratio: 0.4, Token merging ratio hr: 0.4, NGMS: 0.5, ADetailer model: hand_yolov8s.pt, ADetailer prompt: "(masterpiece, best quality, nice hands, perfect hands),", ADetailer negative prompt: "(worst quality, low quality:1.4), ", ADetailer confidence: 0.5, ADetailer dilate erode: 4, ADetailer mask blur: 4, ADetailer denoising strength: 0.45, ADetailer inpaint only masked: True, ADetailer inpaint padding: 32, ADetailer version: 23.11.0, Hires upscale: 1.5, Hires upscaler: 2x-sudo-RealESRGAN, Lora hashes: "UmaMusume_AIO: 3766e98e697e, neg4all_bdsqlsz_V3.5: b1b5db66e2f6, add_detail: 7c6bad76eb54, vectorer: ab6273356e44", NegPiP Active: True, Discard penultimate sigma: True, Version: 1.1.1-2053-gc8660a90

OK, Problem is I use multiple loras, and only 1 using LBW, lwei's length I think ALWAYS greater than or equal to multipliers' len, so out.
According to #126 , actually these two lines of code don't completely solve the problem, I think.
multiplier is only for unet value, not for te or text encoder.

If you are using with LoRa Control - Dynamic Weights Controller, fixed.

If you are using with LoRa Control - Dynamic Weights Controller, fixed.

*** Error running after_extra_networks_activate: E:\AI\webui\extensions\sd-webui-lora-block-weight\scripts\lora_block_weight.py
Traceback (most recent call last):
File "E:\AI\webui\modules\scripts.py", line 639, in after_extra_networks_activate
script.after_extra_networks_activate(p, *script_args, **kwargs)
File "E:\AI\webui\extensions\sd-webui-lora-block-weight\scripts\lora_block_weight.py", line 371, in after_extra_networks_activate
loradealer(self, kwargs["prompts"] ,self.lratios,self.elementals,kwargs["extra_network_data"])
File "E:\AI\webui\extensions\sd-webui-lora-block-weight\scripts\lora_block_weight.py", line 659, in loradealer
weights = syntaxdealer(called.items,"lbw=",2)
File "E:\AI\webui\extensions\sd-webui-lora-block-weight\scripts\lora_block_weight.py", line 707, in syntaxdealer
if "=" in items[index]:return None
IndexError: list index out of range

Prompt:
masterpiece, best quality, nice hands, perfect hands,
1girl, (Admire Vega(umamusume):1.1), brown hair, pink eyes, low ponytail,
horse ears, horse tail,
hair ribbon, white ribbon, cable knit, long sleeves, aran sweater, (blue sweater), panties, pantyshot,
sitting, looking at viewer, on bed, night, indoors,
lora:UmaMusume_AIO:te=0.7:unet=0.6:lbw=OUTD lora:add_detail:1.0 lora:vectorer:1.0 lora:GoodHands-beta2:1

Fixed.