RADModel<T>

Models & Types · AiDotNet.Diffusion.ImageEditing

Region-Aware Diffusion (RAD) model for spatially controlled inpainting and editing.

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

For Beginners

RAD lets you edit different parts of an image with different instructions simultaneously. For example, you could change the sky to sunset while changing the ground to snow, all in one generation pass.

How It Works

RAD enables region-specific control during diffusion by applying different text prompts to different spatial regions. Each region can have its own prompt and guidance scale, allowing fine-grained multi-region editing in a single pass using SD1.5 backbone.

Technical specifications:

  • Base model: Stable Diffusion 1.5 inpainting
  • Text encoder: CLIP ViT-L/14 (768-dim)
  • Input channels: 9 (4 latent + 4 masked image latent + 1 mask)
  • Region control: Per-region prompts and guidance scales
  • Multi-region editing in single denoising pass

Example

var options = new DiffusionModelOptions<float> { LatentChannels = 4, DefaultInferenceSteps = 30 };
var input = Tensor<float>.CreateRandom(new[] { 1, 4, 64, 64 });
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 RADModel<float>(options: options))
    .Build(trainX, trainY);
var prediction = result.Predict(input);

Constructors

Constructor Summary
RADModel(NeuralNetworkArchitecture<T> architecture, DiffusionModelOptions<T> options, INoiseScheduler<T> scheduler, UNetNoisePredictor<T> predictor, StandardVAE<T> vae, IConditioningModule<T> conditioner, 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()