This post will explain in detail negative prompts and how to use them in Stable Diffusion.
- What are Negative Prompts?
- How do Negative Prompts Work?
- What are Some Use Cases of Negative Prompts?
- How to Use Negative Prompts Effectively?
What are Negative Prompts?
A negative prompt is a feature that instructs the Stable Diffusion model on what to leave out of the resulting image. It is usually entered in a separate input box below the positive prompt, which is the text that describes what you want to see in the image. Users can install it locally by following the official link or can utilize its functionalities via the web user interface.
How do Negative Prompts Work?
Stable Diffusion works by beginning with a noisy canvas and gradually denoising it to get at the end outcome. It uses a sampler algorithm that compares the generated image after each step with the positive prompt and adds some changes to the noise until it matches the text description. The negative prompt acts as a constraint that prevents the sampler from adding anything that contradicts the negative text.
Example 1: Create a Cat Image Without Stripes
If users want to generate an image of a “cat”, but users do not want it to have any stripes, use the following prompts:
Positive prompt: a cat
Negative prompt: stripes
The negative prompt guides the generation process to avoid creating any stripes on the cat’s fur, and produce an image like this:
If the negative prompt is “stripes”, the sampler will not add any stripe-like patterns to the noise. The output shows the image of a cat without stripes.
Example 2: Modify an Existing Image Using Negative Prompt
The negative prompt can also be used to modify existing images by using them as an initial canvas instead of noise. This way, users can remove or change some aspects of the original image according to the negative text. For example, if users have “a cat with a hat”:
Now, if users want to remove the hat, upload the image by pressing the “img2img” button and use the following prompts:
Positive prompt: A cat
Negative prompt: hat
The negative prompt guides the generation process to erase the hat from the cat’s fur, and produce an image like this:
The output shows that image of a cat without a hat in the interface.
What are Some Use Cases of Negative Prompts?
Negative prompts are utilized for different purposes, such as:
- Removing undesirable elements from a picture. For example, if users want to generate an image of a landscape, and do not want any buildings or people in it, use a negative prompt like “buildings, people”.
- Changing the style or mood of an image. For example, if users want to generate an image of a sunset, but do not want it to be too bright or warm, use a negative prompt like “bright, warm”.
- Fixing some artifacts or abnormalities in an image. For example, if users want to generate an image of a face, but do not want it to have any deformities or extra limbs, use a negative prompt like “deformed, extra limbs”.
- Fine-tuning the details or features of an image. For example, if users want to generate an image of a flower, and do not want it to have any thorns or spots, use a negative prompt like “thorns, spots”.
How to Use Negative Prompts Effectively?
There are some tips and tricks that can help users to use negative prompts more effectively and get better results:
- Use specific and descriptive words for the negative prompts. For example, instead of using “bad” or “ugly”, use words that describe what makes something bad or ugly for you.
- Use multiple words for the negative prompts separated by commas. This will increase the chances of removing or changing everything that you do not want in the image.
- Use weights for the negative prompts by adding a colon and a number after each word. This will adjust the importance or strength of each word in influencing the generation process.
- Experiment with different negative prompts and see how they affect the output. Sometimes adding or removing one word can make a significant difference in the quality or style of the image.
Conclusion
In Stable Diffusion, negative prompts are a powerful feature that can help to create more customized and refined images from text descriptions. They allow users to specify what they do not want to see in the generated image and guide the generation process to avoid or remove them. They can be utilized for diverse purposes such as removing unwanted objects or elements.