What Is Stable Diffusion CFG Scale – AI Tool’s Addition

Liam Miller Liam Miller
Aug 03, 2023 (Updated: Aug 03, 2023)Filed to: AI Tools

Stable Diffusion is an AI photo generator that is entirely free and open source. Seeing its rapid growth, there are many settings in this tool. For example, the CFG scale in Stable Diffusion. But many people still do not know what this setting is and how to use it when generating images. Well, find out more about the CFG scale in Stable Diffusion by reading this post.

Part 1: What Is CFG Scale in Stable Diffusion

CFG or Classifier Free Guidance scale is the setting that contributes to the nearest result of the input prompts. For a more elaborate explanation, putting a greater CFG scale value will result in a closer resemblance to the prompt, but it will be distorted in quality. Meanwhile, this can be done otherwise, with a higher quality in exchange.

The default CFG scale value is set at 7 to balance the creative freedom and the direction. On the other hand, a value of 1 will likely allow Stable Diffusion to have freedom, while a value of 15 and above will have restrictions. Although the AI image generator limits CFG from 1 to 30 at the maximum, you can set the scale at 999 in Stable Diffusion, both negative and positive, via the Terminal.

It may sound like a straightforward setting, but the AI image generator will make it harder to control with the tradeoffs from various CFG values. But to use the scale most effectively, you can follow the demonstration below on how to use it on Stable Diffusion.

Part 2. How to Use CFG Scale in Stable Diffusion

In this demonstration, you can start experimenting with CFG on DreamStudio or Playground. However, there are more options available for you, such as the Stable Diffusion Online Demo, full Stable Diffusion Web UI, or a minimal setup on RunPod.io.

Step 1.Visit DreamStudio, Lexica, or Playground AI and sign up. Lexica does not require users to sign up, but the other two platforms require a Gmail or Discord account. Once you are in, enter the text in the prompt box.

Step 2.Click the "Generate" button once you have settled with the prompts. Depending on the platform you use, DreamStudio will have CFG Scale, while Lexica has Guidance Scale. On the other hand, you can find Prompt Guidance on Playground AI on the right part of the interface.

How to CFG Scale

Step 3.Adjust the parameter according to your liking. Remember that between 7 and 11 values have more optimal output usually. But it still depends on your requirement, so take your time with the experimentation until you have the best result.

How to CFG Prompt Guidance

Part 3. Comparison of Different CFG Scale Images

How do you see the differences for every adjustment on the CFG scale? The changes are visible to the output, especially if you are jumping from a small value to a larger one. Even if you are only using one platform, the difference will tell the distortion and quality with a few tweaks. To demonstrate, here are some pictures from Stable Diffusion and CFG scale:

CFG Scale Difference

The prompt used in this picture is Portrait of Tom Cruise in the Stable Diffusion prompts of red suit, high quality, 4K. It is generated in Stable Diffusion with specific CFG values. As a result, the similarity of the image to the input prompt is more visible.

There are also some things you can see for the different values. Color saturation and contrast are increased as the CFG scale value is added. But on another point, just above the default value will put the output image to a blurrier quality, resulting in detail loss.

If you want to avoid low-quality results, there are two things you can do. First, increase the sampler steps. But since it is the same with CFG, sampler steps can create longer processing time. If the first method is not a favor for you, you can change the samplers to generate better image details, even at a greater value than 7. Here are more sample images upscaled to 4K for certain CFG scale values.

CFG Images

Bonus Tips: How to Enlarge Stable Diffusion CFG Images

If you don’t want to do more tweaking on Stable Diffusion, then another way to have high-quality AI photos is to use AnyRec AI Image Upscaler. It is an online tool with the power of AI technology, supporting popular image formats, such as PNG, BMP, JPEG, GIF, and more. With its intuitive interface, you can increase the Magnification level of a photo at 2x, 4x, 6x, and 8x maximum values. It will automatically recover the detailed loss in downloading, including pixels, colors, textures, etc. This is the solution for enlarging pictures, suitable for printing, graphic designing, and social media sharing.

Step 1.Click the "Upload Photo" button and choose the picture from your device.

AnyRec Upload Photo

Step 2.Choose the Magnification level; check the details with the Zoom function.

AnyRec Magnification

Step 3.Click the "Save" button when satisfied to download the final result.

AnyRec Save New Image

Part 4: FAQs about CFG Scale in Stable Diffusion

Conclusion

CFG scale in Stable Diffusion is used to control the closeness of the image result to the input prompt. While platforms like DreamStudio, Lexica, and Playground AI are more effective in experimenting with the setting, you can also set the Stable Diffusion CFG scale higher value and use AnyRec AI Image Upscaler to enlarge the size and recover the details in one click.

Related Articles: