ControlNetPlusPlusModel<T>

Models & Types · AiDotNet.Diffusion.Control

ControlNet++ model with improved conditioning via reward-guided training.

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

For Beginners

ControlNet++ is a better version of ControlNet that follows your control images (edges, depth, poses) more accurately. It was trained with a smarter method that teaches it to match control signals more faithfully.

How It Works

ControlNet++ improves upon ControlNet by using reward-guided training that produces more consistent and higher-quality control signal adherence. It supports multiple control types simultaneously with better composability.

Reference: Li et al., “ControlNet++: Improving Conditional Controls with Efficient Consistency Feedback”, ECCV 2024

Example

// Create a ControlNet++ model with reward-guided training
var options = new DiffusionModelOptions<float>
{
    LatentChannels = 4,
    DefaultInferenceSteps = 30
};
            
// Generate image with improved control adherence
var edgeMap = 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 ControlNetPlusPlusModel<float>(options: options, controlType: ControlType.Canny))
    .Build(trainX, trainY);
var prediction = result.Predict(edgeMap);

Constructors

Constructor Summary
ControlNetPlusPlusModel(NeuralNetworkArchitecture<T> architecture, DiffusionModelOptions<T> options, INoiseScheduler<T> scheduler, UNetNoisePredictor<T> baseUNet, StandardVAE<T> vae, IConditioningModule<T> conditioner, ControlType controlType, double rewardWeight, int? seed) Initializes a new ControlNet++ 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()