June 16, 2025
Building image classification models remains cumbersome in data-scarce domains, where collecting large labeled datasets is impractical. In-context learning (ICL) is a promising paradigm for few-shot image classification (FSIC), but prior work has underexplored the relative importance of encoder pretraining versus fusion-layer training data. We present PictSure, a vision-only ICL family of models that demonstrates the potential of easy-to-use fusion transformer architectures, as well as the need for better embedding representations across a wider range of image domains. In both in-domain and out-of-domain evaluations, we find that representation quality induced by pretraining strongly correlates with downstream ICL performance. Crucially, varying the training dataset for the fusion transformer, from ImageNet alone to diverse multi-domain mixtures, provides limited additional performance gains under the evaluated settings, demonstrating that the fusion layer appears capable of adapting effectively once embeddings are sufficiently structured. These results show that the bottleneck in visual ICL is representation quality, not fusion-module training diversity. To facilitate adoption and reproducibility, we release all model weights as open-source artifacts and provide an MCP server that exposes PictSure as a callable tool for LLM-based agentic systems, enabling few-shot image classification to be invoked directly within AI pipelines without integration overhead. Code can be found at <https://github.com/PictSure> and models at <https://huggingface.co/pictsure>.
Collecting large labeled datasets is impractical in many real-world domains such as medical imaging or agriculture, where expert annotation is costly and privacy constraints may apply [1]–[4]. Few-shot image classification (FSIC) addresses this by enabling models to recognize unseen classes from only a handful of examples [5]. In-context learning (ICL) is a particularly attractive paradigm for FSIC: a transformer is provided with labeled support image-label pairs alongside a query, and predicts the query label without any parameter updates at inference time [6], [7]. This eliminates costly fine-tuning and supports immediate deployment across changing task definitions.
Existing visual ICL work, such as CAML [7] and SgVA-CLIP [8], rely on CLIP-based encoders whose language-grounded representations struggle with fine-grained or domain-shifted categories [9]. Prior work has largely overlooked a more fundamental question: how much does the choice of encoder and its pretraining strategy determine ICL performance? Evidence that a linear probe on strong embeddings can outperform sophisticated meta-learners [10] suggests representation quality may be the dominant factor.
We present PictSure, a set of vision-only ICL models designed to tackle this question. To isolate the effect of image encoding on the downstream ICL task, we keep the fusion architecture fixed and systematically vary the encoder and pretraining objective, comparing a supervised ResNet [11] pretrained on ImageNet-21k [12], a contrastive CLIP encoder [9], and a self-supervised DINOv2 [13]. Our central findings are twofold. First, the encoder and its pretraining matter far more than the training set of the ICL transformer itself: models without pretrained encoders fail to converge, while a well-pretrained encoder enables strong in-domain and out-of-domain transfer. Second, expanding the number and diversity of training datasets for the fusion transformer yields negligible gains. The fusion layer learns to read the embedding space from ImageNet alone, demonstrating how readily the ICL transformer adapts once representations are well-structured. This confirms that the bottleneck is not the fusion module’s exposure to diverse tasks, but the quality of the embedding space, suggesting that better representations that improve class separability are a key lever for performance gains. The main contributions are: (1) PictSure, a transformer-based vision-only in-context learner requiring no fine-tuning or language supervision; (2) a systematic study showing encoder pretraining quality is the dominant performance driver in visual ICL; (3) competitive out-of-domain results on medical benchmarks (Brain Tumor, OrganCMNIST), demonstrating the advantage of purely visual embeddings for domain generalization; (4) a fully open-source baseline for future FSIC research, providing a clean, reproducible foundation for studying transformer-based fusion layers under varying encoder designs, including an MCP server that exposes PictSure as a tool for agentic systems to perform few-shot image classification directly within AI pipelines.
FSIC and ICL. An alternative paradigm is ICL which eliminates parameter updates by conditioning on a demonstration set \(\mathscr{D} = \{(x_i, y_i)\}_{i=1}^{m}\) provided at inference time to predict the label of a query [6]: \[F_\theta: (\mathscr{D}, x_q) \rightarrow \hat{y_q}\] Prior work such as CAML [7] extends this paradigm to vision by leveraging CLIP-based encoders to perform ICL over images. However, these approaches inherit a key limitation of language-aligned representations: they often fail to preserve fine-grained visual distinctions and degrade under domain shift, as textual descriptions provide only weak supervision for subtle inter-class differences [7], [9].
PictSure Architecture. Each support image \(x_i\) is encoded by a frozen visual encoder \(\phi_{\text{img}}\) into \(v_i \in \mathbb{R}^d\); its one-hot label \(y_i\) is projected by \(\phi_{\text{lbl}}\) into \(\ell_i \in \mathbb{R}^d\). These are concatenated into a joint token \(t_i = [v_i;\, \ell_i]\); the query uses \(t_q = [v_q;\, \vec{0}]\). The ICL transformer \(\mathcal{T}\) then processes the full sequence under an asymmetric mask: support tokens attend to each other freely, the query attends to all support tokens, but support tokens cannot attend to the query—mirroring meta-inference without mutual contamination. The output query representation is classified via: \[\hat{y_q} = f_{\text{cls}}\!\left(\mathcal{T}([t_1, \dots, t_m, t_q])\right) \in \mathbb{R}^n\] The transformer uses four blocks, eight attention heads, and model dimension 1024. The broad architecture is illustrated in Figure 1. Models are trained on 10-way 5-shot episodes sampled from ImageNet-21K [12] (10,000 episodes per epoch, images at \(224{\times}224\)).
We evaluate three embedding backbones integrated into PictSure, varying only the encoder (with frozen weights) and projection while keeping the ICL transformer architecture the same. ResNet [11] is a supervised convolutional network trained on ImageNet1K using standard classification objectives. CLIP [9] is a Vision Transformer trained via contrastive alignment on 400 million image–text pairs, with its image encoder frozen during integration. DINOv2 [13] is a ViT trained through self-distillation and masked-image modeling on 142 million images without any labels. Across all settings, pretrained and frozen encoders prove necessary for consistent convergence and strong few-shot performance.
We study two fusion-transformer training configurations that vary only in the composition of the training data. The ImageNet setting trains exclusively on ImageNet-21K [12], the standard pretraining corpus used in prior work.
The Default setting replaces this with a multi-domain mixture of sixteen datasets spanning diverse visual categories: ILSVRC-2012 [14] (20%), Places365 [15] (10%), VGGFace2 [16] (10%), Products10K [17] (10%), LEGO Parts [18] (10%), Food-101 [19] (5%), SD-198 [20] (5%), ChestX [21] (5%), Cars196 [22] (5%), WildlifeReID-10K [23] (5%), EuroSAT [24] (4%), PlantVillage (2.5%), Fruits-360 [25] (2.5%), HAM10000 [26] (2%), Oxford Flowers [27] (2%), and KAU-BCMD [28] (2%). This mixture deliberately spans general, fine-grained, medical, agricultural, and remote-sensing imagery to test whether broader domain coverage during fusion training improves out-of-domain generalization.
We evaluated the performance of our PictSure model variations across a diverse range of visual domains. Both in-domain and out-of-domain datasets, comprising general, agricultural, and medical imagery were used for the evaluation, namely tieredImageNet [29], PlantDoc [30], Brain Tumor Classification (MRI) dataset [31], and OCTMNIST [32]. All evaluations use 5-way \(k\)-shot tasks with \(k \in \{1, 5\}\), averaged over 2000 episodes per dataset and reported as mean accuracy \(\pm\) standard error.
Baselines. We compare multiple variants of PictSure against several established baselines. First, we include the representation learning baseline of [10], consisting of a pretrained embedding network followed by a task-specific linear classifier trained on support embeddings (RFS). Second, we consider the method of [33], which combines large-scale pretraining, ProtoNet-based meta-training, and task-specific fine-tuning (PMF). We further include CAML [7], a CLIP-based approach to few-shot learning. In addition, we evaluate the multimodal model Qwen3.5 122B in a pure ICL setting, where the model receives \(m\) support image–label pairs and a query (images resized to \(224 \times 224\)) without parameter updates. All methods are evaluated on 5-way 1-shot and 5-way 5-shot tasks. We report mean accuracy and standard error across episodes. Figure 2 summarizes the results. As a supervised baseline, we train a multilayer perceptron (MLP) directly on the pre-computed embeddings. The network consists of an input projection layer followed by four residual blocks, each comprising two fully-connected layers with batch normalization, ReLU activations, and dropout, with a linear output head. To match the evaluation protocol of our primary method, we repeatedly sample random subsets of 10 classes from each dataset (200 runs per dataset) and train a separate MLP on each subset. Models are optimized with AdamW using a linear learning rate decay schedule and early stopping.
Encoder quality appears to be one of the strongest factors influencing PictSure’s performance. DINOv2 and CLIP variants consistently outperform the ResNet-based variant across all benchmarks, most clearly on tieredImageNet and PlantDoc in both shot settings. These results support the hypothesis that strong representations may contribute more to performance than increased adaptation complexity in the evaluated setting. The fusion transformer showed limited sensitivity to training-data composition across the evaluated datasets. The Default and Imagenet settings yield nearly identical results in our experiments, suggesting ImageNet-21K-style supervision is sufficient for learning support–query interaction and that further gains are more strongly associated with representation quality than data diversity. The exception is ResNet-50, which shows a modest sensitivity to training data composition. We hypothesize that this is because ResNet’s global-average-pooled representations carry less structural information than ViT patch tokens, leaving the fusion module with a less separable embedding space to work from; in that regime, exposure to more varied training tasks may partially compensate for the representational deficit, whereas with a strong encoder the fusion layer benefits less from additional diversity. PictSure’s relative performance depends on the target domain. It is highly competitive on tieredImageNet and particularly strong on PlantDoc, where DINOv2 variants outperform RFS, PMF, and CAML. On OCTMNIST and Brain Tumor it remains competitive, though PMF, RFS, and Qwen3.5 can match or exceed it. PictSure demonstrates competitive cross-domain transfer performance, with its clearest advantages on natural-image benchmarks. With CLIP embeddings frozen, PictSure remains relatively consistent across domains, whereas CAML shows a clear drop on the medical datasets, despite using the same encoder models. Thus, the main difference between adaptation methods appears to be robustness to domain shift rather than absolute performance gains. The supervised MLP baseline reinforces this: its strong performance confirms that pretrained embeddings already contain substantial task-relevant information. Beyond accuracy, PictSure offers a favorable efficiency profile, substantially smaller than CAML and Qwen3.5 while remaining competitive across benchmarks, with advantages over RFS and PMF in transfer performance, lightweight fusion, and stable inference.
Our results support an encoder-centric perspective on visual ICL design. The fusion transformer learns quickly and reliably once embeddings are well-structured, while changes in fusion complexity or training data provide only limited gains when representations are weak. Representation quality appears to be the limiting factor, not the transformer’s ability to perform support-query fusion.
This points to a clear path forward: if ICL transformers already act as robust readers of embedding spaces, further gains are to be found in building better visual representations through stronger pretraining objectives, better encoder architectures, and improved encoder-task alignment under distribution shift.
To lower the barrier to adoption, we release an MCP server exposing PictSure as a callable tool for agentic systems, enabling few-shot image classification within AI pipelines without integration overhead. Future work should prioritize representation learning at scale while keeping the fusion module lightweight, including improved pretraining curricula, broader encoder families, and extended class coverage beyond the current 10-way setup.
These authors contributed equally to this work.↩︎