KohakuBlueleaf / a1111-sd-webui-locon

A extension for loading LyCORIS model in sd-webui
Apache License 2.0
499 stars 109 forks source link

[CRITICAL]All LoRAs not working anymore #40

Open kuyin opened 1 year ago

kuyin commented 1 year ago

locon load lora method loading Lora I:\GitHub\stable-diffusion-webui\models\Lora\Vehicle.safetensors: AttributeError Traceback (most recent call last): File "I:\GitHub\stable-diffusion-webui\extensions\a1111-sd-webui-locon\scripts......\extensions-builtin/Lora\lora.py", line 222, in load_loras lora = load_lora(name, lora_on_disk.filename) File "I:\GitHub\stable-diffusion-webui\extensions\a1111-sd-webui-locon\scripts\main.py", line 371, in load_lora lora.mtime = os.path.getmtime(lora_on_disk.filename) AttributeError: 'str' object has no attribute 'filename'

All the LoRAs not working anymore. Maybe caused by the latest commit.

BigZampano commented 1 year ago

Same error here...!! Did an extensions update and was wondering why nothing looked like before... Help please...

sif commented 1 year ago

Pretty sure the latest commit broke it. Confirming the same experience.

BigZampano commented 1 year ago

I was able to revert back to the last commit and everything is working again...! I did "git log" in the extension folder and then did "git checkout 04b768bad41e0f1122a86d0636fce47bb2765af8", which is the last version before it broke... as a non-coder I feel like a real hacker now... :)

04b768bad41e0f1122a86d0636fce47bb2765af8

Rexveal commented 1 year ago

Disable both locon and lycoris extension and loras are working, only tested with 5-6 loras though so not sure if all of them will work.

I thought it worked, but it becomes inconsistent in results.

olemisterharris commented 1 year ago

I was able to revert back to the last commit and everything is working again...! I did "git log" in the extension folder and then did "git checkout 04b768b", which is the last version before it broke... as a non-coder I feel like a real hacker now... :)

04b768bad41e0f1122a86d0636fce47bb2765af8

Confirmed this works, will keep an eye out for a new update. Thanks for the (temporary) solution!

acncagua commented 1 year ago

Even the 1111 release candidate (v1.3.0-RC) that just came out doesn't work with an error. If you want to use LoRA/LoCon only, disable this extension and reboot, LoRA/LoCon will work using the main body function of 1111

tranthai2k2 commented 1 year ago

@BigZampano colab has a similar situation, what to do

BigZampano commented 1 year ago

@BigZampano colab has a similar situation, what to do

I have no idea, sorry... maybe just disable this extension and rely on the built in LoRA until a fixed version comes... won't be long I suppose...

stablediffusionAI commented 1 year ago

Guys, I use colab and disable Lycoris and a1111-sd-webui-locon extensions in extensions tab worked for me. Let's see what comes from now on...

GoldenMiocola commented 1 year ago

NR C 9VM(G 6B% $)V}EKOB Got same problem, 😭 dont understand whats wrong

jyuan15 commented 1 year ago

I did a "git checkout 04b768b" and it doesn't seem to revert to the last commit, what should I do? Thanks. 2023-05-22_090750

Kadah commented 1 year ago

There's a breaking change coming in A1111 1.3.0, you'll need to switch back to main after updating A1111.

dajusha commented 1 year ago

if you dont know about git cmd, just see these change on file: https://github.com/KohakuBlueleaf/a1111-sd-webui-locon/commit/52a78b5b1c6397441ab7e7a1b1f8382a1aa1766e edit back file by any text editor.

