Stable Diffusion (beyond prompting1) p.3

Wassimgouia
4 min readAug 18, 2023

--

Before showing another advanced feature of Stable Diffusion Make sure to see the previous blog posts.

Stable Diffusion (Basics) p.1:

Stable Diffusion (Prompting and Beyond) p.2 :

To get the most out of your prompting I will be covering what’s called “The XYZ Plot” but first let’s talk about how stable diffusion models actually generate images, it uses a denoising process that generates an image that is literally a random noise based on the seed value you provide than afterward it will try to take a portion of the noise away from the original noisy image by guessing based on your text prompts.

And each time it takes a noise from the noisy image that step is called the sampling step following the sampling Method you chose:

After a certain number of sampling Steps, we will get the final output image that we perceive according to what is described in the prompt and in general: The more Sampling Steps = The more time the image takes to generate. and the more sampling steps = the higher the quality and details of the image.

the sampling steps and sampling method are synchronized together so depending on the Sampling Method you don’t necessarily need high sampling steps to get a respected quality image.

So let’s cover the Sampling Methods:

And the sampling Method is just a way to calculate the noise that is to be taken away from the original noisy image, Some sampling methods require more steps to take away enough noise to generate a decent image and some need fewer steps For example:

The LMS Method:

takes 150 steps to generate a high-quality image

while

Euler a Method:

can take 50 steps and generate a high-quality image

note: some Samplers run relatively faster than others.

Also one more thing :
Batch size :

it means how many images to generate.

Batch size :

it means how many images to generate at once.

Finally, before jumping to the XYZ plot let’s cover

the seed number:

The seed in stable diffusion is an initializer number for the generation of the image. You aren’t required to provide the number yourself, as it’s randomly generated when not specified. However, managing the seed can assist in generating consistent images, testing different parameters, or prompting diverse variations.

The XYZ plot:

So the XYZ plot is a script in stable diffusion that allows you to test different variables and generate comparison images based on those variables you provided.

let’s take an example of an image I already generated:

Prompt:

a goddess of Ireland with a Beautiful face, clear skin, blue eyes, a cute little smile, and red hair, Wearing green Clothes, and a green hat in her head, Portrait mode, highly detailed clothes, 8k

Negative Prompt:

ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, extra limbs, disfigured, deformed, body out of frame, bad anatomy, watermark, signature, cut off, low contrast, underexposed, overexposed, bad art, beginner, amateur, distorted face, blurry, draft, grainy

The other parameters

this is the final result of the Photo generation:

And the model used for this generation is dreamshaper_6BakedVae

I will Cover on another blog the different models and my personal favorite.

and this is the XYZ plot script:

Before showing the final result let’s talk more about other properties of the XYZ plot :

1- Draw Legend :

It indicates the value of a particular image (Like its title)

2- Include Sub Images :

Allow viewing of the generated images individually after the completion of the generation, with this option turned off, you can only preview them in the preview window and you will

3- Keep -1 for Seeds :

To keep a fresh random seed for the generation of the image

4- Include Sub Grids :

Takes the generated grids XYZ plot and allows you to view them individually.

5- Grid Margins (px) :

allows you to specify the spacing with pixels between your images.

And the final Results look like this :

ZOOM IN FOR A CLEARER VIEW

Here’s another example(with the same prompt and model):

we using the XYZ to show the different sampling methods with 50 sampling steps

ZOOM IN FOR A CLEARER VIEW

Conclusion :

we can see that the smaller the CFG scale is the fewer the sampling steps you need to generate a decent image while the bigger the CFG scale is the more it requires sampling steps to generate high-quality images.

--

--