SwiftBrushModel<T>

Models & Types · AiDotNet.Diffusion.FastGeneration

SwiftBrush model for image-free one-step text-to-image distillation.

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

For Beginners

Most distillation methods need real images to train the fast model. SwiftBrush skips this entirely — it trains using only the teacher model’s knowledge, like a student learning to draw by watching the teacher correct their work, without needing reference images. The result is a one-step generator.

How It Works

SwiftBrush distills a diffusion model into a single-step generator without using any real images during training. The student generates a latent, which the frozen teacher denoises to provide a training signal. This “image-free” approach avoids dataset licensing issues and simplifies the training pipeline.

Reference: Nguyen et al., “SwiftBrush: One-Step Text-to-Image Diffusion Model with Variational Score Distillation”, CVPR 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 SwiftBrushModel<float>(options: options))
    .Build(trainX, trainY);
var generated = result.Predict(noise);

Constructors

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

Properties

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

Methods

Method Summary
ModelMetadata<T> GetModelMetadata()