InstaFlowModel<T>
Models & Types · AiDotNet.Diffusion.FastGeneration
InstaFlow model for one-step text-to-image via rectified flow straightening.
Inheritance: DiffusionModelBase<T> → LatentDiffusionModelBase<T> → InstaFlowModel<T>
For Beginners
Diffusion models follow curved paths from noise to images. InstaFlow first “straightens” these paths (making them nearly straight lines), then trains a model to jump from start to end in one step. It’s like straightening a winding road so you can drive directly to your destination instead of following curves.
How It Works
InstaFlow straightens the probability flow ODE paths of a pretrained diffusion model using the Reflow procedure, then distills the straightened model into a single-step generator. The straighter paths make single-step generation possible with minimal quality loss compared to multi-step generation.
Reference: Liu et al., “InstaFlow: One Step is Enough for High-Quality Diffusion-Based Text-to-Image Generation”, ICLR 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 InstaFlowModel<float>(options: options))
.Build(trainX, trainY);
var generated = result.Predict(noise);
Constructors
| Constructor | Summary |
|---|---|
InstaFlowModel(NeuralNetworkArchitecture<T> architecture, DiffusionModelOptions<T> options, INoiseScheduler<T> scheduler, UNetNoisePredictor<T> predictor, StandardVAE<T> vae, IConditioningModule<T> conditioner, int? seed) |
Initializes a new InstaFlow 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() |