[GH-ISSUE #297] [WebUI Forge] Cannot reload embeddings instantly #206

Open
opened 2026-10-30 21:20:58 +00:00 by bsakaguchi · 8 comments
Owner

Originally created by @bluenyx on GitHub (Aug 11, 2024).
Original GitHub issue: https://github.com/DominikDoom/a1111-sd-webui-tagcomplete/issues/297

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

Originally created by @bluenyx on GitHub (Aug 11, 2024). Original GitHub issue: https://github.com/DominikDoom/a1111-sd-webui-tagcomplete/issues/297 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](https://github.com/user-attachments/assets/db7c263e-3818-4110-9fb7-a70036b96c5d) ![image](https://github.com/user-attachments/assets/de3decf3-4265-4199-89fe-6b310aa0f66e) ![image](https://github.com/user-attachments/assets/530b1826-5bcc-49ac-a2ab-5d5b92aa1e3d)
Author
Owner

@DominikDoom commented on GitHub (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.

<!-- gh-comment-id:2282750011 --> @DominikDoom commented on GitHub (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](https://github.com/user-attachments/assets/70e645b6-309a-4fd6-9424-14c432ea58ba) - 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.
Author
Owner

@Hazitos commented on GitHub (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.

<!-- gh-comment-id:2329646704 --> @Hazitos commented on GitHub (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.
Author
Owner

@GeminiSquishGames commented on GitHub (Sep 20, 2024):

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.

<!-- gh-comment-id:2363206227 --> @GeminiSquishGames commented on GitHub (Sep 20, 2024): 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.
Author
Owner

@Symbiomatrix commented on GitHub (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.

<!-- gh-comment-id:2407854560 --> @Symbiomatrix commented on GitHub (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.
Author
Owner

@DominikDoom commented on GitHub (Oct 11, 2024):

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.

<!-- gh-comment-id:2407903487 --> @DominikDoom commented on GitHub (Oct 11, 2024): > 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.
Author
Owner

@DenOfEquity commented on GitHub (Oct 11, 2024):

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.

<!-- gh-comment-id:2408192749 --> @DenOfEquity commented on GitHub (Oct 11, 2024): 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.
Author
Owner

@DominikDoom commented on GitHub (Oct 12, 2024):

@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.

<!-- gh-comment-id:2408552791 --> @DominikDoom commented on GitHub (Oct 12, 2024): @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.
Author
Owner

@Symbiomatrix commented on GitHub (Oct 26, 2024):

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

<!-- gh-comment-id:2439761292 --> @Symbiomatrix commented on GitHub (Oct 26, 2024): @DominikDoom Den merged (thanks!), should be good to go using the standard method.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
DominikDoom/a1111-sd-webui-tagcomplete#206
No description provided.