Bing-su / adetailer

Auto detecting, masking and inpainting with detection model.
GNU Affero General Public License v3.0
4.21k stars 329 forks source link

[Feature Request]: Respect the `{prompt}` keyword (or similar) in ADetailer prompts (nice-to-have) #521

Closed toebeann closed 8 months ago

toebeann commented 9 months ago

Is your feature request related to a problem? Please describe.

Let's imagine you are developing a prompt for a woman with red hair and green eyes, and you want her to have a specific feature on her face only:

masterpiece, 1girl, red hair, green eyes, scarred face

(this is a contrived example)

Some models might put scars on other parts of the body, like the arms, neck, etc., not understanding the context or intent.

To correct for this, it is currently possible to have only ADetailer focus on the feature while using e.g. the mediapipe_face_full model, something like:

positive prompt:

masterpiece, 1girl, red hair, green eyes

adetailer positive prompt:

masterpiece, 1girl, red hair, green eyes, scarred face

The (admittedly minor) problem is that this becomes cumbersome to maintain if you are experimenting with your prompt, developing it over time to flesh it out. Each time you make changes that affect the face, you need to make sure to add them to the adetailer prompt or you will end up with an undesirable result, and this can become quite tedious.

If you only input scarred face as your positive prompt for ADetailer, then other details present in the original prompt will be lost and potentially replaced, for example you might end up with an inpaint where e.g. the eye colour will be blue or brown instead of the desired green.

You could develop the prompt first, and only then add the desired details to the ADetailer prompt, but it's not terribly convenient.

Describe the solution you'd like

A keyword which ADetailer recognises as a signal to insert the original prompt in its place could be a nice way to make this situation more convenient for users.

For example, ADetailer could respect the {prompt} keyword already used by automatic1111 as a special string which will be substitued for your prompt when combined with a style from styles.csv.

Alternatively, ADetailer could add its own keyword in the same vein as the [SEP] and [SKIP] keywords, e.g. [PROMPT].

Example usage

positive prompt:

masterpiece, 1girl, red hair, green eyes

and then your adetailer positive prompt could be:

{prompt}, scarred face 

When put together, ADetailer would then construct the prompt:

masterpiece, 1girl, red hair, green eyes, scarred face

Describe alternatives you've considered

As mentioned above, it is possible to develop the prompt first and only once you are satisfied add details to the ADetailer prompt by copy and paste. You could also copy and paste the prompt manually to ADetailer each time you make changes. Neither of these are terribly convenient, however.

An alternative that ADetailer could implement would be to add the ability for the user to select styles for only ADetailer to use, then the user could leave the adetailer prompt blank and select a style which contains e.g. {prompt}, scarred face.

This alternative feels like it would be more tedious for the user than my proposal, since editing the styles.csv for a single use feels a little overkill. That said, it could be a nice addition in its own right for use cases where a user does want to save their template ADetailer prompt string for future uses.

Additional context

No response

Bing-su commented 9 months ago

https://github.com/Bing-su/adetailer/blob/3f1d1b9772aae767ff63be15be425348b0083324/scripts/!adetailer.py#L309-L314

I added the [PROMPT] syntax a long time ago and forgot to document it somewhere, sorry.

It's a keyword that works as you say.

Woisek commented 9 months ago

I added the [PROMPT] syntax a long time ago and forgot to document it somewhere, sorry.

That's great, but wouldn't it more convenient to support the wildcard extension to carry random made variables over to the ADetailer prompt? 🤔 That would be awesome.

toebeann commented 9 months ago

Ha, perfect! My bad for only testing {prompt} before opening a feature request!