LGCount: Layout-Guided Diffusion for Zero-Shot Object Counting
Organizations: Simon Fraser University, Burnaby, Canada
Abstract
Class-agnostic counting requires the user to specify what to count, usually with a class name or a few annotated boxes. We propose a richer text-based specification: a structured layout that names the target, the region that holds it, the distractors to ignore. A prompt upsampler writes this layout from the image and the requested category alone, and an image-editing diffusion model, adapted into a single-step counter, turns it into a density map. Because counting datasets pair each image with a single valid density map, a counter trained on it learns to ignore the layout. We therefore train on synthetic counterfactuals in which one image admits several valid density maps, so that the layout cannot be ignored. On FSC-147 we improve on the previous zero-shot state of the art and we set the best reported result on LOOKALIKES while being told the least about each image. A single photograph can be counted by category, by region, or by granularity without retraining.
Figures & tables
| Method | Year | Backbone | Prompt | Pseudo | Synthetic | MAE | RMSE |
| FamNet [ 22 ] | 2021 | ResNet | Visual | – | – | 22.08 | 99.54 |
| CACViT [ 26 ] | 2024 | ViT | Visual | – | – | 9.13 | 48.96 |
| DAVE [ 18 ] | 2024 | ResNet | Visual | – | – | 8.66 | 32.36 |
| CountGD | 2024 | G.Dino | Vis. + Text | – | – | 5.74 | 24.09 |
| CountGD++ | 2026 | G.Dino | Vis. + Text | – | – | 5.86 | 18.79 |
| GroundingDINO [ 15 ] | 2024 | G.Dino | Text | 11.52 | 97.37 |
| Method | Ref. | Neg | Infer. | MAE | RMSE |
|---|---|---|---|---|---|
| CountGD +FiGO [ 4 ] | Text | TTA | 13.31 | 23.36 | |
| GrREC +FiGO [ 4 ] | Text | TTA | 16.15 | 26.99 | |
| CountGD++ [ 2 ] | Text | ZS | 24.6 | 37.3 | |
| CountGD++ [ 2 ] | Text +PS | ZS | 29.1 | 45.0 | |
| RECOUNT [ 6 ] | Image | ZS | 8.41 | 14.67 | |
| DAVE [ 18 ] | Text | ZS | 53.10 | 64.44 |
| Method | FSC147 | LookAlikes | ||
|---|---|---|---|---|
| MAE | RMSE | MAE | RMSE | |
| Qwen3.8 | 13.48 | 67.97 | 8.80 | 19.14 |
| LGCount +Qwen3.8 | 7.06 | 19.38 | 7.97 | 14.34 |
| Method | FSC147 | LookAlikes | ||
|---|---|---|---|---|
| MAE | RMSE | MAE | RMSE | |
| FSC-147 Only | 9.57 | 28.98 | 12.68 | 22.89 |
| + Counterfactuals | 7.06 | 19.38 | 7.97 | 14.34 |
| +2.51 | +9.60 | +4.71 | +8.55 | |
Appendix figures & tables2 assets
Supplementary material from the paper’s appendix.
Appendix
| FSC-147 | LOOKALIKES | |||||
| Region | Inst. | Neg. | MAE | RMSE | MAE | RMSE |
| full | 10.24 | 93.00 | 10.37 | 22.18 | ||
| full | ✓ | 10.15 | 94.15 | 8.22 | 21.40 | |
| full | ✓ | 9.94 | 94.03 | 10.40 | 23.30 | |
| full | ✓ | ✓ | 9.92 | 93.97 | 8.10 | 19.88 |
| declared | 10.68 | 93.39 | 7.53 | 19.56 | ||
| Upsampler | Params | MAE | RMSE | Fallback |
|---|---|---|---|---|
| Qwen3.8 | 27B | 7.06 | 19.38 | 0 |
| InternVL3.5 | 8B | 10.01 | 32.36 | 2 |
| FLUX.3 upsampler | 9B | 10.52 | 95.10 | 69 |
Object Counting
Object counting estimates the number and locations of target instances in images or video, from dense crowds to fine-grained categories.
See all 67 papers