Skip to content
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

[WebUI Forge] Cannot reload embeddings instantly #297

Open
bluenyx opened this issue Aug 11, 2024 · 8 comments
Open

[WebUI Forge] Cannot reload embeddings instantly #297

bluenyx opened this issue Aug 11, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@bluenyx
Copy link

bluenyx commented Aug 11, 2024

WebUI : forge - [f2.0.1v1.10.1-previous-222-g33187c26]
python: 3.11.9
torch: 2.4.0+cu124
gradio: 4.40.0

Tag Autocomplete: Cannot reload embeddings instantly: 'StableDiffusionModelHijack' object has no attribute 'embedding_db'
And, I have easynegative, but it's not added.

image
image
image

DominikDoom added a commit that referenced this issue Aug 11, 2024
Resolves some symptoms of #297, but doesn't fix the underlying cause
@DominikDoom
Copy link
Owner

DominikDoom commented Aug 11, 2024

It seems webui forge had a pretty big backend rewrite which broke many extensions.
I tried my best to add fallbacks for its changes, and it should be partially fixed now, but some things are still different from before.

The main things to consider:

  • Like some other implementations (maybe also dependent on settings), the SD model now gets loaded not on startup, but on demand (i.e. once you click generate)
    • TAC uses the webui's internal model database to fast-reload embeddings and figure out if they're SD1/SD2/SDXL, so before the model is loaded, embeddings will show up as "unknown". This is not fixable. Once the model was loaded for the first time, it should show the correct types.
    • This also means that newly added embeddings will only show up after a model switch/reload
    • In some cases, TAC might need a manual refresh (e.g. clicking the refresh button in the Extra networks gallery tabs or using this button in the TAC settings:
      image
  • With this update, forge doesn't include the full file path in the embedding object I access anymore
    • As a result, TAC's setting to sort extra networks by modification date won't work
    • And it also isn't possible anymore to prefix the folder name of the embedding (e.g. negative/...) to only show embeddings of that subfolder (this was possible before, even though the folder prefixes weren't shown in the completion UI)

There might be more changes in the future, as some things in forge still seem broken in general right now and its rewrite isn't finished yet. For example, multiple API endpoints don't work and the TI embeddings extra network tab also doesn't show only the embeddings matching the currently loaded model, but all of them.

Depending on how these are fixed, my workaround might get broken again, so I'm leaving this issue open for the meantime.

@DominikDoom DominikDoom added the bug Something isn't working label Aug 11, 2024
@DominikDoom DominikDoom changed the title Cannot reload embeddings instantly [WebUI Forge] Cannot reload embeddings instantly Aug 11, 2024
@Hazitos
Copy link

Hazitos commented Sep 4, 2024

I am having a very similar bug but with my UI itself not loading certain aspects like, checkpoints, loras, embeddings and even reloading the UI seems to to not work anymore, it just freezes and never finishes. I'll be making a separate bug report about this.

@GeminiSquishGames
Copy link

Interesting. This doesn't even work in forge for me and hasn't for a few months. Same with prompt-all-in-one... but not only them. They really dropped the ball I guess.

@Symbiomatrix
Copy link
Contributor

Symbiomatrix commented Oct 11, 2024

@DominikDoom Any idea why they dropped the filenames in the first place? It's still littered all over the production code (eg sd_forge_lora/networks.load_networks refers to it on exception, backend/text_processing/textual_inversion.create_embedding_from_data taking a filepath it doesn't use), two months later.

@DominikDoom
Copy link
Owner

Any idea why they dropped the filenames in the first place? It's still littered all over the production code (eg sd_forge_lora/networks.load_networks refers to it on exception, backend/text_processing/textual_inversion.create_embedding_from_data taking a filepath it doesn't use), two months later.

@Symbiomatrix All I can tell you is that it happened during the big backend rework where forge migrated away from all the hijack stuff used in base A1111, but I don't know if it was intentional. It might very well just be an oversight that got lost during the "move fast, break things" period of said rework.

@DenOfEquity
Copy link

You can access the new Forge embeddings database as:
embedding_db = modules.textual_inversion.textual_inversion.EmbeddingDatabase()
refresh: embedding_db.load_textual_inversion_embeddings(force_reload=True, sync_with_sd_model=False)
attributes seem to be as usual, filename contains full path.

@DominikDoom
Copy link
Owner

@DenOfEquity That is from the base webui, and I use that in the code if it is set (by accessing it from the respective model, since I need the existing instance).
But as far as I'm aware, forge does not use this implementation for embeddings anymore.
In its main code, it calls from backend.text_processing.textual_inversion import EmbeddingDatabase, as @Symbiomatrix already mentioned. And that one has no filename / filepath property.

@Symbiomatrix
Copy link
Contributor

Symbiomatrix commented Oct 26, 2024

@DominikDoom Den merged (thanks!), should be good to go using the standard method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants