mix1009 / model-keyword

Automatic1111 WEBUI extension to autofill keyword for custom stable diffusion models and LORA models.
MIT License
248 stars 13 forks source link

Request: trigger word sets/groups within each LoRA #35

Open PaulCoddington opened 1 year ago

PaulCoddington commented 1 year ago

Ideally, this extension should be able to handle conceptual groups of trigger words within a single LoRA, such as:

EvangelionLoRA.safetensors

AYANAMIREI, EVA00PLUGSUIT, INTERFACE HEADSET

AYANAMIREI, TOKYO-3_MIDDLE_SCHOOL_UNIFORM, RED RIBBON, SCHOOL_UNIFORM, BLACK SOCKS

SORYUASUKALANGLEY, TOKYO-3_MIDDLE_SCHOOL_UNIFORM, RED RIBBON, SCHOOL_UNIFORM, WHITE SOCKS, INTERFACE HEADSET

SORYUASUKALANGLEY, EVA02PLUGSUIT, INTERFACE HEADSET

--//--

Description 'keyword or keywords separated by |' is unclear.

Expected behavior from description might be:

word1, word2, word3|word1, word4, word5

Which should produce a drop list:

word1, word2, word3 word1, word4, word5

But in actual fact, produces a drop list:

word1

...because the underlying text file is CSV and the input is not sanitized.

Alternative expected behavior from description might be:

word1|word2|word3|word4|word5

But then the user does unnecessary extra work for no gain (shift key) to type it rather than naturally type (or copy/paste) 'word1, word2, word3, word4, word5' and have the extension convert the ", " or "," to "|" when writing to the file (Replace and Trim).

But this still cannot handle LoRA that conceptually have multiple sets of trigger words that are only used together in groups, such as multiple named characters with multiple costume options.

--//--

Although the README states that saving new sets of keywords overwrites the previous saved entries, the content of the file is not overwritten but appended in practice.

So, it appears possible to save groups as multiple entries in the underlying text file by:

word1|word2|word3 [SAVE BUTTON] word4|word5|word6 [SAVE BUTTON]

And the file will then contain:

checksum1234, word1|word2|word3, LoRA1.safetensors checksum1234, word4|word5|word6, LoRA1.safetensors

But, when the file is read back into the drop list, only the last entry for the LoRA is listed and all other entries for the same LoRA are ignored:

word4 word5 word6

I suspect this behaviour is a bug I've accidentally discovered by trying to figure out how to group trigger words.

--/--

BTW the extension fails with an error if the text file accidentally becomes UTF-8, which is the default format for Windows 11 onwards. This is going to catch people out, as they will want to edit the text files manually to correct mistakes, as this will be much faster than starting up and using the WebUI interface when making alterations to LoRA collections.

I discovered this problem while trying to work around the grouping problem using 'word1·word2·word3|word4·word5' with the intent to manually edit after auto-insertion (note: some trigger words do contain spaces, so space cannot be used to separate words in a group).

--//--

This add-in has potential to become a major sought-after feature that can overcome the problem that the WebUI lacks any form of trigger word management other than having a huge unsearchable Style list.

I have not seen any alternatives so far, other than keeping a notebook on the side. The website you mentioned in another thread is not up-to-date with the large number of new LoRA being produced and also requires users to have not renamed the LoRA to make them easier to use.

I do hope you will be encouraged to continue work on this (and check out the booru tag autocomplete extension to see if the same techniques can be used to provide pop-up trigger word selection drop lists in the prompt box itself rather than using a drop list of LoRAs below it).