Teach you how to write prompt words with Stable Diffusion, the basic and advanced syntax of Stable diffusion prompt words

Hello everyone, today I will share with you about Stable diffusion Prompt wordWhy is it necessary to understand the basic and advanced grammar of SD? First of all, prompt words have a great influence on the output effect. Understanding the usage of prompt words will help us write better prompt words. Secondly, we may copy other people's prompt words from C station. Although we can get good results by copying them directly, this will only "know the result but not the reason". So if you want to master SD well, it is necessary to pass this level!

1. Basic rules

The first rule is: prompt words are separated by English commas. If you think it is not beautiful to squeeze all the prompt words into one line, you can also wrap the line, but wrapping the line does not mean separating the prompt words. If you want to separate them, you still have to add English commas.

Teach you how to write prompt words with Stable Diffusion, the basic and advanced syntax of Stable diffusion prompt words

The second rule is that the weight of the prompt word decreases from the front to the back, which means that the prompt word at the front has a higher weight. However, this also has a prerequisite, that is, your prompt word does not use any syntax to increase/decrease the weight.

For example, I have two sets of prompt words (the general scene is a little girl and a castle):

# Group A prompt words castle,landscape,1girl,loli,silver hair,school_uniform,crystal_earrings,kind_smile,arm_support,in summer,book,mini_witch_hat,frilled,strappy_heels, # Group B prompt words castle,landscape,1girl,loli,silver hair ,school_uniform,crystal_earrings,kind_smile,arm_support,in summer,mini_witch_hat,frilled,strappy_heels,book,

The difference between these two sets of prompts is the position of the book prompt (one is in the middle, the other is at the end), resulting in one having more books and the other having fewer books.

Teach you how to write prompt words with Stable Diffusion, the basic and advanced syntax of Stable diffusion prompt words

The third rule (note) is: the number of prompt words should be controlled within 75 tokens. According to the second rule, the later the prompt words, the lower the weight, so the more prompt words, the better.

The SD interface actually has corresponding prompts. How are tokens calculated? Generally speaking, one word is counted as one token, including English commas. For example, "castle" is counted as 2 tokens.

Teach you how to write prompt words with Stable Diffusion, the basic and advanced syntax of Stable diffusion prompt words

The fourth rule (note) is: use phrases instead of natural language descriptions as prompts. In the same scene as above, a loli girl stands by the castle. After translation, it will become: A loli girl stands by the castle

This is actually a natural language description, and it can also produce a picture. However, words like by the are actually not very useful, but they waste tokens and weights.

2. Prompt Word Weight Grammar

In SD, the default weight of each prompt word is 1. Although we can influence its weight by adjusting the position of the prompt word, this is too troublesome, so SD actually has a set of syntax for increasing/decreasing weights.

2.1 Bracket Enhancement

In SD, English parentheses () can be used to enhance the weight of the prompt word. One parenthesis can increase the weight by 1.1 times. A maximum of 3 parentheses can be added, which means 1.1 * 1.1 * 1.1 = 1.331 times the weight.

2.2 Braces enhancement?

This needs to be verified. It is said that English curly brackets { } can also be used to enhance the weight of the prompt word, which is equivalent to 1.05 times the weight. However, I tried it and the effect was not obvious, so I am not sure whether this syntax is effective in Qiuye SD.

Teach you how to write prompt words with Stable Diffusion, the basic and advanced syntax of Stable diffusion prompt words

2.3 Bracket lowering

Similar to parentheses, but square brackets [] are used to reduce the weight of the prompt word. One square bracket is 0.9 times the weight, and a maximum of 3 square brackets is 0.729 times the weight.

2.4 Parentheses directly enhance/lower (recommended)

This method is written as: (xxx: 1.5). The weight is after the colon. This setting method is recommended and looks more intuitive.

Teach you how to write prompt words with Stable Diffusion, the basic and advanced syntax of Stable diffusion prompt words

