The purpose
Have you ever felt that the images you generate with Stable Diffusion WebUI don’t quite match your vision, or that you wish you could give more specific instructions? The AI image generation process relies heavily on the quality of the prompts (or ‘spells’) you provide.
Prompt engineering is the art of optimizing these instructions to the AI to get the results you want. This article will show you how to write better prompts to efficiently create higher-quality images.
Basic Principles
Prompt engineering, in simple terms, is the skill of giving optimal instructions to a generative AI (like Stable Diffusion) so that it can accurately understand your intent. The AI “creates” an image based on your words, but the direction of that “creativity” can change dramatically depending on the prompt.
Key Points for Effective Prompts:
- Clarity: Be specific about what you want to draw, avoiding vague or ambiguous phrases.
- Prioritization: Since AI models tend to focus on keywords at the start of a prompt, describe the most important elements first.
- Quality Instructions: Remember to add keywords to improve the overall quality of your generated image.
Choosing Keywords
A prompt isn’t just a list of words. It’s crucial to arrange keywords with a proper structure, as they serve as a ‘blueprint’ for the AI’s image generation.
Keywords for enhancing image quality
To boost the quality of the images you generate, put the following keywords at the start of your prompt. Think of these as a universal language for telling the AI you want a high-quality result.
masterpiece
best quality
ultra detailed
intricate detail
high resolution
8k
Description of the theme, characteristics, artistic style, and background.
Next, you will describe the specific content you want to create. The basic method is to list the keywords, separated by commas.
- Subject:
1girl
,cat
,mountain landscape
etc. - Subject’s characteristics:
long blonde hair
,blue eyes
,wearing a school uniform
etc. - Style / Artistic Style:
digital art
,photo-realistic
,anime style
,oil painting
etc. - Environment and Background:
outdoors
,cityscape
,cherry blossoms
,night with stars
etc.
Examples of Art Style/Style Descriptions
digital art
watercolor painting
oil painting
anime style
photo-realistic
fantasy art
pixel art
Tips for Using Negative Prompts
Negative prompts are a very powerful tool for telling the AI what you don’t want in your image. Setting them correctly can dramatically reduce common issues like corrupted images or unwanted elements (such as weird hands, blur, or watermarks), leading to much higher-quality results.
You’ll find a dedicated negative prompt field in the Stable Diffusion WebUI, located just below the main prompt input box.
Commonly used negative prompts include: low quality, worst quality, bad anatomy, bad hands, deformed, blurry, out of focus, duplicate, watermark, signature, text, ugly, disgusting, easynegative, ng_deepnegative_v1_75t
easynegative
and ng_deepnegative_v1_75t
are pre-compiled lists of negative prompts created by the community. Using just one of them can effectively prevent multiple undesirable features from appearing in your image.
Forge provides a dedicated template for Negative Prompts.
Emphasis/attenuation
To strongly emphasize a specific keyword or, conversely, reduce its influence, you can use prompt weighting syntax.
Emphasis: ((keyword))
or (keyword:1.X)
Example: ((sparkling eyes))
(You can also use a specific number, like 1.1 or 1.2.)
The more parentheses you add or the higher the number you use above 1.0, the more the keyword will be emphasized.
Attenuation: (keyword:0.X)
Example: (too much light:0.7)
By specifying a number less than 1.0, you can reduce the keyword’s effect.
These syntaxes are helpful for making small adjustments when the AI isn’t generating the elements you want, or if it makes them too prominent.
Changing prompts ([A:B:C])
When you want to express complex scenes, the passage of time, or changes in a state, prompt blending (or switching) is a very useful technique.
syntax:[keywordA:keywordB:step]
- It will gradually transition from keyword A to keyword B.
- The
step
value can be a ratio of the total generation steps or a specific step count. Example:[day:night:0.5]
→ The prompt transitions from ‘day’ to ‘night’ at the halfway point of the generation process.します。- 例:
[day:night:0.5]
→ 生成プロセスの半分で「day」から「night」に切り替わる。
- 例:
Example: A person walking in a [sunny forest:dark forest:0.5] with [green leaves:autumn leaves:0.7]
This is an extremely powerful technique, but predicting the results can be counter-intuitive, so it often requires some trial and error.
Result
I have explained the prompt syntax for generating higher-quality images with Stable Diffusion.
comment