Guidance scale
Guidance scale or Classifier-Free Guidance (CFG) is a parameter that controls the adherence of the generated image to the text prompt. A higher guidance scale will force the image to be more aligned with the prompt, while a lower guidance scale will give more space for Stable Diffusion to decide what to put into the image.
Here is a sample of applying a different guidance scale while keeping other parameters the same:
import torch generator = torch.Generator("cuda:0").manual_seed(123) prompt = """high resolution, a photograph of an astronaut riding a horse on mars""" image_3_gs = text2img_pipe( Â Â Â Â prompt = prompt, Â Â Â Â num_inference_steps = 30, Â Â Â Â guidance_scale = 3, Â Â Â Â generator = generator ).images[0] image_7_gs = text2img_pipe( Â Â Â Â prompt = prompt, Â Â Â Â num_inference_steps = 30, Â Â Â Â ...