RefinerStage<T>

Models & Types · AiDotNet.Diffusion.Alignment

Refiner stage for late-stage noise-add-then-denoise detail improvement.

For Beginners

Imagine you’ve painted a picture but want to add more detail. The refiner slightly blurs the image (adds noise), then carefully sharpens it back. This re-processing enhances fine details like skin texture, fabric patterns, and small objects that the main generation pass might have missed.

How It Works

The refiner stage takes a nearly-finished generated image, adds a small amount of noise back, and re-denoises using a specialized refiner model (or the same model with different conditioning). This late-stage refinement enhances fine details, textures, and overall coherence. Used in SDXL’s two-stage pipeline and other multi-stage generation approaches.

Reference: Podell et al., “SDXL: Improving Latent Diffusion Models for High-Resolution Image Synthesis”, ICLR 2024 (refiner stage)

Constructors

Constructor Summary
RefinerStage(IDiffusionModel<T> refinerModel, double strength, double guidanceScale, int refinerSteps) Initializes a new refiner stage.

Properties

Property Summary
double GuidanceScale { get; } Gets the classifier-free guidance scale for the refiner.
double Strength { get; } Gets the noise strength for refinement (0.0 = no change, 1.0 = full re-generation).
int RefinerSteps { get; } Gets the number of denoising steps the refiner uses.

Methods

Method Summary
T ComputeRefinementDelta(Vector<T> beforeRefinement, Vector<T> afterRefinement) Computes the refinement quality improvement estimate.
Vector<T> AddNoiseForRefinement(Vector<T> cleanLatent, Vector<T> noise) Adds noise to a latent at the specified strength level.
int GetStartTimestep(int totalTimesteps) Computes the starting timestep for the refiner based on strength.