OSDSModel<T>

Models & Types · AiDotNet.Diffusion.FastGeneration

One-Step Diffusion via Shortcut (OSDS) model for single-step high-quality generation.

Inheritance: DiffusionModelBase<T> → LatentDiffusionModelBase<T> → OSDSModel<T>

For Beginners

Most diffusion models need many steps to turn noise into an image. OSDS learns a “shortcut” — a direct path from noise to image in just one step. Think of it like learning both the scenic route (multi-step) and a highway (one-step) to the same destination. You can choose speed or quality depending on your needs.

How It Works

OSDS learns a shortcut function that directly maps noise to clean data in a single forward pass. Unlike distillation approaches, it trains a dedicated shortcut path that bypasses the iterative denoising process entirely. The shortcut is learned alongside the standard diffusion trajectory, enabling both one-step and multi-step generation from the same model.

Reference: Frans et al., “One Step Diffusion via Shortcut Models”, 2024

Example

var options = new DiffusionModelOptions<float> { LatentChannels = 4, DefaultInferenceSteps = 1 };
var noise = Tensor<float>.CreateRandom(new[] { 1, 4, 64, 64 });
var trainX = Tensor<float>.CreateRandom(4, 8);
var trainY = Tensor<float>.CreateRandom(4, 2);
var result = new AiModelBuilder<float, Tensor<float>, Tensor<float>>()
    .ConfigureModel(new OSDSModel<float>(options: options))
    .Build(trainX, trainY);
var generated = result.Predict(noise);

Constructors

Constructor Summary
OSDSModel(NeuralNetworkArchitecture<T> architecture, DiffusionModelOptions<T> options, INoiseScheduler<T> scheduler, UNetNoisePredictor<T> predictor, StandardVAE<T> vae, IConditioningModule<T> conditioner, int? seed) Initializes a new OSDS model with optional configuration.

Properties

Property Summary
IConditioningModule<T> Conditioner { get; }
INoisePredictor<T> NoisePredictor { get; }
IVAEModel<T> VAE { get; }
int LatentChannels { get; }

Methods

Method Summary
ModelMetadata<T> GetModelMetadata()