ControlNeXtModel<T>

Models & Types · AiDotNet.Diffusion.Control

ControlNeXt model with improved efficiency and generalization.

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

For Beginners

ControlNeXt is a newer, more efficient version of ControlNet. It uses a smarter design that requires fewer parameters and less memory while working just as well (or better) at following control signals.

How It Works

ControlNeXt improves upon ControlNet by using a more parameter-efficient architecture with cross-normalization layers instead of a full encoder copy. This reduces memory usage while improving generalization across different control types.

Reference: Peng et al., “ControlNeXt: Powerful and Efficient Control for Image and Video Generation”, 2024

Example

// Create a ControlNeXt model for efficient spatial control
var options = new DiffusionModelOptions<float>
{
    LatentChannels = 4,
    DefaultInferenceSteps = 20
};
            
// Guide image generation with a depth map
var depthMap = Tensor<float>.CreateRandom(new[] { 1, 1, 512, 512 });
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 ControlNeXtModel<float>(options: options, controlType: ControlType.Depth))
    .Build(trainX, trainY);
var generated = result.Predict(depthMap);

Constructors

Constructor Summary
ControlNeXtModel(NeuralNetworkArchitecture<T> architecture, DiffusionModelOptions<T> options, INoiseScheduler<T> scheduler, UNetNoisePredictor<T> baseUNet, StandardVAE<T> vae, IConditioningModule<T> conditioner, ControlType controlType, int? seed)

Properties

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

Methods

Method Summary
ModelMetadata<T> GetModelMetadata()