Note: I tried it and it also works without the parentheses, for example book:1.5

This method also has a shortcut key setting: first select the prompt word, then hold down the CTRL key, and use the up and down arrow keys to quickly adjust.

3. Advanced Grammar of Prompt Words

In addition to the basic grammar mentioned above, SD's prompt words also have some advanced gameplay.

3.1 Underline connection

Connecting two words with an underscore (_) can serve as a connection, making it easier for SD to see them as a whole. This syntax is very common in the prompt words of the Qiuye integration pack.

For example,

# Group A prompt words: plate, coffee, cake, # Group B prompt words: plate, coffee_cake,

In these two groups of prompt words, in group A, since coffee and cake are not connected, SD may return both coffee and cake when drawing, but group B returns coffee and cake.

Teach you how to write prompt words with Stable Diffusion, the basic and advanced syntax of Stable diffusion prompt words

3.2 Alternating Sampling

The syntax for alternating sampling is: [prompt1 | prompt2 | prompt3]

In this way, the first step of sampling will use prompt1, the second step will use prompt2, the third step will use prompt3, and the fourth step will use prompt1 again, and the cycle will be repeated in an alternating manner.

If you want to combine two or more things into one, such as a color gradient, this might be a solution worth trying.

Or give an example

# Group A prompt words 1girl,red hair,blue hair,wavy hair, # Group B prompt words 1girl,[red|blue|wavy] hair,

The comparison chart is as follows:

Teach you how to write prompt words with Stable Diffusion, the basic and advanced syntax of Stable diffusion prompt words

3.3 Proportional Sampling

Proportional sampling is a bit like the previous alternating sampling, but proportional sampling can be more refined!

The first method: prompt1, [prompt2: 0-1 value]. This method means that prompt2 will be used only after the sample value reaches the specified value.

The second method: prompt1, [prompt2:: 0-1 value]. This method has an additional colon compared to the first method, indicating that prompt2 will not be used after the sample value reaches the specified value.

The third method: [prompt1:prompt2: 0-1 value]. Assuming the value is 0.3, this method means that prompt1 is used for the first 30% of the sampling value, and prompt2 is used for the last 70%.

Regarding the use scenario of proportional sampling, it is actually suitable for merging multiple things together, but because it can be more refined, the output effect will be better, such asThis article[1]It mentions merging multiple faces into a new face. If you are interested, you can take a look.

Teach you how to write prompt words with Stable Diffusion, the basic and advanced syntax of Stable diffusion prompt words

Note: A fusion portrait of Trump and Biden

4. Preset styles of prompt words

Sometimes we write a set of good prompts and think we can use them again in the future. At this time, preset styles come in handy. Its function is to save the prompts so that we can reuse them directly next time.

5. Prompt Word Writing Plug-in

If you are using Akiba's SD, then its built-in prompt word plug-in can actually meet the needs of most people. Not only does it have a lot of prompt words, but the prompt words are also well categorized and have built-in translation, which is very convenient to use.

Teach you how to write prompt words with Stable Diffusion, the basic and advanced syntax of Stable diffusion prompt words

What should you do if you are using Linux or cannot use Akiba SD for other reasons? It is actually very simple, because Akiba SD also achieves the above effect by installing the prompt word plug-in. If you are using sd-webui, you can also achieve the same effect by installing the plug-in.

Prompt word plug-in address:https://gitcode.net/ranting8323/sd-webui-prompt-all-in-one/-/blob/main/README_CN.MD

 

statement:The content is collected from various media platforms such as public websites. If the included content infringes on your rights, please contact us by email and we will deal with it as soon as possible.
Encyclopedia

What exactly is AI? This article finally explains it all in plain language!

2024-6-2 10:27:37

Encyclopedia

How to use the Kuaishou KOLORS large model and test the function of Kuaishou AI product KOLORS

2024-6-3 9:47:41

Search