-
Notifications
You must be signed in to change notification settings - Fork 316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
POC: Updating loras on the fly. #182
Conversation
Certified works on my machine.
I'm not a fan of having active UI elements for Tag Autocomplete, IMO aside from the settings it should stay purely passive and automatic. The main page scripts section is cluttered enough for most people already. Also, there already is a refresh button for loras in the builtin extra networks tab - preferably there would be a way to use that instead. I'll take a look at it. In the meantime, if you reload the UI by clicking the buttons at the bottom of the page or in the settings instead of closing the whole terminal window, it only takes a few seconds and also reloads everything else beside Loras that might have changed. So I don't think it's that bad. As for the paths issue, that is something entirely separate. It's a common pain point, but I can't add features that rely on a modded Gradio for obvious reasons. The (relative) paths I use by default are provided by the webui itself. |
Thanks for considering it.
I'm on vlad's fork, no such reload buttons at the bottom of the page that I can see. I reload through settings' apply + reload. And in any case, if they still reload the entire page (ie wipe all main settings to default), it's quite an inconvenience. Sorry, perhaps I was unclear - I wasn't saying the paths issue should be fixed (well, at least it'd take more effort than it's worth to fix it for everyone), but rather that I'm not 100% sure whether my fix works on the vanilla extension. Also, and I don't mean to sound overbearing, but as my former teacher often said - KISS! If you can add a slightly imperfect QOL feature without too much hassle or clutter, it's better than not having it at all. You may not realise how much of a difference it would make. (And it's not like we're billing for the time, eh.) |
I tried around for a bit with the built-in gradio components, I think I found the best way to do it. shared.opts.add_option("tac_refreshTempFiles", shared.OptionInfo("Refresh TAC temp files", "Refresh internal temp files", gr.HTML, {}, refresh=refresh_temp_files, section=TAC_SECTION)) This will create a non-interactible settings component but give it a refresh button like the webui uses for dropdowns, so it functions as a standalone refresh button with a label. This is more useful than adding a custom button since the webui already has the fixed refresh button style etc. provided, making it more consistent. It even shows a "something is happening" animation, although I'm not sure if that actually depends on the runtime of the refresh function: chrome_2023-05-26_15-26-47.mp4Either way, this both works in the normal settings as well as in the quicksettings. The only downside is that there's no good way to tell when the refresh is done, so for now I just have the javascript side update after a fixed 2 second timer. If the "pending" fading animation is runtime dependent, I might try to listen to HTML changes to see when Gradio removes the class again, but for now I think this is good enough. I pushed it on the https://github.com/DominikDoom/a1111-sd-webui-tagcomplete/tree/feature-refresh-temp-files branch, please have a look if it fits your needs (and if it works on vlads fork). |
It may well be the only way currently. I've had a chat with vlad, and though the optioninfo are accessible & alterable, it seems that the settings components are only constructed in ui locally, so we can't add any custom events (like mapping the js function to a button), and even then vlad says the js runs before the python mapped function so it's out of order for us. Edit: Huh, where's the part that actually reloads the loras etc from the files? The js seems to just be setting them to empty lists? Oh, I see, process queue. Embeddings not in the refresh list? |
I grab the embeddings directly from the webui dictionary, to get info about whether they are a SD 1.x or 2.x based embedding. It's a bit tricky to include in the same function since they aren't available at startup. But model change will already update the temp file, I just haven't included it in the js part yet because of that. I plan to add it in a bit though. |
Should work now. But it still depends on the internal dict of the webui, so it will update only after a model change, manual refresh in the extra networks UI, or (I think) when the prompt is parsed & validated before starting a generation. So our button alone is not enough. Also, I somehow missed that I mistyped the query selector in the initial commit, the changes weren't updated in the javascript at all since the function never got called, lol. I only checked if the files itself were updated earlier. |
Job well done, sir. Works perfectly as described and certainly much more elegantly written than I could've done. Much obliged. Edit: By the way, might want to label that button a bit better for the users. : ) |
Hello dominik, it's been a longstanding peeve of mine that the ui must be restarted to see newly added loras in autocomplete.
Apparently, merely updating the lora.txt file and the global loras variable is all it takes to refresh the list, no restart needed (at least on vlad's fork). So I added a couple crummy ui buttons and copypastad functions, and it seems to be working almost without a hitch (I think the button's js call doesn't wait for the file to update, so possibly need a timer to combine that).
I'm also using a slightly modded version which has direct instead of relative paths and gradio's circumvented to allow said path, but if that's all it takes to enable this feature, then I think it's imperative to find a way to do that.
Penny for your thoughts?