StyleAlignedModel<T>
Models & Types · AiDotNet.Diffusion.Control
Style-Aligned model for consistent style across multiple generated images.
Inheritance: DiffusionModelBase<T> → LatentDiffusionModelBase<T> → StyleAlignedModel<T>
For Beginners
When you generate multiple images, this model makes them all look like they belong to the same “art collection” — same colors, same style, same artistic feel. It’s like having one artist draw several different scenes.
How It Works
Style-Aligned uses shared self-attention across multiple generated images during the denoising process to ensure consistent style. This enables generating sets of images that share the same artistic style without explicit style transfer.
Reference: Hertz et al., “Style Aligned Image Generation via Shared Attention”, CVPR 2024
Example
// Create Style-Aligned model for consistent style across batches
var options = new DiffusionModelOptions<float>
{
LatentChannels = 4,
DefaultInferenceSteps = 30
};
// Generate multiple images with consistent artistic style
var noise = Tensor<float>.CreateRandom(new[] { 4, 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 StyleAlignedModel<float>(options: options))
.Build(trainX, trainY);
var styledBatch = result.Predict(noise);
Constructors
| Constructor | Summary |
|---|---|
StyleAlignedModel(NeuralNetworkArchitecture<T> architecture, DiffusionModelOptions<T> options, INoiseScheduler<T> scheduler, UNetNoisePredictor<T> baseUNet, StandardVAE<T> vae, IConditioningModule<T> conditioner, double styleAlignmentStrength, int? seed) |
Initializes a new Style-Aligned model. |
Properties
| Property | Summary |
|---|---|
IConditioningModule<T> Conditioner { get; } |
|
INoisePredictor<T> NoisePredictor { get; } |
|
IVAEModel<T> VAE { get; } |
|
int LatentChannels { get; } |
Methods
| Method | Summary |
|---|---|
ModelMetadata<T> GetModelMetadata() |