← Homepage
University of Toronto

Zero-shot style transfer and content/style probing

Independent content and style labels from Things objects × ArtBench styles. Linear probes on frozen ViT CLS tokens improve style retrieval relative to raw cosine kNN on late CLS.

Overview

We ask whether a linear map on frozen ViT CLS can improve artistic-style retrieval when raw cosine kNN on the same token does not.

Supervised, CLIP, BEiT3, DINOv3, and MAE: late CLS style Recall@1 is under 1%. A 256-D linear probe reaches about 88%.

Data: Things100 × ArtBench

We build a UCAST-style grid: object concepts from THINGS stylized into ArtBench artistic domains. Content and style labels are independent, so the same image can be queried for content retrieval or style retrieval.

5×5 content by style grid
5×5 content×style matrix (Starry Night, The Scream, Great Wave, Kandinsky, Seurat).

UCAST pipeline

The benchmark is a Cartesian product: 1,000 content photographs × 1,000 style paintings, stylized one pair at a time by style_transfer.py into ucast_things100_artbench1000/. That is 1,000,000 JPEGs.

Content and style pools

The 5×5 grid above is a display subset built from canonical paintings (Starry Night, The Scream, and so on) so the figure is readable. The probes never see it. Training and evaluation use the 1,000 ArtBench styles.

Inference

Framework is UCAST[1], but the forward pass is written out inside style_transfer.py rather than called through CAST_pytorch/test.py, since a million pairs makes per-image process launch the dominant cost. VGG-19 truncated to the first 31 layers (through relu4-1) encodes content and style. AdaIN then matches the content feature channel mean and standard deviation to the style feature mean and standard deviation at that layer, and the decoder (latest_net_Dec_B.pth) upsamples back to RGB. Weights are models/vgg_normalised.pth, checkpoints/UCAST_model/latest_net_AE.pth, and latest_net_Dec_B.pth.

Splits

dataset.py, seed 42. The instance split holds out 20% of the content image names per category, 2 of the 10. The style split holds out 20% of the style categories. This is what turns a million stylizations into a retrieval set: queries and gallery come from held-out content names or held-out styles, not from pairs the probe was fit on.

Method: dual CLS probes

Freeze a ViT-B/16. At each layer, map CLS h^(ℓ) ∈ ℝ^768 with two independent linear heads to L2-normalized 256-D content and style embeddings. Both heads train under a pairwise sigmoid focal loss: build the 512 × 512 cosine matrix for a batch, treat each off-diagonal entry as an independent same-class/different-class decision, and discount the pairs the probe already scores correctly.

Batches are square by construction, C = 32 classes × M = 16 images, so the positive count per batch is fixed rather than left to chance. Focal γ = 1.0 with α = 0.75 on the positive class, which is the minority here at roughly 33:1. Temperature and logit bias are learnable and used only during training; evaluation is zero-shot cosine kNN (Recall@1 / mAP). The α choice, the per-group count normalization, and why not InfoNCE are written up on the poster page: pairwise sigmoid focal loss.

CLS probing architecture
Dual content/style probes on frozen CLS features.

Results

Probes raise style Recall@1 / mAP relative to raw CLS. Higher probe dimensions help. Content retrieval is generally easier than style on this set.

Style mAP across layers
Style-split mAP (solid = probed, dashed = raw CLS).
Content mAP across layers
Content / instance-split mAP across layers and dimensions.

CLS vs patch / Gram

CLS vs patch style comparison
CLS vs patch pooling for style.
Gram vs CLS comparison
Gram-style features vs CLS probing.
Matrioshka study
Nested (Matrioshka) probe dimensions, style split.

Error structure

For incorrect style-probe neighbors, the fraction that stay in the query’s object category increases with probe dimension and depth.

Within-category incorrect heatmaps
Content and style within-category incorrect grids.
Style within-category poster heatmap
Style-probe panel: high means errors stay in-category; low means they leave it.

References

  1. Zhang et al., A Unified Arbitrary Style Transfer Framework via Adaptive Contrastive Learning, arXiv 2023.
  2. Hebart et al., THINGS: A database of 1,854 object concepts and more than 26,000 naturalistic object images, PLOS ONE 2019.
  3. Liao et al., The ArtBench Dataset: Benchmarking Generative Models with Artworks, arXiv 2022.