Crowd-SAM: SAM as a Smart Annotator for Object Detection in Crowded Scenes

Zhi Cai, Yingjie Gao, Yaoyan Zheng, Nan Zhou, Di Huang · DOI

Abstract

Object detection in crowded environments presents significant challenges due to high annotation costs and the "part-whole" ambiguity where models struggle to distinguish between individual components and complete objects. We present Crowd-SAM, a framework that repurposes the Segment Anything Model (SAM) into a high-efficiency "smart annotator." By integrating a few-shot learning approach with a semantic-aware prompt sampler and a specialized discrimination network, Crowd-SAM achieves performance comparable to fully supervised state-of-the-art models using as few as 10 labeled images. Our results demonstrate that the synergy between SAM's geometric precision and DINOv2's semantic richness can effectively address the complexities of dense scene analysis.

Introduction

Detecting objects in crowded scenes—such as busy urban intersections or packed stadiums—is a cornerstone of modern computer vision, yet it remains notoriously difficult. Two primary hurdles impede progress in this area. First, the annotation cost is prohibitive; manually labeling hundreds of overlapping objects per image can take over 40 seconds per instance. Second, foundation models like SAM often suffer from part-whole ambiguity. In dense crowds, SAM frequently segments a sub-part (e.g., a limb or a head) instead of the entire body. Furthermore, the computational expense of running SAM's automatic mask generator on dense grids often leads to a high rate of false positives.

Crowd-SAM addresses these issues by leveraging the geometric precision of SAM alongside the semantic richness of DINOv2, creating a system that learns to identify and segment objects accurately with minimal human intervention.

Methodology

The Crowd-SAM framework introduces three core innovations to transform SAM into a robust detector for crowded scenes:

1. Self-Prompting via DINOv2

To eliminate the need for manual clicks, Crowd-SAM utilizes a frozen DINOv2 backbone equipped with a lightweight learnable adapter. This setup generates a "semantic heatmap" that identifies foreground regions likely to contain objects of interest (e.g., pedestrians). This heatmap guides the prompting process, ensuring that the model focuses its computational resources on relevant areas.

2. Efficient Prompt Sampler (EPS)

Standard automatic mask generation often relies on a brute-force grid of prompts, which is inefficient in dense scenes. The EPS module dynamically prunes prompts: if a sampled prompt successfully generates a high-quality mask, any subsequent prompts falling within that mask's boundaries are discarded. This drastically reduces redundant computations while maintaining high recall.

3. Part-Whole Discrimination Network (PWD-Net)

The PWD-Net serves as the framework's decision-making core to resolve occlusion and segmentation errors. It combines SAM’s internal tokens (Mask and IoU tokens) with DINOv2’s semantic features to evaluate candidate masks. By learning to distinguish between a complete object and a fragment, PWD-Net selects the mask with the highest "wholeness" and Intersection over Union (IoU), effectively solving the part-whole ambiguity problem.

Crowd-SAM is trained in a few-shot manner, requiring only a handful of labeled images to fine-tune its lightweight adapters while the heavy foundation models (SAM and DINOv2) remain frozen.

Experimental Results

The researchers evaluated Crowd-SAM across several challenging benchmarks, including CrowdHuman, CityPersons, OccHuman, and COCO.

Performance in Crowded Scenes

On the CrowdHuman dataset, Crowd-SAM achieved an 78.4% Average Precision (AP) using only 10 labeled images. This performance is remarkably close to fully supervised models such as ATSS (80.3%) and FCOS (76.3%), which require thousands of labeled examples. In the few-shot regime, Crowd-SAM outperformed the previous state-of-the-art (De-FRCN) by a significant 32% AP margin.

Robustness to Occlusion

In tests on the OccHuman dataset, which focuses on heavily occluded figures, Crowd-SAM surpassed the fully supervised Pose2Seg model by 9.2% AP. This demonstrates the framework's superior ability to handle overlapping objects and maintain structural integrity in complex visual fields.

Discussion and Insights

The success of Crowd-SAM highlights several key insights for the future of foundation models in specialized tasks:

  • Synergy of Foundation Models: SAM provides the "how" (geometric segmentation), while DINOv2 provides the "what" (semantic context). Their combination is more powerful than either model used in isolation.
  • Smart Sampling over Dense Sampling: The EPS module proves that intelligent pruning is more effective than dense grid prompting for maintaining high recall without an explosion of false positives.
  • Selection vs. Generation: Often, SAM does generate the correct mask among its multiple outputs. The challenge lies in selection. PWD-Net shifts the focus from better mask generation to better mask evaluation.

Limitations and Future Work

Despite its strengths, Crowd-SAM has limitations. Its reliance on window-cropping for small object detection can increase inference time. Additionally, while extensible to multi-class detection (as shown on COCO), the framework's primary optimizations were centered on pedestrians. Future work will focus on expanding the framework to a wider variety of object classes and improving inference speeds to move beyond offline "smart annotation" toward real-time deployment.

Summary updated

BibTeX
@inproceedings{cai2024crowd,
  author = {Zhi Cai and Yingjie Gao and Yaoyan Zheng and Nan Zhou and Di Huang},
  title = {{Crowd-SAM: SAM as a Smart Annotator for Object Detection in Crowded Scenes}},
  booktitle = {European Conference on Computer Vision},
  year = {2024},
  doi = {10.1007/978-3-031-72890-7\_20},
}
Figure