ControlNetInpaintingModel<T>
Models & Types · AiDotNet.Diffusion.Control
ControlNet Inpainting model with mask-aware conditioning.
Inheritance: DiffusionModelBase<T> → LatentDiffusionModelBase<T> → ControlNetInpaintingModel<T>
For Beginners
This model erases part of an image (marked by a mask) and fills it in with new content that matches a control signal. For example, you could erase a person from a photo and use an edge map to guide what replaces them.
How It Works
Specialized ControlNet for inpainting that takes both a control image and a binary mask as input. The mask indicates which regions to regenerate while the control signal guides the structure of the inpainted content.
Example
// Create a ControlNet inpainting model
var options = new DiffusionModelOptions<float>
{
LatentChannels = 4,
DefaultInferenceSteps = 30
};
// Inpaint masked regions guided by a control image
var imageWithMask = Tensor<float>.CreateRandom(new[] { 1, 5, 64, 64 }); // 4 latent + 1 mask
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 ControlNetInpaintingModel<float>(options: options, controlType: ControlType.Canny))
.Build(trainX, trainY);
var prediction = result.Predict(imageWithMask);
Constructors
| Constructor | Summary |
|---|---|
ControlNetInpaintingModel(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() |