getimg.ai
Pricing
Log in

Guide to Stable Diffusion CFG Scale Parameter

Optimize your Stable Diffusion results with the CFG scale (guidance scale). Learn the best practices for using guidance scale from our step-by-step guide.

Note:

This parameter is not available in AI Generator's Essential mode, which generates good results without adjustable parameters.

How does the guidance scale work?

Simply put, the CFG scale (classifier-free guidance scale) or guidance scale is a parameter that controls how much the image generation process follows the text prompt. The higher the value, the more the image sticks to a given text input.

But this does not mean that the value should always be set to maximum, as more guidance means less diversity and quality.

You can see it for yourself by moving the guidance scale slider below. It showcases the same generation of 'panda playing guitar' with different guidance values.

Guidance scale7

Notice how it behaves at the extremes; the text prompt is ignored when the guidance scale value is set to 1. It's strictly followed with a maximum of 20 but with worse image quality. The most 'creative' and 'artistic' results are usually generated around a guidance scale of 7-12. But using a scale up to 15 still produces results with little to no artifacts.

Recommendation:

Use the guidance scale value of 7-9. Increase when the generated image does not follow the prompt. Stay away from extremes of 1 and 20.

Setting the right value depends on your desired results and also the text prompt's complexity. The decision is yours, but it is always best to experiment with different scales to see whether more creative results or results strictly adhering to the prompt are better for your use case.

Let’s see a more complex example of generating an image of a 'biomechanical suit':

cfg: 7
cfg: 14
cfg: 17
cfg: 21

In this case, the prompt contains more words (see here). Some concepts from the prompt are more visible on the images with increased guidance. Notice, for example, how the suit has more details with a guidance scale of 17, emphasizing intricate inflatable shapes and some biopunk elements.

If you are trying to generate an image with more tiny details specified in the prompt, you can start with a higher guidance scale between 12 and 16.

We hope our guide helped you understand the CFG scale/guidance scale parameter in Stable Diffusion, and you'll use what you've learned to create something amazing.

Frequently Asked Questions

What is CFG scale in Stable Diffusion?

The guidance scale affects how much the image generation follows your text prompt.

What guidance scale should I use?

For a good mix of creativity and accuracy, start with a scale of 7-12. For detailed prompts, try a slightly higher range, like 12-16.

Why not use the highest guidance scale possible?

If set too high, the CFG scale can make the image less creative and lower its quality. It’s better to find a balance based on the desired results.