NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

FS-DETR: Few-Shot DEtection TRansformer with prompting and without re-training

Adrian Bulat, Ricardo Guerrero, Brais Martínez, Georgios Tzimiropoulos

Abstract

FS-DETR is a novel transformer-based framework for Few-Shot Object Detection (FSOD) that eliminates the need for test-time fine-tuning or re-training. By treating visual templates of novel objects as "prompts" and utilizing pseudo-class embeddings, the model can detect multiple new classes in a single forward pass. FS-DETR introduces visual prompting with "stamping" and Multi-Head Cross-Attention in the encoder to achieve state-of-the-art performance among non-re-training methods, often rivaling or exceeding fine-tuning-based approaches in low-shot scenarios.

Introduction

Standard object detection models are typically "closed-set," limited to recognizing only the specific categories they encountered during training. Few-Shot Object Detection (FSOD) seeks to overcome this limitation, enabling a model to detect "novel" classes (e.g., a rare animal species) given only a few example images, or templates.

Practical FSOD systems must meet three key criteria: they should require no re-training (for immediate deployment), offer flexibility to handle an arbitrary number of classes simultaneously, and maintain high accuracy. While many existing methods rely on fine-tuning, this process is slow and computationally intensive. FS-DETR addresses these challenges by reframing detection as a visual prompting task within a transformer architecture, allowing for high-performance detection without any on-the-fly parameter updates.

Methodology

FS-DETR is built upon the Conditional DEtection TRansformer (DETR) architecture and introduces two primary innovations: visual prompting with "stamping" and early feature filtering via Multi-Head Cross-Attention (MHCA).

Visual Prompting and Stamping

Instead of relying solely on learnable object queries, FS-DETR takes the visual features of novel templates and prepends them to the decoder's queries. To ensure the network can distinguish between different classes, each template is "stamped" with a pseudo-class embedding. These embeddings act as class-agnostic signatures, allowing the transformer layers to track which template belongs to which class throughout the decoding process.

Overview of the FS-DETR architecture showing the integration of visual prompts, pseudo-class embeddings, and the encoder-decoder structure.

Early Filtering and Pre-training

The authors added a Multi-Head Cross-Attention (MHCA) layer to the encoder. This allows the target image features to be filtered by the templates early in the pipeline, highlighting regions that match the objects of interest before they reach the decoder.

To overcome the data-hungry nature of transformers, the model undergoes an unsupervised pre-training stage. Using Selective Search to generate object proposals from unlabeled datasets like ImageNet-100 and MSCOCO, the model learns a universal "matching" function—the ability to locate a cropped patch within a larger image—which is fundamental for generalizable few-shot detection.

Experiments and Results

The model was evaluated on standard FSOD benchmarks, including PASCAL VOC (splits 1, 2, and 3) and MSCOCO.

On PASCAL VOC, FS-DETR set a new state-of-the-art for methods that do not require re-training, outperforming previous benchmarks by up to 17.8 AP50 points. Notably, in extreme low-shot scenarios (1 or 2 examples), FS-DETR often outperformed methods that do utilize fine-tuning. On the more challenging MSCOCO dataset, the model improved 1-shot performance by 1.1 to 3.1 AP50 points over the previous best non-re-training methods.

Performance comparison on PASCAL VOC. FS-DETR (Ours) consistently outperforms other non-re-training methods across all novel sets and shot counts.

Key Insights

  • Detection as Prompting: Reframing detection as a prompting task, similar to Large Language Models, allows the model to use visual examples as dynamic instructions.
  • Universal Matching: By training on "pseudo-classes" rather than fixed categories, the model learns a general matching function that generalizes to unseen object types.
  • The Power of Early Filtering: Ablation studies highlighted that the MHCA layer in the encoder is critical for performance, as it focuses the model's attention on relevant regions early in the process.

Conclusion

FS-DETR provides a highly efficient and accurate solution for few-shot detection without the overhead of re-training. Its ability to process multiple novel classes in a single forward pass makes it uniquely suited for real-time applications in robotics and mobile computing. While challenges like semantic misalignment and query convergence remain, FS-DETR represents a significant step forward in flexible, open-set object detection. Future work may involve integrating natural language prompts to further enhance the system's discriminative power.

Summary updated

BibTeX
@inproceedings{bulat2022fs,
  author = {Adrian Bulat and Ricardo Guerrero and Brais Martínez and Georgios Tzimiropoulos},
  title = {{FS-DETR: Few-Shot DEtection TRansformer with prompting and without re-training}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2022},
}
Figure