RBModulationModel<T>
Models & Types · AiDotNet.Diffusion.StyleTransfer
RB-Modulation model for training-free style transfer via reference-based attention modulation.
Inheritance: DiffusionModelBase<T> → LatentDiffusionModelBase<T> → RBModulationModel<T>
For Beginners
RB-Modulation is a “plug and play” style transfer — no training needed. Just provide a style image and a content image, and it transfers the style by cleverly manipulating the attention patterns inside the model. Works with any pre-trained diffusion model.
How It Works
RB-Modulation enables style transfer without any training or fine-tuning by modulating self-attention layers using features extracted from the style reference image. Style features replace content features at specific attention layers during generation.
Reference: Rout et al., “RB-Modulation: Training-Free Personalization of Diffusion Models using Stochastic Optimal Control”, 2024
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 RBModulationModel<float>(options: options))
.Build(trainX, trainY);
var personalized = result.Predict(input);
Constructors
| Constructor | Summary |
|---|---|
RBModulationModel(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() |