arXiv:2610.08379cs.CVOct 2026

Manuscript Offprint

arXiv:2610.08379

UniCounting: Instance-Aware Proposal Consolidation for Image-Query-Free Multi-Category Counting

Jinshi Liu, Pan Liu, Lei He, Weichao Luo, Rui Qian

Abstract

Visual counting is commonly formulated as counting a single specified target, with a model receiving an image-specific exemplar, text query, or target category and returning a single count. We instead study fixed-vocabulary image-query-free multi-category counting. A global vocabulary is fixed for each run, and, given only an RGB image, the model predicts a complete category-count vector without being told which categories appear. We present UniCounting, which casts counting as instance-aware structural inference over an over-complete proposal set. Generic segmenters produce duplicate masks, partial views, and proposals from neighboring instances; semantic scores can name them but cannot determine which denote the same object. Frozen SAM 2.1 generates masks, while frozen DINOv2 and OpenCLIP provide relation and category features. A 3,267-parameter category-shared relation head predicts same-instance affinities from instance-mask-derived supervision. Sparse graph construction, representative selection, labeling, and background-margin admission then convert each admitted component into one count with replayable group evidence. Only the relation head is trained, without count or density-map targets. On COCO clean500, UniCounting obtains lower point-estimate vector ℓ1\ell_1 error and absent-class false mass than calibrated OWLv2-All80, with comparable micro presence F1. Under a matched decoder, the learned relation reduces both errors relative to mask containment, mask IoU, CLIP, and DINO, while revealing a fragmentation-merge trade-off. We also report transfer diagnostics on OmniCount-sub, FSC-147, and CARPK.

1 Introduction

Visual counting is typically formulated as a conditional, single-category task. A model receives an exemplar or a category query that specifies what to count and returns a scalar count or density map for that target (Ranjan et al. 2021; Liu et al. 2022; Jiang, Liu, and Chen 2023; Amini-Naieni, Han, and Zisserman 2024). This interface is effective when the target is known in advance, but it does not directly answer a scene-level question: which object categories are present, and how many instances of each occur? We study image-query-free multi-category counting, where a global vocabulary is fixed once for each deployment or evaluation run, but no image-dependent category selection is provided. Thus, image-query-free does not mean vocabulary-free; rather, the model receives no per-image target category, exemplar, or

Figure

Figure 1: Qualitative counting examples. In the upper example, colored boxes mark representative proposals for the displayed groups, and arrows connect each representative to its fixed-vocabulary category and predicted count. In the lower example, one predicted component merges proposals supporting at least five distinct ground-truth hot-dog instances. The remaining discrepancy between the ground-truth count of 11 and the single predicted component may also include upstream proposal misses.

restricted class list. Given only an RGB image, it returns a complete category–count vector together with the proposal groups supporting its nonzero entries.

Several lines of work provide parts of this capability. Category-labeled detectors can be converted into count vectors by summing detections, supervised multi-class counters predict fixed category channels, and reference-less counters can organize foreground objects into image-specific groups (Minderer, Gritsenko, and Houlsby 2023; Xu et al. 2021; Hobley and Prisacariu 2024; Spanakis, Oikonomidis, and Argyros 2026). What remains underexplored is the instance-consolidation problem that appears when counting is built from generic segmentation proposals without an image-specific target. Automatic segmenters produce over-complete candidate sets containing duplicate masks for one object, partial views of the same object, and visually similar proposals from neighboring objects. Semantic scores can assign category names to proposals, but they do not determine whether two proposals denote the same physical instance. Reliable counting therefore requires resolving proposal identity before selecting one representative and one label for each surviving group.

We introduce UniCounting, an instance-aware proposal-consolidation framework built on frozen foundation-model features. SAM 2.1 generates candidate masks, while DINOv2 and OpenCLIP provide relation and category features (Ravi et al. 2025; Oquab et al. 2024; Radford et al. 2021; Cherti et al. 2023). A 3,267-parameter category-shared relation head learns pairwise same-instance affinity from instance-mask-derived supervision. UniCounting converts these affinities into a sparse graph, forms connected components, selects a maximum-category-margin representative for each component, assigns the representative's fixed-vocabulary label, and applies background-margin admission using a validation-calibrated threshold. The distinction is not the absence of a vocabulary, but whether image-dependent category selection is supplied. Each admitted component contributes one count. The resulting vector is therefore accompanied by an explicit trail from proposals and relation edges to components, representatives, labels, and admission decisions. Only the relation head is trained; the category head and the three foundation-model components remain frozen, and training uses no count or density-map targets. Figure 1 illustrates this proposal-to-group-to-count trace.

We evaluate UniCounting at two complementary levels. At the system level, complete-vector experiments measure category-wise counting, absent-category errors, and presence prediction, including a calibrated category-labeled detector as a direct reference. At the mechanism level, a matched-decoder study holds the candidate pool and downstream decoder fixed while replacing only the edge score; group-partition diagnostics and component-wise ablations then localize the effects of relation scoring, representative selection, labeling, and admission. Our primary evidence comes from the complete-vector COCO evaluation and the matched-decoder analysis, while the remaining held-out and single-coordinate datasets serve as supporting diagnostics.

Our contributions are twofold:

• We cast fixed-vocabulary image-query-free multi-category counting as an instance-aware proposal-consolidation problem and introduce UniCounting, a foundation-model pipeline with a 3,267-parameter trainable relation head to convert over-complete frozen proposals into complete count vectors with replayable group evidence.

• We provide a controlled empirical framework that separates system-level counting performance from proposal-consolidation quality through calibrated complete-vector references, matched-decoder edge comparisons, group-partition diagnostics, and decoder ablations. Using this framework, we show that learned instance relations reduce vector ℓ1\ell_{1} error and absent-class false mass relative to the tested edge-score alternatives, while exposing a trade-off between proposal fragmentation and instance merging.

References (31)