# Sampling Methods

Hello all and welcome to an in-depth look at a few sampling methods we have available within RunDiffusion. In this guide we will go over each sampling method and a visual aid from steps 10 all the way to 150.

What is sampling?

Stable Diffusion initiates the image production process by generating a fully random image within the latent space. Subsequently, the noise predictor estimates the image's noise, which is then subtracted from the image. This iterative procedure is reiterated multiple times, resulting in a refined image, free from noise.

The denoising process, known as sampling, entails the generation of a fresh sample image at each step by Stable Diffusion. The technique employed during this sampling process is referred to as the sampler or sampling method.

Sample Overview

At this time on /05/26/23 we have 7 samplers available on RunDiffusion.

1. Euler A
Euler ancestral (Euler a) sampler bears resemblance to Euler's sampler, but it deviates in the way it handles noise subtraction and addition. At each step, Euler a subtracts an excess amount of noise and introduces a certain degree of random noise to align with the noise schedule. The denoised image outcome is contingent upon the specific noise introduced during preceding steps. Consequently, it can be regarded as an ancestral sampler, as the denoising trajectory relies on the unique random noises incorporated at each iteration. If the process were to be repeated, the outcome would differ.
2. LMS
Similar to Euler's method, the linear multistep method (LMS) is a widely recognized technique for solving ordinary differential equations (ODEs). It strives to enhance accuracy by leveraging the values from previous time steps in a strategic manner. In the case of AUTOMATIC1111, it utilizes up to 4 previous values as the default configuration for the LMS solver. By incorporating this historical information, AUTOMATIC1111 aims to improve the precision and effectiveness of its ODE-solving capabilities.

3. DPM++ 2S a, DPM++ 2M, DPM++ 2S a Karras, DPM++ 2M Karras

DPM samplers, short for Diffusion Probabilistic Model Solvers, form a recently developed family of solvers specifically designed for diffusion models within AUTOMATIC1111. This family includes the following solvers:

DPM2: Known as DPM-Solver-2 - this solver offers accuracy up to the second order.

DPM2 Karras: This variant of DPM2 employs the Karras noise scheduler while remaining otherwise identical in functionality.

DPM2 a: DPM2 a is almost identical to DPM2, with the distinction that it introduces noise at each sampling step, transforming it into an ancestral sampler.

DPM2 a Karras: Similar to DPM2 a, this variant incorporates the Karras noise schedule while retaining the other characteristics of DPM2 a.

In addition to the DPM solvers mentioned above, there are improved versions known as DPM++ samplers, which build upon the foundations of the original DPM solvers.

4. DDIM

Denoising Diffusion Implicit Models (DDIM) stands out as one of the pioneering samplers designed for resolving diffusion models. Its underlying concept revolves around approximating the image at each step by combining three key components.

-Final image: This represents the ultimate denoised image obtained upon completing all the steps.

-Image direction: It indicates the direction pointing to the image at the current step.

-Random noise: This element introduces variability and randomness to the image generation process.

A question arises: How can we anticipate the final image even before reaching the last step? DDIM addresses this by approximating the final image using the denoised image. Similarly, the image direction is approximated by leveraging the noise estimated by the noise predictor. By employing these approximations, DDIM ensures a coherent and effective denoising process.

## Samplers/Steps

Below is a sample image I created using Euler A at 40 steps on the Crystal-Clear FX Model. I have used the seed in every sampler and step count in the guide.

Generation Details:

Prompt:
(hyperrealism :1.2), (award winning:1.4) masterpiece photo BREAK beautiful witch in her magical cabin of spells  BREAK (8K UHD:1.2), (photorealistic:1.2), render, realism, accurate, characters, details, crystal clear, render, photorealistic, nature, art, realism, accurate, cinematic, photography, realistic, intricate detail, style art, landscape, characters, details, crystal clear, perfect face, ultra sharp, masterpiece, highly detailed, highly accurate, awe-inspiring, award-winning, sharp focus, intricate, dramatic lighting, 8k, UHD, HDR, Photorealism, HD Quality, 8k resolution, Unreal Engine, Realistic, Refined, Cinematic Lighting, octane render, post production, 3D, cinema4D

Negative Prompt:
text, error, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, artist name, b&w, weird colors, cartoon, 3d, bad art, poorly drawn, close up, blurry, lowres

Resolution:
640x360
Seed:
1446417654
CFG:11.5
Steps:N/a

## PixelPirate

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to .