RescaledCFG<T>

Models & Types · AiDotNet.Diffusion.Guidance

Rescaled Classifier-Free Guidance to prevent over-saturation.

Implements: IGuidanceMethod<T>

For Beginners

When you use a very high guidance scale, images can become oversaturated with unnaturally bright colors. This fix automatically adjusts the brightness back to normal while keeping the guidance effect.

How It Works

Rescales the guided noise prediction to match the standard deviation of the conditional prediction. This prevents the color saturation and contrast blowout that occurs at high CFG scales (e.g., > 10).

Reference: Lin et al., “Common Diffusion Noise Schedules and Sample Steps are Flawed”, 2023

Constructors

Constructor Summary
RescaledCFG(double rescaleWeight) Initializes a new Rescaled CFG instance.

Properties

Property Summary
GuidanceType GuidanceType { get; }

Methods

Method Summary
Tensor<T> Apply(Tensor<T> unconditional, Tensor<T> conditional, double scale, double timestep)