Project 05
AdaIN Style Transfer: Arbitrary Neural Style Transfer with Adaptive Instance Normalization
A from-scratch AdaIN implementation that transfers arbitrary artistic styles in one feed-forward pass, at 150 ms per 512 px image on a single T4.
- 2026
- Python
- PyTorch
- VGG-19
- AdaIN
- +2

Context
Problem
Iterative style transfer can take minutes per image, and feed-forward alternatives need a separate network for every style. A practical system has to handle an arbitrary style image in one pass, without a style-specific model.
Reading
Research & prior art
- 01
Gatys et al. (2015), “A Neural Algorithm of Artistic Style,” arXiv.
Gatys framed style transfer as an optimisation over pixels using VGG feature statistics. It is the quality reference, but it takes minutes per image and has to optimise from scratch for every content-style pair.
- 02
Johnson et al. (2016), “Perceptual Losses for Real-Time Style Transfer and Super-Resolution,” ECCV.
Johnson replaced the per-image optimisation with a feed-forward network trained on a perceptual loss. It is fast, but each network is tied to one style, so arbitrary style means training a new network per style.
- 03
Huang & Belongie (2017), “Arbitrary Style Transfer in Real-time with Adaptive Instance Normalization,” ICCV.
AdaIN aligns the mean and variance of content features to the style features, so one decoder handles an arbitrary style in a single pass. That is the paper we implemented.
- 04
Ulyanov et al. (2016), “Instance Normalization: The Missing Ingredient for Fast Stylization,” arXiv.
Instance normalisation is the operation AdaIN generalises. It removes per-image contrast statistics that would otherwise leak the content's style into the output.
- 05
Dumoulin et al. (2017), “A Learned Representation for Artistic Style,” ICLR.
Conditional instance normalisation showed that one network can cover many styles by conditioning the normalisation. AdaIN removes the learned per-style parameters and uses the style image's statistics directly.
Trade-offs
Approaches compared
Gatys optimisation
- Strengths
- Highest flexibility: any content, any style, no training. The loss is direct and easy to reason about.
- Limits
- Minutes per image, and the optimisation is pair-specific, so it cannot support a real-time or video path.
- Verdict
- The quality reference, not the deployment path.
Johnson feed-forward network
- Strengths
- One forward pass at inference; much faster than optimisation.
- Limits
- One network per style. Arbitrary style means retraining, which is the cost we wanted to avoid.
- Verdict
- A good real-time baseline, but not arbitrary.
AdaIN
- Strengths
- One decoder, arbitrary style, 150 ms per 512×512 image on one T4 after warm-up, and an α interpolation parameter at inference.
- Limits
- Quality is below per-pair optimisation. The batch-8 and batch-32 comparison is confounded by GPU count, and the video path is frame-by-frame.
- Verdict
- The right cost/flexibility trade for this project. I would not claim it matches optimisation quality.
Method
Approach
- 01
Use a frozen VGG-19 encoder up to relu4_1; align the content feature statistics to the style statistics with AdaIN, and train only the decoder.
- 02
Train on MS-COCO content images and WikiArt style images with the content and style losses from the original paper, including the four-layer style loss and a style weight of 10.
- 03
Run the final configuration for 40,000 iterations at batch size 32 on two T4 GPUs, scaling the learning rate and using DataParallel across both.
- 04
Persist the decoder, optimizer state, and loss history to a Hugging Face repository at every checkpoint, then resume from the highest checkpoint when an ephemeral Kaggle session ends.
- 05
Benchmark a 512×512 forward pass on one T4 after warm-up with torch.cuda.synchronize(), and expose the α interpolation parameter at inference.
Contribution
What I personally built
- I implemented the AdaIN encoder and decoder from scratch: frozen VGG-19 to relu4_1, the AdaIN alignment, and the decoder trained with the content and style losses.
- I owned the 2×T4 DataParallel runs, the batch-8/32/64 comparisons, checkpointing to Hugging Face, and resume after ephemeral Kaggle sessions.
- I wrote the 512×512 inference benchmark with warm-up and torch.cuda.synchronize(), and the α interpolation path.
- The team shared the literature study and the report; the AdaIN implementation and training runs were my part.
Evidence
Results
150 ms
Inference time
512×512 image, one T4, measured after warm-up
15 to 30 FPS
Expected video throughput
256 px frames, planned extension, not measured



Reflection
What I would do differently
The batch-8 and batch-32 comparison was confounded: batch 8 ran on one GPU and batch 32 on two, so I cannot attribute the quality difference to batch size. I would hold the hardware fixed, train closer to the paper's 160,000 iterations, and evaluate with a perceptual or user study instead of loss curves alone. The video path is still frame-by-frame, so temporal flicker remains unaddressed.