DeSinc / SallyBot

AI Chatbot coded in Discord.net C#
MIT License
299 stars 51 forks source link

Issue with stable diffusion not being able to load loras #22

Closed NarksClueless closed 1 year ago

NarksClueless commented 1 year ago

When having the prompts for the stable diffusion be entirely user input and not the LLM, if you try to use a lora it will come back with "couldn't find Lora with name XXXXX". like this.

image

Sure it's not a massive issue but being able it change the outputs with a lora would be nice!

DeSinc commented 1 year ago

either select a lora in the webui by enabling the dropdown for it in the SD webui settings, or try to provide \<lora:Lora_Name:1> in the prompt itself which might work too. Admittedly I haven't tested this

DeSinc commented 1 year ago

First test: Confirming: selecting a lora from the webui does cause all of the bot's prompts to become shaped by that lora.

DeSinc commented 1 year ago

Second test: replacing llm's prompt with direct user prompt: I can't get it to recognise the \<lora:Lora_Name> tag even with escape backslashes. I think this must be a webui only feature to put it in with the prompt text.

There might be some param you can pass to the webui for this but I'm not sure what it is

DeSinc commented 1 year ago

warning: if you select a lora in the drop down it seems atm in my version of SD there is no way to UNselect this lora, quite annoying. I think I have to move the lora out of the folder to get it to stop selecting it in the webui. not even a reload clears it.

Edit: I found a fix for this by literally typing 1 word "None" into a line in a .py with notepad. The file is called lora_script.py and it is in this folder: \stable-diffusion-webui\extensions-builtin\Lora\scripts\lora_script.py

Open that with any text editor, even just regular notepad, and then on the bottom line 55 here: "sd_lora": shared.OptionInfo("None", "Add Lora to prompt", gr.Dropdown, lambda: {"choices": [""] + [x for x in lora.available_loras]}, refresh=lora.list_available_loras),

Change that "choices": [""] part to have ["None"] inside the empty square brackets and quotes. Like this:

"sd_lora": shared.OptionInfo("None", "Add Lora to prompt", gr.Dropdown, lambda: {"choices": ["None"] + [x for x in lora.available_loras]}, refresh=lora.list_available_loras),

Now save this file and close it and close stable diffusion, and re-load it again. Now this adds a "None" option in the lora drop-down so you can DE-SELECT the lora.

Thanks to this thread for the fix: https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/9041#issuecomment-1486049253

DeSinc commented 1 year ago

well, there is no lora tags in stable diffusion API. I had a look at the code to see if I could add it myself but no luck, I just don't understand what it needs to add that field and select a lora based on it.

Until SD adds a lora field for the input json in the API, the only way to select a lora appears to be going into the webui and selecting it in the settings.

DeSinc commented 1 year ago

When having the prompts for the stable diffusion be entirely user input and not the LLM, if you try to use a lora it will come back with "couldn't find Lora with name XXXXX". like this.

image

Sure it's not a massive issue but being able it change the outputs with a lora would be nice!

p.s: what did you do to get this lora error back btw?

NarksClueless commented 1 year ago

Sorry so when i changed it to allower user input for the prompts by doing this image

If you try and use a lora by adding it into a prompt like this " a funny cat standing <> " it should show that error.

I should have mentioned that selecting a lora via the dropdown is trash because you can't unselect it and it permanently mixes it with everything else.

Also know that it can use Textual Inversions fine by just typing their file name exactly as it is saved So "necoarc.pt" would be "necoarc"

I did see this thread about the same issue with people posting a solution but im not smart enough to implement it and test it https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/7984

DeSinc commented 1 year ago

yeah I have no clue what he did or what he's talking about. I read it 3 times but I don't have enough information or context to be able to connect any dots. frankly I have no clue how they all know what he meant in that thread. lmao

NarksClueless commented 1 year ago

Understandable, appreciate the effort on the project as a whole.

If i figure it out i'll post it..

NarksClueless commented 1 year ago

Figured it out, somewhere some how you're filtering out capitals or something, idk much about coding or how to edit code that well.

If you rename the lora using all lower case it can prompt without issue. This might not be useful to you but it's good to know just in case you feel like letting people generate art of characters, memes, etc.

DeSinc commented 1 year ago

Figured it out, somewhere some how you're filtering out capitals or something, idk much about coding or how to edit code that well.

If you rename the lora using all lower case it can prompt without issue. This might not be useful to you but it's good to know just in case you feel like letting people generate art of characters, memes, etc.

definitely not filtering out capitals out of the message, and definitely the lora name is not caps sensitive in the webui either. It must be a SD API thing that's doing it. good find.