ConsisLoRAModel<T>

Models & Types · AiDotNet.Diffusion.StyleTransfer

ConsisLoRA model for consistent style transfer using LoRA with content-style disentanglement.

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

For Beginners

ConsisLoRA creates reliable style adapters that transfer only the style (colors, brushstrokes, textures) without changing the content. Multiple images generated with the same ConsisLoRA will have a consistent visual style.

How It Works

ConsisLoRA improves LoRA-based style transfer by explicitly disentangling content and style information during LoRA training. Uses consistency regularization to ensure style features are captured in the LoRA weights while content features pass through.

Example

var options = new DiffusionModelOptions<float> { LatentChannels = 4, DefaultInferenceSteps = 25 };
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 ConsisLoRAModel<float>(options: options))
    .Build(trainX, trainY);
var stylized = result.Predict(input);

Constructors

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