ControlNetFluxModel<T>

Models & Types · AiDotNet.Diffusion.Control

ControlNet adapted for the FLUX.1 architecture with flow matching.

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

For Beginners

This brings ControlNet’s “follow my reference image” capability to FLUX models. FLUX uses a different internal architecture than Stable Diffusion, so this specialized version ensures control signals work correctly with FLUX.

How It Works

Adapts ControlNet conditioning for FLUX.1’s flow-matching diffusion framework with double-stream transformer blocks. Uses 16-channel latent space and rectified flow scheduling native to FLUX.

Example

// Create a ControlNet for FLUX.1 architecture
var options = new DiffusionModelOptions<float>
{
    LatentChannels = 16,
    DefaultInferenceSteps = 28
};
            
// Generate with edge-guided control
var edgeCondition = Tensor<float>.CreateRandom(new[] { 1, 1, 1024, 1024 });
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 ControlNetFluxModel<float>(options: options, controlType: ControlType.Canny))
    .Build(trainX, trainY);
var prediction = result.Predict(edgeCondition);

Constructors

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