Logo

The Expert Guide to CFG Scale in Stable Diffusion (How to use it?)

The Expert Guide to CFG Scale in Stable Diffusion (How to use it?)

What is CFG scale in stable diffusion?

In Stable Diffusion, CFG stands for Classifier Free Guidance scale. CFG scale is a parameter that controls Stable Diffusion how 'strict' it should follow the prompt input in image generation. Lower CFG give the AI more freedom to be creative, while higher numbers force it to stick more to the prompt.

But this does not mean that you should use a larger CFG values in creating images. In fact, low values might produce more details and softer image but sometimes not include certain aspects of the prompt.High values are usually sharper, are more likely to include everything from the prompt but can have less details, especially things not in the prompt.

Should CFG scale be high or low?

The default CFG scale value in Stable diffusion WEB UI is 7, which gives a good balance between creative freedom and following your direction. But this does not mean that 7 is the best choice for all prompt words. We need to flexibly adjust the size of the CFG scale value according to the complexity of the prompt words.

So how to choose the best CFG scale value? Here is a basic guide:

  • CFG 2-6: Creative, but might be too distorted and not follow the prompt. Can be fun and useful for short prompts
  • CFG 7-10: Recommended for most prompts. Good balance between creativity and guided generation
  • CFG 10-15: When you're sure that your prompt is detailed and very clear on what you want the image to look like
  • CFG 16-20: Not generally recommended unless the prompt is well-detailed. Might affect coherence and quality
  • CFG > 20: almost never usable

The effect of different CFG scale on the same prompt

Case1: simple prompt

Prompt: (masterpiece:1.3), (absurdres:1.3), (best quality:1.3), (ultra-detailed:1.3),(best shadow:0.7), (handled hair), (sharp eyeliner, eyeshadow, detailed eyes:1.1), perfect anatomy, BREAK, 1girl, solo, RED HAIR, hair between eyes, GREEN EYES, glowing eyes, sailor collar, school uniform, side ponytail, sidelocks

cfg scale:1

cfg scale:1

cfg scale:4

cfg scale:4

cfg scale:7

cfg scale:7

cfg scale:10

cfg scale:10

cfg scale:13

cfg scale:13

cfg scale:16

cfg scale:16

cfg scale:19

cfg scale:19

cfg scale:22

cfg scale:22

cfg scale:25

cfg scale:25

cfg scale:28

cfg scale:28

  • CFG < 7: there are misaligned fingers in the image that I don't mention in the prompt.
  • 7 < CFG < 16: the images maintain good image quality.
  • CFG > 16: the lighting of the image begins to become dim, and the picture begins to become sharp

Case2: complicate prompt

Prompt: Hatsune Miku (vocaloid), gothic inflatable dark dress, closed eyes, (cyborg mask), inflatable shapes, (((wires, tubes, veins, electric arc, electric sparks))), white biomechanical details, ((wearing epic bionic cyborg implants)), masterpiece, intricate, biopunk, vogue, highly detailed, artstation, concept art, extremely detailed, beautiful, unreal engine 5, extremely detailed background

cfg scale:1

cfg scale:1

cfg scale:4

cfg scale:4

cfg scale:7

cfg scale:7

cfg scale:10

cfg scale:10

cfg scale:13

cfg scale:13

cfg scale:16

cfg scale:16

cfg scale:19

cfg scale:19

cfg scale:22

cfg scale:22

cfg scale:25

cfg scale:25

Compared with the previous case1, the prompt I entered this time is more complex, so at CFG=10~13, the picture quality is optimal. As the CFG value increases, the color of the picture becomes more inconsistent and the picture quality becomes sharper. When the CFG scale is 1~7, the pictures are chaotic and the picture quality is very poor.

Conclusion

The CFG scale in Stable Diffusion is a parameter for the user to control the 'strictness' of the AI's execution of prompt. The larger CFG scale you enter, the more you want the AI to follow your prompt. However we recommend keeping the CFG value between 7 and 10 to maintain a balance between the AI's 'imagination' and 'prompt instructions'. In one word, dynamically changing the CFG scale according to the complexity of the prompt words is the best way to generate perfect AI pictures.

Use Free Stablu Diffusion AI Online

GET STARTED FOR FREE

AnimeGenius Page Loading