KLoRAStyleModel<T>

Models & Types · AiDotNet.Diffusion.StyleTransfer

K-LoRA Style model for composable style transfer by merging multiple LoRA style adapters.

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

For Beginners

K-LoRA lets you mix multiple artistic styles. Each style is a small add-on (LoRA adapter), and you can blend them — for example, 70% Van Gogh colors with 30% Picasso geometry. This gives you creative control over the final look.

How It Works

K-LoRA trains separate LoRA adapters for different style aspects (color, texture, composition) and merges them with adjustable weights. This enables mixing multiple styles with fine-grained control over each style’s contribution.

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 KLoRAStyleModel<float>(options: options))
    .Build(trainX, trainY);
var blended = result.Predict(input);

Constructors

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