High-Density Object Segmentation

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.

Sample crowded scene 1 Sample crowded scene 2 Sample crowded scene 3

Or try one of these held-out test images (34, 33 and 29 objects).

Starting…

How it works

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.

Measured results

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.

MethodTypeMean IoU Count acc. (±3)MAE
WatershedClassical0.06528%8.66
KMeans (k=5)Classical0.2520%114.86
YOLOv8s-seg (fine-tuned)Deep learning0.42952%4.28
Hybrid (density-aware)Hybrid0.45664%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.

An honest note on this demo

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