uwidev / sd_extension-prompt_formatter

Prompt formatter extension for automatic1111's stable diffusion web-ui
GNU Affero General Public License v3.0
95 stars 9 forks source link

Classify and wrap prompts according to txt file #1

Open sdbds opened 1 year ago

sdbds commented 1 year ago

many people use extensions 'wildcards', it use txt to load a class list. Can we use the same method to read categories, separating quality words, character words, and background、items?

uwidev commented 1 year ago

I've heard of wildcards, but never really explored them. Just do be sure, you're talking about sd-dynamic-prompts, right?

I'm a bit confused on what you're asking for. Currently, this extension looks at the entire prompt and recognizes "tokens" as anything between brackets, between commas, and between the last token and a bracket. Could you give me an example of how this feature would operate?

sdbds commented 1 year ago

I've heard of wildcards, but never really explored them. Just do be sure, you're talking about sd-dynamic-prompts, right?

I'm a bit confused on what you're asking for. Currently, this extension looks at the entire prompt and recognizes "tokens" as anything between brackets, between commas, and between the last token and a bracket. Could you give me an example of how this feature would operate?

Sorry, I may not have made myself clear. What I meant was this wildcard. it forked form origin version but more easier to understand.

Assuming we have defined some wildcard txt files, such as quality words, character traits, backgrounds, items, etc.

We hope that this plugin can read the path of scanning wildcard files (or we can define a directory by ourselves) and then divide the prompt into different lines according to the classification of these words.

For example original prompts: a girl,master piece,4k,holding, cup,red hat,blue eyes,sky

after Formatting:

master piece,4k,

a girl,blue eyes, holding,

cup,red hat,

sky,

Hope to intuitively divide the prompt into different lines according to the wildcard's txt classification.

uwidev commented 1 year ago

Yeah I can see how this might be useful. I believe that if you really want to get consistent poses, they should be more so towards the beginning of the list.

So from what I understand, let's say we have wildcard files as follows. medium.txt

pencil
crayon
paint

framing.txt

upper body
portrait
full body

Given a prompt: pencil, upper body, crayon It would be formatted to:

pencil, crayon

upper body

Based on some user-defined ordering (for example, ordered style, framing), though I think optimally it would just format it to pencil, crayon, upper body without the new lines.

If this is correct, as said earlier, I think it would be very useful when writing prompts.

Currently I'm trying to make sure the prompt formatting is stable with vanilla prompt features. Things like composable diffusion and prompt editing and alternating words aren't fully supported yet. I will also probably remove the default behavior of moving networks to the back, as default behavior should retain as closely as possible to the original prompt.

That said, this feature won't be coming.

It's possible I might allow "extensions" with my extension so that people can easily do more.

sdbds commented 1 year ago

thank you for understanding~Not necessarily need to use a new line, just make these prompts look clearer. Many times the prompts found online are randomly sorted and not easy to distinguish. This can be an extended feature.