ControlARModel<T>

Models & Types · AiDotNet.Diffusion.Control

ControlAR model combining autoregressive generation with spatial control.

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

For Beginners

While standard ControlNet works with diffusion models, ControlAR brings the same “follow my reference image” capability to autoregressive (token-based) image generators, bridging the two main approaches to image generation.

How It Works

ControlAR adapts ControlNet-style spatial conditioning for autoregressive image generation models. It enables token-level control where spatial conditions are mapped to discrete token sequences for AR model consumption.

Reference: Li et al., “ControlAR: Controllable Image Generation with Autoregressive Models”, 2024

Example

// Create a ControlAR model for edge-guided image generation
var options = new DiffusionModelOptions<float>
{
    LatentChannels = 16,
    DefaultInferenceSteps = 30
};
            
// Generate an image guided by an edge map
var edgeMap = Tensor<float>.CreateRandom(new[] { 1, 1, 256, 256 });
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 ControlARModel<float>(options: options, controlType: ControlType.Canny))
    .Build(trainX, trainY);
var prediction = result.Predict(edgeMap);

Constructors

Constructor Summary
ControlARModel(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()