Counting objects in crowded scenes, where classical computer vision breaks down. The model runs entirely in your browser — nothing is uploaded anywhere.
Drop a crowded photo here, or
A street, a shelf, a crowd — the more objects, the more interesting.
Or try one of these held-out test images (34, 33 and 29 objects).
Starting…
A detector tuned for ordinary scenes suppresses real objects in crowded ones: non-maximum suppression removes overlapping boxes on the assumption that overlap means duplication, which is wrong in a crowd. So the method measures crowding first — with a cheap Canny edge-density test — and only then relaxes the detector's confidence floor and NMS threshold.
The gate deliberately uses edge density rather than the detector's own count: if the detector has already missed the crowd, its count cannot be the evidence that a crowd is there.
All four methods scored in one run on the same 50 held-out COCO val2017 test images (5–50 objects each), same metric definitions, same device. Seed 1337.
| Method | Type | Mean IoU | Count acc. (±3) | MAE |
|---|---|---|---|---|
| Watershed | Classical | 0.065 | 28% | 8.66 |
| KMeans (k=5) | Classical | 0.252 | 0% | 114.86 |
| YOLOv8s-seg (fine-tuned) | Deep learning | 0.429 | 52% | 4.28 |
| Hybrid (density-aware) | Hybrid | 0.456 | 64% | 3.30 |
The KMeans row is the instructive one. It scores a respectable 0.252 IoU while getting the count right on zero images — it emits 127 masks per image against 12.6 real objects, so greedy matching finds overlap by volume rather than by segmenting well. Mean IoU alone cannot distinguish that from working.
This page runs the detector and the density gate, not the Watershed cross-check — that would need OpenCV compiled to WebAssembly for a component an ablation showed contributes 6% of the method's improvement (3 of 49 objects of recovered counting error, firing on 4 of 50 test images). The full four-way comparison, the ablation and the report are in the repository.
Pranay Sarkar · Source & 18-page report