So you have generated a few Stable Diffusion AI images. They looked great but not quite what you want? You can use some customization. Here’s a primer for the basic generation parameters.
Table of Contents
Stable Diffusion Software
We will focus on Stable Diffusion AI. While some parameters mentioned in this article are available in free online AI generators, all of them are available in this popular Stable Diffusion GUI (AUTOMATIC1111). See my quick start guide for setting up in Google Colab.
CFG Scale
Classifier Free Guidance scale is a parameter to control how much the model should respect your prompt.
1 – Mostly ignore your prompt.
3 – Be more creative.
7 – A good balance between following the prompt and freedom.
15 – Adhere more to prompt.
30 – Strictly follow the prompt.
Below are a few examples of increasing the CFG scale with the same random seed. In general, you should stay away from the two extremes – 1 and 30.
Recommendation: Starts with 7. Increase if you want it to follow your prompt more.
Sampling steps
Quality improves as the sampling step increases. Typically, 20 steps with the Euler sampler is enough to reach a high-quality, sharp image. Although the image will change subtly when stepping through to higher values, it will become different but not necessarily of higher quality.
Recommendation: 20-30 steps. Adjust to higher if you suspect quality is low.
Sampling methods
There’s a variety of sampling methods you can choose, depending on what GUI you are using. They are simply different methods for solving diffusion equations. They are supposed to give the same result but could be slightly different due to numerical bias. But since there’s no right answer here – the only criterion is the image looks good, the accuracy of the method should not be your concern.
Not all methods are created equal. Below are the processing times of various methods.
Below are images produced after 20 steps with different sampling methods. Many of them are similar, but some of them can be quite different.
There are discussions in the online community claiming that certain sampling methods tend to yield particular styles. This is without theoretical merit.
My starting point is 20 steps of DPM++ 2M Karras.
Recommendation: DPM++ 2M Karras
Seed
The random seed determines the initial noise pattern and, hence, the final image.
Setting it to -1 means using a random one every time. It is useful when you want to generate new images. On the other hand, fixing it would result in the same images in each new generation.
How do you find the seed used for an image if you use a random seed? In the dialog box, you should see something like:
Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 4239744034, Size: 512×512, Model hash: 7460a6fa
Copy this seed value to the seed input box. If you generate more than one image at a time, the seed value of the second image is incremented by 1, and so on. Alternatively, click the recycle button to reuse the seed from the last generation.
Recommendation: Set to -1 to explore. Fix to a value for fine-tuning.
Image size
The size of the output image. Since Stable Diffusion v1 is trained with 512×512 images, deviating from it too much could cause issues such as duplicating objects. Leave it as square whenever possible. 512×768 (portrait) or 768×512 (landscape) are still okay.
Recommendation: Set the image size as 512×512. Otherwise, 512×768 or 768×512. (For v1 models)
Batch size
Batch size is the number of images generated each time. Since the final images are very dependent on the random seed, it is always a good idea to generate a few images at a time. This way, you can get a good sense of what the current prompt can do.
Recommendation: Set batch size to 4 or 8.
Summary
In this article, we have covered the basic parameters for Stable Diffusion AI. Check out this article for a step-by-step guide to building high-quality prompts. Check out this article for more advanced prompting techniques.
Finally am explanation for all this stuff! Well written in bite sized chunks! Thanks!
Thank you Andrew, you have wonderful articles, very clear lessons. And thank you for sharing your knowledge with others, it is worthy of respect.
Thank you for your kind words!
Thank you very much for clear, easy to understand explanations and recommendations.
Thanks a lot!
Great article!
Could you please also explain the “Batch count” slider and the “Tiling” and “Hires.fix” check boxes?
Many Thanks!
I have an article on Automatic1111 that has some explanations on these.
https://stable-diffusion-art.com/automatic1111/
This is an excellent article and it has been extremely useful for me.