UniVSTAdaInStylization<T>

Models & Types · AiDotNet.Diffusion.StyleTransfer

UniVST’s training-free AdaIN-guided localized stylization (Song et al., arXiv:2410.20084, TPAMI 2025), operating at BOTH the latent level and the attention level.

For Beginners

AdaIN restyles content by rescaling it to the style’s per-channel mean and spread. Doing it to the attention keys and values as well as the latent is what carries style into fine detail rather than just recolouring the whole frame.

How It Works

Acting at only one of the two levels is the obvious simplification and the paper argues against it: latent-level AdaIN alone injects colour statistics but loses localized detail, while attention-level alignment alone does not move the global appearance far enough.

The three operations run on different schedules, which is the substance of the method: latent AdaIN inside a narrow late window, query blending at EVERY timestep, and key/value AdaIN on a linear ramp.

Constructors

Constructor Summary
UniVSTAdaInStylization(UniVSTOptions options) Creates the stylization helper.

Methods

Method Summary
Tensor<T> AdaIn(Tensor<T> content, Tensor<T> style) Adaptive instance normalization: rescales content to style’s per-channel statistics.
Tensor<T> ApplyMask(Tensor<T> edited, Tensor<T> content, Tensor<T> mask) Mask gating: mask * edited + (1 - mask) * content, keeping the stylization local.
Tensor<T> BlendKeyValue(Tensor<T> editKv, Tensor<T> styleKv, double timestepFraction) Key/value blending on the ramp: beta_t * AdaIN(editKv, styleKv) + (1 - beta_t) * styleKv.
Tensor<T> BlendQuery(Tensor<T> editQuery, Tensor<T> contentQuery) Query blending, applied at EVERY timestep: gamma * editQuery + (1 - gamma) * contentQuery.
bool IsKeyValueAdaInActive(double timestepFraction) True when the key/value AdaIN ramp applies at the given fraction of T.
bool IsLatentAdaInActive(double timestepFraction) True when latent-level AdaIN applies at the given progress through the schedule, expressed as a fraction of T.
double BetaAt(double timestepFraction) beta at the given fraction of T: linear from BetaAtRampStart at the ramp start to BetaAtRampEnd at the ramp end, clamped to those values outside the ramp.

Fields

Field Summary
double Epsilon Guards the division when a channel is constant, so a flat channel passes through.