DominikDoom / a1111-sd-webui-tagcomplete

Booru style tag autocompletion for AUTOMATIC1111's Stable Diffusion web UI
MIT License
2.56k stars 306 forks source link

Handling Exception, and issues when restarting gradio through web-ui #89

Closed NamelessButler closed 1 year ago

NamelessButler commented 1 year ago

Autotag Build 1.12.1

Getting some exceptions with tag-autocomplete.... When going to settings tab... https://pastebin.com/XhU5fQ60 At this point tag-autocomplete still works....

And if I change any settings and restart gradio, sometimes this happen. https://pastebin.com/n3AnU5TC When this happens it stops working entirely....

Even restarting collab doesn't work now... dunno whats going on.

DominikDoom commented 1 year ago

The first seems related to it not correctly finding the folder the extension was installed in, but if that error happens, autocomplete shouldn't work at all, which is why I didn't catch it there. Which colab are you using?

The second seems unrelated to tag-autocomplete, that says that a file was requested that Gradio can't serve (either because they don't exist or because they are outside the webui root, which is forbidden as security measures). Since they are all image files and artist names, that could be related to the inspiration extension or something similar if you're using that as well.

NamelessButler commented 1 year ago

Apart from auto-tag

Extensions: https://github.com/AUTOMATIC1111/stable-diffusion-webui-wildcards https://github.com/yfszzx/stable-diffusion-webui-images-browser https://github.com/some9000/StylePile https://github.com/Zyin055/Config-Presets https://github.com/animerl/novelai-2-local-prompt

And Collab... https://colab.research.google.com/drive/1USiUuG_QvqSwbrgm6AAKOwRtOae3mxK6?usp=sharing Personal one I'm using...

DominikDoom commented 1 year ago

Yeah the second exception comes from StylePile it seems, https://github.com/some9000/StylePile/tree/main/StylePile/Artists, those are the artist jpg files it can't find for whatever reason.

Thanks for the colab link, I'll set up my own copy and see if I can reproduce it.

NamelessButler commented 1 year ago

Ok, btw, First time I ran it today with the fixed auto-tag , tags were working.... Until I went to settings tab and changed a few settings. After I applied and restart gradio through there. Things went haywire....

Starting only with auto-tag extension worked, although it took a bit for the tags to start working... I thought it wasn't working at first.

I'll also try some things here.... Enabling one extension after another to see if there is any sort of conflict.

edit: I haven't added other extensions yet, just change once again a few settings on the settings tabs, and restarted gradio... auto-tag stopped working, but no exception errors this time. edit2: By the time I finished writing above, I went back to the gradio page, and it was frozen.... And if I open another gradio page, it takes quite a while to load.... I'm guessing there's some sort of conflict with the settings... or restarting gradio break things up. edit3: After deleting config.json from root folder (which stores the settings) it threw me the first exception I posted above. https://pastebin.com/XhU5fQ60. Since it generates a new one everytime we apply, I thought it was a good idea.

DominikDoom commented 1 year ago

Likely the gradio restart messing something up, or quirks of gradio on colab in general. I just tried it myself, and I also got the first exception, but immediately after opening the webui URL, not after applying settings.

Notably, however, everything related to autocomplete still worked for me, despite the supposed file not found errors. It seems to me like the files were for whatever reason requested before being ready to serve by gradio, but since it still worked for me maybe it retried? Idk to be honest.

Reloading gradio in the settings created a new share link for me, so the old page was stuck on Loading... forever, the new one worked though (without throwing any errors).

NamelessButler commented 1 year ago

Something along these steps is breaking it , (mainly applying settings).... 1 - Install basics + auto-tagcomplete 2 - start web ui 3 - Tags working fine 4 - go to settings tab and click apply image 5 - restart gradio 6 - tags stops working

DominikDoom commented 1 year ago

Are you restarting gradio using the colab or with the button in the webui settings?

NamelessButler commented 1 year ago

Web-ui settings then I open the new link provided in collab. Btw, I haven't change any settings this time, I just went to settings tab and click apply, mainly for testing if it was the cause.... Edit: Wait nvm, it started working out of nowhere now.... it just took quite a while... Let's see if use my settings it will still work....

NamelessButler commented 1 year ago

Changed settings: image image image image image image Restarting gradio now....

NamelessButler commented 1 year ago

After opening new gradio link... tag wasn't working, after a couple seconds the page hang/froze

DominikDoom commented 1 year ago

I tried following your steps but apply & restart didn't make a difference and didn't throw an error. Interestingly the first exception only happens for me when I click on the share link right after it shows. If I just wait a few seconds before opening it, so far it has never reappeared.

tag wasn't working, after a couple seconds the page hang/froze

Don't use e621 as extra tags, that functionality is primarily to add small sets of custom tags or new aliases. It will perform an alias match search, so if the extra file is too big, it will take ages to finish. It searches every potential alias for every tag, so in case of danbooru as the main file and e621 as extra, this means 10,000,000,000 (yes, ten billion) lookups. This is why it hangs.

NamelessButler commented 1 year ago

I was about to write about it, maybe that's the cause... I though it was extra tags. After removing e621 it no longer hangs as you just said, and tags are working although it takes around 10~20 second after starting gradio. I'll check if it conflicts with the other extensions now...

DominikDoom commented 1 year ago

I though it was extra tags.

Yeah it is a bit unclear, I'll add a warning for it. e621 is a completely different main tag set for models trained on the site of the same name, mainly furry models.

Other than that I couldn't find any issues trying stuff out the colab. The original exceptions seem to both be gradio quirks that don't actually break functionality as far as I could see. And as I said they both didn't reappear if I wait a bit before accessing the webui, so it might literally be that the gradio backend isn't fast enough when sharing from colab and needs a bit of warm-up time, so to speak, to serve all the files. Same for the StylePile artist pictures, the faster I opened the page, the more were not loaded correctly. Long startup time might be just related to what CPU colab gave you and what your network speed is, since on colab the tag files need to be accessed over the internet instead of loading them from a local file, which can obviously be much slower depending on connection quality.

NamelessButler commented 1 year ago

I see thanks for the support. Main issue for me was actually e621 which was breaking everything due to zillions of tags to load and collab limitations... so I assume with e621, assuming I'm using the model... Should I load only the e621.csv, or both danbooru.csv and e621.csv can be used together, assuming I have a fairly decent cpu?

Once again, thanks for the support, you can close this issue. Happy holidays 🎄 🎅 🎁

DominikDoom commented 1 year ago

so I assumi with e621, assuming I'm using the model... Should I load only the e621.csv, or both danbooru.csv and e621.csv can be used together, assuming I have a fairly decent cpu?

If you are using a furry model like yiffy, you should only use e621 as the main tag file, while for most anime models danbooru is usually a better fit. At least for the models I know of none were directly trained on both, and merges with different tag sets usually result in subpar results as well.

There currently isn't a way to use multiple files as main tags. Extra file just adds them to the bottom, so sorting will also not be correct. I might add that functionality later or do a manual merge of the two csvs, but since not a lot of models would benefit from it I didn't see the need so far.

Btw, I didn't try it on the colab, but at least on local tag-autocomplete also supports tag hotswap, so if you change the file in the settings or add tac_tagFile to the quicksettings, it should auto-reload without needing to restart (I noticed I would sometimes need to click on "Apply settings" twice for it to register the change).