acncagua commented 1 year ago
  1. updated to A1111 v1.3.0-RC
  2. remove a1111-sd-webui-locon extension
  3. restart A1111
  4. Install a1111-sd-webui-locon extension from URL (658c4f772c71e0da1e31d0a6d2950a17bf257f7f)
  5. Restart A1111
  6. Select LoRA from ExtraNetwork
  7. Error occurs Traceback (most recent call last):

    File "/home/acncagua/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/routes.py", line 414, in run_predict output = await app.get_blocks().process_api( File "/home/acncagua/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/blocks.py", line 1323, in process_api result = await self.call_function( File "/home/acncagua/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/blocks.py", line 1051, in call_function prediction = await anyio.to_thread.run_sync( File "/home/acncagua/stable-diffusion-webui/venv/lib/python3.10/site-packages/anyio/to_thread.py", line 31, in run_sync return await get_asynclib().run_sync_in_worker_thread( File "/home/acncagua/stable-diffusion-webui/venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread return await future File "/home/acncagua/stable-diffusion-webui/venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 867, in run result = context.run(func, *args) File "/home/acncagua/stable-diffusion-webui/modules/ui_extra_networks.py", line 313, in fill_tabs refresh() File "/home/acncagua/stable-diffusion-webui/modules/ui_extra_networks.py", line 330, in refresh ui.pages_contents = [pg.create_html(ui.tabname) for pg in ui.stored_extra_pages] File "/home/acncagua/stable-diffusion-webui/modules/ui_extra_networks.py", line 330, in ui.pages_contents = [pg.create_html(ui.tabname) for pg in ui.stored_extra_pages] File "/home/acncagua/stable-diffusion-webui/modules/ui_extra_networks.py", line 121, in create_html for item in self.list_items(): File "/home/acncagua/stable-diffusion-webui/extensions-builtin/Lora/ui_extra_networks_lora.py", line 19, in list_items alias = lora_on_disk.get_alias() AttributeError: 'LoraOnDisk' object has no attribute 'get_alias'

jyuan15 commented 1 year ago

I rolled back to the last commit with 'git reset --hard 04b768b' and lora was back to work.

Ineman commented 1 year ago

line 371: lora.mtime = os.path.getmtime(lora_on_disk)

line 373: sd = sd_models.read_state_dict(lora_on_disk)

atbgams commented 1 year ago

As Ineman said ,got \stable-diffusion-webui\extensions\a1111-sd-webui-locon\scripts,open (main.py) by notepad++ or other edit tools ,change these 2 lines,restart a1111 from cmd.

Rexveal commented 1 year ago

line 371: lora.mtime = os.path.getmtime(lora_on_disk)

line 373: sd = sd_models.read_state_dict(lora_on_disk)

This work for me

RazredgeBR commented 1 year ago

I'm using SD on Google Colab "notebook" and I can't be editing any files. It's either straight out of Github or nothing. Is there a way for me to use an older commit or a branch that is working? If it is, please provide me a link and or a guide.

NoppaiKohai commented 1 year ago

line 371: lora.mtime = os.path.getmtime(lora_on_disk)

line 373: sd = sd_models.read_state_dict(lora_on_disk)

This worked for me, but then I just get an error about

AttributeError: 'LatentDiffusion' object has no attribute 'lora_layer_mapping'

instead

shinoda-kotaro commented 1 year ago

line 371: lora.mtime = os.path.getmtime(lora_on_disk)

line 373: sd = sd_models.read_state_dict(lora_on_disk)

Thank you! This saved me from a two hour nightmare.

hiro-hiroyuki-takeuchi commented 1 year ago

line 371: lora.mtime = os.path.getmtime(lora_on_disk)

line 373: sd = sd_models.read_state_dict(lora_on_disk)

This works for me! Thanks!!!

jyuan15 commented 1 year ago

LoRA', 'None', 1, 1, 'LoRA', 'None', 1, 1, 'LoRA', 'None', 1, 1, 'LoRA', 'None', 1, 1, None, 'Refresh models', <controlnet.py.UiControlNetUnit object at 0x00000242928CABF0>, <controlnet.py.UiControlNetUnit object at 0x00000243B49D1870>, <controlnet.py.UiControlNetUnit object at 0x00000242928C9030>, 'NONE:0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\nALL:1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1\nINS:1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0\nIND:1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0\nINALL:1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0\nMIDD:1,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0\nOUTD:1,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0\nOUTS:1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1\nOUTALL:1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1\nALL0.5:0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5', True, 0, 'values', '0,0.25,0.5,0.75,1', 'Block ID', 'IN05-OUT05', 'none', '', '0.5,1', 'BASE,IN00,IN01,IN02,IN03,IN04,IN05,IN06,IN07,IN08,IN09,IN10,IN11,M00,OUT00,OUT01,OUT02,OUT03,OUT04,OUT05,OUT06,OUT07,OUT08,OUT09,OUT10,OUT11', 1.0, 'black', '20', False, 'ATTNDEEPON:IN05-OUT05:attn:1\n\nATTNDEEPOFF:IN05-OUT05:attn:0\n\nPROJDEEPOFF:IN05-OUT05:proj:0\n\nXYZ:::1', False, False, False, 'Horizontal', '1,1', '0.2', False, False, False, 'Attention', False, '0', '0', '0.4', None, False, False, False, False, False, False, None, [], [], [], [], '', '', '', '', False, None, None, '', '', '', '', 'Auto rename', {'label': 'Upload avatars config'}, 'Open outputs directory', 'Export to WebUI style', True, {'label': 'Presets'}, {'label': 'QC preview'}, '', [], 'Select', 'QC scan', 'Show pics', None, False, False, 'positive', 'comma', 0, False, False, '', 1, '', [], 0, '', [], 0, '', [], True, False, False, False, 0, None, False, None, False, None, False, 50) {} Traceback (most recent call last): File "D:\Stable\SuperSD\stable-diffusion-webui\modules\call_queue.py", line 57, in f res = list(func(args, *kwargs)) File "D:\Stable\SuperSD\stable-diffusion-webui\modules\call_queue.py", line 37, in f res = func(args, kwargs) File "D:\Stable\SuperSD\stable-diffusion-webui\modules\txt2img.py", line 56, in txt2img processed = process_images(p) File "D:\Stable\SuperSD\stable-diffusion-webui\modules\processing.py", line 526, in process_images res = process_images_inner(p) File "D:\Stable\SuperSD\stable-diffusion-webui\extensions\sd-webui-controlnet\scripts\batch_hijack.py", line 42, in processing_process_images_hijack return getattr(processing, '__controlnet_original_process_images_inner')(p, args, kwargs) File "D:\Stable\SuperSD\stable-diffusion-webui\modules\processing.py", line 684, in process_images_inner devices.test_for_nans(x, "vae") File "D:\Stable\SuperSD\stable-diffusion-webui\modules\devices.py", line 156, in test_for_nans raise NansException(message) modules.devices.NansException: A tensor with all NaNs was produced in VAE. This could be because there's not enough precision to represent the picture. Try adding --no-half-vae commandline argument to fix this. Use --disable-nan-check commandline argument to disable this check.

add --no-half-vae --disable-nan-check in webui-user.bat

350640267 commented 1 year ago

line 371: lora.mtime = os.path.getmtime(lora_on_disk) line 373: sd = sd_models.read_state_dict(lora_on_disk)

This worked for me, but then I just get an error about

AttributeError: 'LatentDiffusion' object has no attribute 'lora_layer_mapping'

instead

me,too。help!

Merijeek commented 1 year ago

Worked for a bit by editing the two lines above.

Now, any attempt at a LORA/Lycoris gets me:

loading Lora E:\sd\stable-diffusion-webui\models\Lora\style\Analog_Diffusion.safetensors: NameError
Traceback (most recent call last):
  File "E:\sd\stable-diffusion-webui\extensions\a1111-sd-webui-locon\scripts\..\..\..\extensions-builtin/Lora\lora.py", line 222, in load_loras
    lora = load_lora(name, lora_on_disk.filename)
  File "E:\sd\stable-diffusion-webui\extensions\a1111-sd-webui-locon\scripts\main.py", line 378, in load_lora
    for key_diffusers, weight in sd.items():
NameError: name 'sd' is not defined
riade3788 commented 1 year ago

LoRA', 'None', 1, 1, 'LoRA', 'None', 1, 1, 'LoRA', 'None', 1, 1, 'LoRA', 'None', 1, 1, None, 'Refresh models', <controlnet.py.UiControlNetUnit object at 0x00000242928CABF0>, <controlnet.py.UiControlNetUnit object at 0x00000243B49D1870>, <controlnet.py.UiControlNetUnit object at 0x00000242928C9030>, 'NONE:0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\nALL:1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1\nINS:1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0\nIND:1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0\nINALL:1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0\nMIDD:1,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0\nOUTD:1,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0\nOUTS:1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1\nOUTALL:1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1\nALL0.5:0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5', True, 0, 'values', '0,0.25,0.5,0.75,1', 'Block ID', 'IN05-OUT05', 'none', '', '0.5,1', 'BASE,IN00,IN01,IN02,IN03,IN04,IN05,IN06,IN07,IN08,IN09,IN10,IN11,M00,OUT00,OUT01,OUT02,OUT03,OUT04,OUT05,OUT06,OUT07,OUT08,OUT09,OUT10,OUT11', 1.0, 'black', '20', False, 'ATTNDEEPON:IN05-OUT05:attn:1\n\nATTNDEEPOFF:IN05-OUT05:attn:0\n\nPROJDEEPOFF:IN05-OUT05:proj:0\n\nXYZ:::1', False, False, False, 'Horizontal', '1,1', '0.2', False, False, False, 'Attention', False, '0', '0', '0.4', None, False, False, False, False, False, False, None, [], [], [], [], '', '', '', '', False, None, None, '', '', '', '', 'Auto rename', {'label': 'Upload avatars config'}, 'Open outputs directory', 'Export to WebUI style', True, {'label': 'Presets'}, {'label': 'QC preview'}, '', [], 'Select', 'QC scan', 'Show pics', None, False, False, 'positive', 'comma', 0, False, False, '', 1, '', [], 0, '', [], 0, '', [], True, False, False, False, 0, None, False, None, False, None, False, 50) {} Traceback (most recent call last): File "D:\Stable\SuperSD\stable-diffusion-webui\modules\call_queue.py", line 57, in f res = list(func(args, *kwargs)) File "D:\Stable\SuperSD\stable-diffusion-webui\modules\call_queue.py", line 37, in f res = func(args, kwargs) File "D:\Stable\SuperSD\stable-diffusion-webui\modules\txt2img.py", line 56, in txt2img processed = process_images(p) File "D:\Stable\SuperSD\stable-diffusion-webui\modules\processing.py", line 526, in process_images res = process_images_inner(p) File "D:\Stable\SuperSD\stable-diffusion-webui\extensions\sd-webui-controlnet\scripts\batch_hijack.py", line 42, in processing_process_images_hijack return getattr(processing, '__controlnet_original_process_images_inner')(p, args, kwargs) File "D:\Stable\SuperSD\stable-diffusion-webui\modules\processing.py", line 684, in process_images_inner devices.test_for_nans(x, "vae") File "D:\Stable\SuperSD\stable-diffusion-webui\modules\devices.py", line 156, in test_for_nans raise NansException(message) modules.devices.NansException: A tensor with all NaNs was produced in VAE. This could be because there's not enough precision to represent the picture. Try adding --no-half-vae commandline argument to fix this. Use --disable-nan-check commandline argument to disable this check.

add --no-half-vae --disable-nan-check in webui-user.bat

tried that but got a new error and I don't nor should need --no-half-vae --disable-nan-check

Kadah commented 1 year ago

Here are a few options to resolve this:

Migrate to https://github.com/KohakuBlueleaf/a1111-sd-webui-lycoris

Update to A1111 1.3.0 RC

Wait then update to A1111 1.3.0 release

Revert to commit 04b768bad41e0f1122a86d0636fce47bb2765af8, but then revert back to head after updating A1111 to =>1.3.0

PR an A1111 version detection to deal with the changes in interface with the A1111 LoRA module in 1.3.0

Do note that this extension has other bug caused by the same root issue: this extension hijacks the default A1111 LoRA module and A1111 has updated that module a bunch while this extension's development has been dead for months. The a1111-sd-webui-lycoris does not do this and currently appears to be A1111=>1.3.0 safe.

KohakuBlueleaf commented 1 year ago

Sorry for late reply.

First, this extension is basically dead and deprecated, and the reason is basically as same as what @Kadah said.

I firstly use some hijack and hook to replace the built-in lora with my own locon implementation, and this quickly turn out to be bad idea. So I just rewrite a new version (lycoris) by myself. Which is "basically" (not totally) isolated with built-in loras.

(If you have traced the code detailly, you will find out that since my impl and a41's impl both need to do some weight operation on-fly in generation. I need to do lot more check to ensure lycoris ext will backup/restore correct weight, however this part continuouly has some annoying bug and I cannot reproduce them...)

basically the best solution now is: install lycoris, disable built-in lora, move all your lora/locon/loha/lokr/ia3/dylora file into LyCORIS folder.

And if there are someone who want to maintain this extension (it will be very difficult), let me know.

Bsm09 commented 1 year ago

Sorry for late reply.

First, this extension is basically dead and deprecated, and the reason is basically as same as what @Kadah said.

I firstly use some hijack and hook to replace the built-in lora with my own locon implementation, and this quickly turn out to be bad idea. So I just rewrite a new version (lycoris) by myself. Which is "basically" (not totally) isolated with built-in loras.

(If you have traced the code detailly, you will find out that since my impl and a41's impl both need to do some weight operation on-fly in generation. I need to do lot more check to ensure lycoris ext will backup/restore correct weight, however this part continuouly has some annoying bug and I cannot reproduce them...)

basically the best solution now is: install lycoris, disable built-in lora, move all your lora/locon/loha/lokr/ia3/dylora file into LyCORIS folder.

And if there are someone who want to maintain this extension (it will be very difficult), let me know.

A1111-sd-webui-lycoris does not support LoRA Block Weight. Only this extension supports it. Can a1111-sd-webui-lycoris be enabled to support it? Thank you!

Ideal-Real-Labs commented 1 year ago

Experiencing similar issue:

Error running process_batch: C:\Users\user\a1111\stable-diffusion-webui\extensions\sd-webui-additional-networks\scripts\additional_networks.py
Traceback (most recent call last):
  File "C:\Users\user\a1111\stable-diffusion-webui\modules\scripts.py", line 395, in process_batch
    script.process_batch(p, *script_args, **kwargs)
  File "C:\Users\user\a1111\stable-diffusion-webui\extensions\sd-webui-additional-networks\scripts\additional_networks.py", line 190, in process_batch
    if not args[0]:
IndexError: tuple index out of range

Is there an official fix in the mix?

KohakuBlueleaf commented 1 year ago

Sorry for late reply. First, this extension is basically dead and deprecated, and the reason is basically as same as what @Kadah said. I firstly use some hijack and hook to replace the built-in lora with my own locon implementation, and this quickly turn out to be bad idea. So I just rewrite a new version (lycoris) by myself. Which is "basically" (not totally) isolated with built-in loras. (If you have traced the code detailly, you will find out that since my impl and a41's impl both need to do some weight operation on-fly in generation. I need to do lot more check to ensure lycoris ext will backup/restore correct weight, however this part continuouly has some annoying bug and I cannot reproduce them...) basically the best solution now is: install lycoris, disable built-in lora, move all your lora/locon/loha/lokr/ia3/dylora file into LyCORIS folder. And if there are someone who want to maintain this extension (it will be very difficult), let me know.

A1111-sd-webui-lycoris does not support LoRA Block Weight. Only this extension supports it. Can a1111-sd-webui-lycoris be enabled to support it? Thank you!

You should check LBW's repo It already support lycoris. And it is not "support it recently" It is like 1~2 months ago.

KohakuBlueleaf commented 1 year ago

Experiencing similar issue:

Error running process_batch: C:\Users\user\a1111\stable-diffusion-webui\extensions\sd-webui-additional-networks\scripts\additional_networks.py
Traceback (most recent call last):
  File "C:\Users\user\a1111\stable-diffusion-webui\modules\scripts.py", line 395, in process_batch
    script.process_batch(p, *script_args, **kwargs)
  File "C:\Users\user\a1111\stable-diffusion-webui\extensions\sd-webui-additional-networks\scripts\additional_networks.py", line 190, in process_batch
    if not args[0]:
IndexError: tuple index out of range

Is there an official fix in the mix?

This is not my extension. Check the readme

"THIS EXTENSION IS NOT FOR ADDITIONAL NETWORK“

KohakuBlueleaf commented 1 year ago

@Bsm09

2023.04.14.2000(JST) support LyCORIS(a1111-sd-webui-lycoris) LyCORIS(a1111-sd-webui-lycoris)に対応

Copied from lbw's readme

acncagua commented 1 year ago
specifying after "lora name" the strength of LoRA, then specifying hierarchy (except DyLORA) specifying TEnc:UNet strength after "lora name" and then specifying hierarchy with lbw= (In case of DyLORA) Specify the strength of TEnc:UNet:Dyn after "lora name", and then specify the hierarchy with lbw=.
KohakuBlueleaf commented 1 year ago

lora: <lora: "lora name":1:IN02> specifying after "lora name" the strength of LoRA, then specifying hierarchy

lyco: (except DyLORA) <lyco: "lora name":1:1:lbw=IN02> specifying TEnc:UNet strength after "lora name" and then specifying hierarchy with lbw=

lyco: (In case of DyLORA) <lyco: "lora name":1:1:1:lbw=IN02> Specify the strength of TEnc:UNet:Dyn after "lora name", and then specify the hierarchy with lbw=.

BTW, since my arg system have kwarg feature and default value feature. you can use: <> which only TE get value 0.5 and UNet will use default value (which will take same weight from TE), dyn will be None as default. And if you use: <> TE will use default value(1), and unet=0.5, dyn=None.

acncagua commented 1 year ago

lora: <lora: "lora name":1:IN02> specifying after "lora name" the strength of LoRA, then specifying hierarchy lyco: (except DyLORA) <lyco: "lora name":1:1:lbw=IN02> specifying TEnc:UNet strength after "lora name" and then specifying hierarchy with lbw= lyco: (In case of DyLORA) <lyco: "lora name":1:1:1:lbw=IN02> Specify the strength of TEnc:UNet:Dyn after "lora name", and then specify the hierarchy with lbw=.

BTW, since my arg system have kwarg feature and default value feature. you can use: which only TE get value 0.5 and UNet will use default value (which will take same weight from TE), dyn will be None as default. And if you use: TE will use default value(1), and unet=0.5, dyn=None.

So, you mean we can use it in the same way as <lora:> if TEnc and UNet have the same value. Thank you for the explanation

cultureBomb commented 1 year ago

couldn't fallback.