Guide to Stable Diffusion guidance scale parameter

How to use guidance scale in Stable Diffusion.

Simply put, the guidance scale (sometimes referred as cfg - classifier free guidance) is a parameter that controls how much the image generation process follows the text prompt. The higher the value, the more 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.

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

Notice how it behaves at the extremes; the text prompt is ignored when the guidance scale value is set to 1. With a maximum of 30, it's strictly followed but with worse image quality (even though, in this case, it achieves the best proportions of guitar to panda). The most 'creative' and 'artistic' results are usually generated around a guidance scale of 7. But using a scale up to 20 still produces results with little to no artifacts.

Recommendation: Use the default guidance scale value of 7. Increase when the generated image does not follow the prompt. Stay away from extremes of 1 and 30.

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 more complex example for generating an image of 'biomechanical suit':

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

The prompt, in this case, contains more words (see here). Some concepts from the prompt are more visible on the images with increased guidance. Notice, for example, how with a guidance scale of 17, the suit has more details, 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 19.

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