SenseFlowModel<T>

Models & Types · AiDotNet.Diffusion.FastGeneration

SenseFlow model for accelerated flow-matching generation via knowledge distillation.

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

For Beginners

Flow-matching models like FLUX generate amazing images but need 20+ steps. SenseFlow is a distilled version that captures the same quality in 4-8 steps by learning to take “bigger strides” along the generation path, like a student who learns shortcuts from a thorough teacher.

How It Works

SenseFlow accelerates flow-matching models (like FLUX) through a combination of progressive distillation and feature alignment. Maintains the straight-path ODE formulation while reducing the number of steps needed from 20-50 to 4-8.

Reference: SenseTime, “SenseFlow: Accelerated Flow-Matching Generation”, 2024

Example

var options = new DiffusionModelOptions<float> { LatentChannels = 16, DefaultInferenceSteps = 6 };
var noise = Tensor<float>.CreateRandom(new[] { 1, 16, 128, 128 });
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 SenseFlowModel<float>(options: options))
    .Build(trainX, trainY);
var generated = result.Predict(noise);

Constructors

Constructor Summary
SenseFlowModel(NeuralNetworkArchitecture<T> architecture, DiffusionModelOptions<T> options, INoiseScheduler<T> scheduler, FluxDoubleStreamPredictor<T> predictor, StandardVAE<T> vae, IConditioningModule<T> conditioner, int? seed) Initializes a new SenseFlow 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()