Manuscript Offprint
arXiv:2610.08379UniCounting: Instance-Aware Proposal Consolidation for Image-Query-Free Multi-Category Counting
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 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 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 error and absent-class false mass relative to the tested edge-score alternatives, while exposing a trade-off between proposal fragmentation and instance merging.
Closed-set and discovered categories. Supervised multi-class counting predicts one density channel per trained class (Xu et al. 2021; Gao, Zhao, and Li 2024), while SIMCO clusters emergent foreground types (Godi et al. 2021). These establish fixed-channel and category-discovery precedents, so fixed-vocabulary output alone is not our novelty claim.
Detection, grounding, and count vectors. Fixed-category detectors provide class-labeled instances, so summing retained detections by class is a direct complete-vector baseline. Grounding DINO takes category names or referring expressions for open-set detection, and OWLv2 scales detection with language-defined categories (Liu et al. 2024; Minderer, Gritsenko, and Houlsby 2023). Because this reduction already provides vector outputs, UniCounting focuses on proposal grouping and category admission under vector-level counting errors, with a replayable group for every accepted count.
Multi-category counting. Reference-less counters typically return one anonymous count (Ranjan and Hoai 2022; Hobley and Prisacariu 2023; Xu et al. 2023). ABC123 and OCCAM discover multiple image-specific types without exemplars (Hobley and Prisacariu 2024; Spanakis, Oikonomidis, and Argyros 2026), whereas OmniCount names user-specified categories (Mondal et al. 2025). PrACo tests whether text-guided counters reject absent labels, while PrACo++ adds negative-label and distractor protocols and MUCCA provides real multi-category scenes (Ciampi et al. 2025; Pacini et al. 2026). UniCounting complements these directions by using one global vocabulary fixed for the entire run before its first image is processed, emitting every coordinate, and reporting both absent-class false mass and presence F1.
Proposal-based recognition. Foundation models support region discovery and semantic matching (Kirillov et al. 2023; Ravi et al. 2025; Radford et al. 2021; Cherti et al. 2023; Oquab et al. 2024), but their proposal sets contain duplicates and incomplete views. We isolate the conversion of these redundant proposals into a complete named count vector with group-level evidence.
3 Method
3.1 Task Definition
For each deployment or evaluation run, a global vocabulary is fixed before any image in that run is processed;

Figure 2: UniCounting modules and data flow. Frozen SAM 2.1 generates over-complete candidates, while frozen DINOv2 and OpenCLIP encode the three proposal views for relation features. The fixed category head uses only the masked- and box-view OpenCLIP embeddings to compute fixed-vocabulary category scores. The trained relation head supplies the same-instance affinity used by thresholding, top2-OR, and union-find. Deterministic maximum-category-margin representative selection, raw-cosine labeling, and background-margin admission then produce the count vector and its group evidence. Snowflake, lightning, and gray modules denote frozen, trained, and parameter-free computation, respectively.
no image-dependent category selection is supplied. Let denote this vocabulary and an RGB image. We call the task image-query-free because inference receives but no image-specific text, point, exemplar, target label, or restricted class list. Category names, templates, and text prototypes are fixed together with for the full run. For each category , the model returns a collection of admitted proposal components, together with the count vector
where every is a connected component of proposals assigned to and retains a designated representative . Thus, is a collection of components, not a set of representative proposals. A category is present when . The predictor cannot read a target class, a per-image class list, or any evaluation annotation. The global vocabulary defines the ontology for the run; it is neither a per-image prompt nor an image-dependent class list.
3.2 Fixed Category Head
A frozen SAM 2.1 automatic mask generator (Ravi et al. 2025) produces candidates . Each candidate has masked, box, and context crops. Frozen DINOv2 (Oquab et al. 2024) and OpenCLIP (Radford et al. 2021; Cherti et al. 2023) encode all three views for relation prediction. For view , let denote the L2-normalized OpenCLIP embedding of candidate , and let denote L2 normalization. The category head uses only the masked and box OpenCLIP embeddings. Fixed templates are averaged into a normalized prototype for each . The proposal feature and its raw category score are computed together as
Template lists and taxonomy-specific name aggregation are given in the supplement. The classifier over V has no trainable parameters, no trainable background or unknown class, and no learned rejection gate. A separate fixed bank of seven background prototypes is used only by the admission rule in Section 3.5. The selected decoder uses the category cosines for representative selection and labeling.
3.3 Relation Head and Same-Instance Score
The relation head is the only trainable module. For each directed pair , a 16-dimensional feature contains same-view DINO and CLIP cosine similarities, cross-view CLIP similarities, directed log-area ratio, minimum-to-maximum area ratio, two image-area fractions, two SAM 2.1 scores, their absolute difference, and a constant. Each dimension is centered by its relation-training mean and divided by its relation-training standard deviation after clamping that denominator below at . Feature 16 is an inactive compatibility placeholder: after standardization it is identically zero and, because the MLP already has affine biases, it does not affect any branch logit. Let and have biases and , and let denote dropout with rate 0.1. For branch , let and parameterize its output layer. Let denote the logistic sigmoid. The directed representation, branch logit, and symmetric same-instance score are
The two affine trunk layers contain 1,088 and 2,080 parameters, and the three output layers contain 99, giving 3,267 trainable parameters. Primary inference uses only the symmetric same-instance score; the semantic and completeness branches are used only in diagnostic decoder variants.
3.4 Instance Grouping, Representative Selection, and Labeling
For relation-head run , an unordered edge is eligible when , with frozen on inner validation. For each candidate , let contain the neighbor indices of up to two eligible incident edges with the largest instance scores. The top2-OR edge set is
An OR rather than mutual selection preserves an edge chosen by either endpoint. Union-find on E produces connected components, including singleton proposals. Each limits direct incident selections but does not bound component size after transitive closure.
Within each component G, let and be the largest and second-largest raw category cosines for candidate i. UniCounting selects the maximum-category-margin representative and assigns the component the representative's highest-scoring category:
No member averaging, semantic relation, or learned completeness score enters Eqs. 7–9.
3.5 Background-Margin Admission
Let denote the fixed background concepts background, an unknown object, other object, texture, shadow, printed text, and empty scene. For , the normalized prototype is the mean of its normalized fixed-template embeddings; the exact templates are listed in the supplement. For each component , UniCounting computes the admission margin , applies its binary admission indicator , and accumulates admitted labels:
Algorithm 1 UniCounting inference with explicit state and outputs.
Require: Pair scores , category scores , proposal features
Require: Background prototypes , thresholds and
Ensure: Count vector and admitted components
1: for each candidate do
2: the top two satisfying
3: end for
4: and UnionFind( )
5: for each do
6:
7: end for
8: and for every
9: for each . components() do
10: Compute , , and using Eqs. 8–10
11: if then
12: and
13: end if
14: end for
15: return ,
The run-specific threshold is frozen on inner validation and is a raw-cosine margin rather than a probability. We omit the superscript when unambiguous. A rejected component contributes zero to every category. Its label is not changed, and its count is not redistributed.
Pair scoring costs before sparsification. The graph stores at most 2N endpoint selections, and union-find component construction is near-linear in . Exact thresholds, index orders, and deterministic tie-breaking rules are specified in the supplement.
3.6 Supervision and Optimization
The category head remains fixed, and the relation head is fitted on 210 COCO train2017 images (Lin et al. 2014), with a disjoint 45-image inner-validation split, denoted inner45, reserved for decoder and threshold selection. A proposal is supervised only when one non-crowd instance accounts for at least 0.8 of its mask, the second-best instance accounts for at most 0.1, and ignore overlap is at most 0.1. Reliable proposal pairs receive same-category and same-instance targets; the completeness target is directional and identifies the proposal with greater ground-truth coverage when the containment and coverage-gap conditions hold. Both directions of each pair are used for training, while Algorithm 1 reads only the same-instance branch at inference. Pair supports, the weighted training objective, and optimization settings are specified in the supplement.
Selection uses only inner45. It minimizes complete-vector for graph construction, representative selection, and labeling, then selects admission by micro presence F1, with vector breaking ties. No target-test set enters training or selection.
4 Experiments
The experiments ask how UniCounting performs under complete-vector counting, whether the relation-head score improves consolidation under a matched decoder, and which partition changes explain its gains and costs. We then analyze the remaining decoder components and their selection trace. All systems are evaluated under the protocol defined in Section 3.1. OWLv2-AllK satisfies the same complete-vector output requirement, although it receives the fixed K-class list as an inference input. The Faster R-CNN reference also emits a complete COCO80 vector but uses full COCO box supervision. ABC123 and OCCAM discover anonymous image-specific types, while OmniCount predicts categories requested by a user cue. FSC-147 and CARPK provide only single-coordinate transfer diagnostics under heterogeneous cue protocols, so their results and the full protocol comparison are reported in Supplementary Table S7 rather than used as primary evidence.
4.1 Protocols and Metrics
Model selection and system variants. All decoder choices and thresholds are fixed on a COCO inner-validation split before target-test evaluation. The unqualified name UniCounting refers only to Algorithm 1.
Controlled edge and grouping protocol. We replace only the symmetric edge score with mask containment, mask IoU, CLIP cosine, DINO cosine, or the relation-head score, while fixing the candidate pool, pair universe, top2-OR graph construction, representative rule, labeling rule, and run-matched background-margin admission. Singleton and overlap-guard controls retain the same downstream decoder. Score-specific thresholds are selected only on inner45; exact values and tie-breaking rules are given in the supplement.
Fixed-list detector baseline. OWLv2-All80 receives the same list of 80 raw COCO category names for every image, applies classwise NMS, and counts retained detections. Its score threshold is calibrated only on inner45; checkpoint, preprocessing, search-grid, and tie-breaking details are given in the supplement. Clean500 remains untouched.
Fully supervised detector reference. We report torchvision Faster R-CNN with a ResNet-50-FPN v2 backbone and official COCO-trained weights (Ren et al. 2015). Classwise NMS and an inner45-selected score threshold produce a complete COCO80 count vector. Since the model uses COCO box supervision, it provides supervised context rather than a like-for-like comparison to UniCounting.
Primary complete-vector evaluation. COCO clean500 is a deterministic 500-image subset of val2017 (Lin et al. 2014). We rank eligible images by file name, exclude identities from the separate 60-image diagnostic split clean60 defined in the supplement, and take the first 500 without reading annotations or model outputs. Its image hashes are disjoint from relation-head training and inner45 validation, and all thresholds are frozen before preprocessing. Let denote the evaluation set, where is the ground-truth count vector and its prediction; here denotes the nonnegative integers. For clean500, and . Each image contains a mean/median of 2.894/2 present categories and 7.018/4 annotated objects; 96.38% of image-class cells are zero, and the largest per-class count is 13.
We report mean vector error and present-cell MAE over cells with . Absent-class false mass is , and total-count MAE is . We also report macro and micro presence F1, where presence means a positive count; macro-F1 averages represented classes, whereas micro-F1 pools all image-category decisions. Full support and bootstrap rules are given in the supplement.
Transfer evaluations. OmniCount-sub is an internally constructed, exact-duplicate-screened 2,000-image holdout sampled from the OmniCount training/validation resources rather than the official test split (Mondal et al. 2025). It uses the 191-category taxonomy released publicly with OmniCount; we use PF191 as shorthand for this public, fixed output space. We therefore treat it as a project holdout, not an official benchmark. Its labels are not used to train the relation head, select the decoder, or tune admission, and we report vector error and pooled micro presence F1.
FSC-147 provides all 1,190 test images but only one annotated target category per image (Ranjan et al. 2021). UniCounting predicts the complete 147-dimensional vector without target metadata, after which the evaluator extracts the target coordinate for MAE and RMSE. CARPK is evaluated analogously on its 459 test images as zero-shot transfer to the fixed car coordinate, without fine-tuning (Hsieh, Lin, and Hsu 2017). Because FSC-147 and OmniCount-sub share 26 source-image hashes, we report them separately and do not treat them as independent transfer confirmations.
Statistical reporting and reproducibility. Unless stated otherwise, relation-head rows report mean and sample standard deviation over three relation seeds. Paired 95% bootstrap intervals are computed from saved prediction vectors; resampling, seed aggregation, macro-support, and random-seed details are provided in the supplement.
4.2 Implementation Details
We use frozen SAM 2.1 for proposals, DINOv2 for relation features, and OpenCLIP for category features. The relation head scores all proposal pairs before graph sparsification, giving relation-scoring cost. Exact checkpoints, candidate filtering thresholds, crop construction, preprocessing, and deterministic inference settings are specified in the supplement.
4.3 How does UniCounting perform under complete-vector counting?
Table 1 reports complete-vector performance on COCO clean500. UniCounting is numerically lower than OWLv2-All80 in vector (6.485 versus 6.860), present-cell MAE (2.129 versus 2.205), and absent-class false mass (0.325 versus 0.474), while their micro-F1 values are nearly identical.
| Method | Vector | Present MAE | False mass | Total MAE | Macro-F1 | Micro-F1 |
|---|---|---|---|---|---|---|
| Zero vector | 7.018 | 2.425 | 0.000 | 7.018 | 0.000 | 0.000 |
| Fixed-list detector (OWLv2-All80) | 6.860 | 2.205 | 0.474 | 5.800 | 0.472 | 0.415 |
| UniCounting | 6.485±0.058 | 2.129±0.005 | 0.325±0.062 | 5.868±0.050 | 0.407±0.007 | 0.416±0.005 |
| Faster R-CNN (fully supervised ref.) | 3.098 | 0.916 | 0.446 | 2.078 | 0.809 | 0.832 |
Table 1: Primary complete-vector results on COCO clean500. Every row predicts the same COCO80 vector. OWLv2 receives the full raw COCO80 list identically for every image, while UniCounting uses a fixed taxonomy and no image-specific cue. Its row reports mean±sample standard deviation over three relation-head seeds; seed-specific thresholds are given in the supplement. The point estimate for UniCounting minus OWLv2 vector is (6.485 versus 6.860). The separated Faster R-CNN row uses full COCO box supervision and is reported only as a supervised reference, not as a like-for-like training-regime comparison.
| Edge/grouping rule | τ | Vector ℓ1 ↓ | False mass↓ | Total MAE↓ | Micro-F1↑ |
|---|---|---|---|---|---|
| No grouping / singletons | - | 29.187 | 20.347 | 24.440 | 0.319 |
| Mask containment | 0.005 | 9.935 | 4.697 | 5.020 | 0.427 |
| Mask IoU | 0.005 | 13.649 | 8.265 | 7.965 | 0.374 |
| CLIP cosine | 0.500 | 7.335 | 1.452 | 4.987 | 0.431 |
| DINO cosine | 0.310 | 6.814 | 0.809 | 5.463 | 0.434 |
| Relation-head score + overlap guard | 0.465 | 9.597 | 4.361 | 4.635 | 0.414 |
| Relation-head score (shared τ, controlled) | 0.465 | 6.483 | 0.326 | 5.864 | 0.417 |
Table 2: Controlled edge and grouping ablation on COCO clean500. The two relation-head rows are controlled variants rather than the primary UniCounting configuration: both use a common edge threshold , whereas primary UniCounting uses seed-specific instance thresholds selected on inner45. The table reports end-task metrics after a shared downstream decoder; full pre-admission partition diagnostics are provided in the supplement. Mask IoU is the binary-mask intersection over union; the overlap guard instead adds a positive-intersection constraint to the relation-head score. Every row is the arithmetic mean of seed-specific point metrics for seeds 17, 42, and 73. For containment, mask IoU, CLIP, DINO, relation-head, singleton, and overlap-guard rows, the candidate pool, pair universe, graph construction, representative and labeling rules, and run-matched background-margin admission are fixed; only the edge score, common edge threshold, or stated grouping control changes.
(0.416 versus 0.415). OWLv2 has lower total-count MAE (5.800 versus 5.868) and higher macro-F1 (0.472 versus 0.407). We therefore describe the 0.375 vector- gap as a point-estimate difference and make no significance claim. The matched-decoder study below separates the contribution of proposal consolidation from the remaining system components.
The fully supervised Faster R-CNN reference reaches 3.098 vector and 0.832 micro-F1. This gap indicates substantial headroom when COCO box supervision is available, but it does not isolate the contribution of proposal consolidation because the detector and UniCounting use different training supervision.
The standalone OmniCount-sub complete-vector comparison is reported in Supplementary Table S5, while FSC-147 and CARPK single-coordinate diagnostics are reported in Supplementary Table S7. These results provide transfer context rather than evidence for the grouping mechanism.
4.4 Does the relation-head score improve proposal consolidation under a matched decoder?
Table 2 isolates the edge score under a shared downstream decoder. The relation-head score obtains the lowest vector and false mass among the tested scores. Its paired vector- and false-mass intervals against containment, mask IoU, CLIP, and DINO exclude zero. DINO has higher micro-F1, and the overlap guard has lower total-count MAE. Thus, the relation-head score improves the two complete-vector error measures targeted by this comparison, but not every end-task metric.
4.5 Why does it help, and what does it sacrifice?
Figure 3 summarizes the mechanism underlying Table 2. Mask IoU and containment suppress merges more conservatively but leave substantially more instances fragmented. In contrast, the relation-head score shifts the partition toward aggressive consolidation, obtaining the lowest fragmented rate and complete-vector error among the tested edge scores, while accepting a moderate merge-error increase. It also attains a Pair F1 of 0.694, purity of 0.925, and representative IoU of 0.215; formal definitions and the complete partition diagnostics are provided in Supplementary Table S8.
4.6 Decoder Component Ablation and Selection Analysis
Table 3 records the staged inner45 selection trace, with each row carrying forward the choices selected at preceding stages. Figure 4 separates the contribution of each selected decoder choice on the two frozen target sets. Maximum-category-margin representation and representa-

Figure 3: Fragmentation-merge trade-off under the matched decoder on COCO clean500. Each point represents an edge or grouping rule; the horizontal and vertical axes report the fragmented-instance rate and component merge error, respectively, so lower-left is preferred. Point annotations report the resulting complete-vector error after the shared downstream decoder. The relation-head score produces the lowest fragmentation and vector error among the tested edge scores, while incurring more merges than the conservative mask-containment and mask-IoU rules.
| Stage | Selected variant | Vector | Micro-F1↑ |
|---|---|---|---|
| Graph | same-instance edges* | 6.867±0.06 | 0.417±0.005 |
| Represent. | max category margin | 6.837±0.09 | 0.423±0.004 |
| Labeling | raw cosines | 6.837±0.09 | 0.423±0.004 |
| Admission | background-margin | 6.793±0.05 | 0.426±0.007 |
Table 3: Decoder choices selected on inner45. * refers to all eligible/top2-OR. Each stage carries forward the choices selected at preceding stages. The table is a staged selection trace rather than a cumulative-improvement analysis. The complete candidate matrix and frozen target-set results are reported in the supplement.
tive raw-cosine labeling consistently improve both vector and micro-F1, with labeling producing the largest effect. Background-margin admission provides a smaller additional gain. In contrast, top2-OR sparsification exhibits metric- and dataset-dependent behavior, supporting selection of the complete pipeline on inner45 rather than retrospective target-set tuning. The complete audit in Supplementary Table S9 further shows that the semantic constraint consistently degrades performance.
5 Discussion and Limitations
The complete-vector evidence is limited to the 500-image COCO evaluation and the project holdout OmniCount-sub, and we do not evaluate MUCCA or PrACo++. clean500 is disjoint from development data and selected without annotations, but remains a subset of COCO val2017, with unknown foundation-model pretraining overlap. The controlled ablation isolates five edge scores and two grouping controls under one decoder. The relation-head score reduces vector error and false mass relative to tested alternatives, but does not minimize total-count MAE; its merge error is higher than mask IoU and containment, while lower than CLIP and DINO. The candidate pool recalls only 62.4% of non-ignore instances at mask IoU 0.50. Since representative selection and admission maximize over V, changing vocabularies shifts score distributions, and reusing COCO-calibrated thresholds may impair transfer calibration.


Figure 4: Stage-wise effects of the decoder choices selected on inner45 when audited on the frozen clean500 and OmniCount-sub target sets. Panel (a) reports vector- improvement, defined as the baseline error minus the selected-variant error; panel (b) reports micro-F1 improvement, defined as the selected-variant score minus the baseline score. Positive values therefore denote improvement in both panels. Baselines are all-edges grouping, maximum-area representation, component-mean labeling, and no admission, respectively. Representative selection and labeling provide the largest consistent gains, whereas the effect of top2-OR sparsification is metric- and dataset-dependent.
Trainable capacity is limited to the 3,267-parameter relation head, but inference still runs frozen SAM 2.1, DI-NOv2, and OpenCLIP components with quadratic pair scoring. Deployment should further address privacy, ontology omissions, and systematic category errors.
6 Conclusion
UniCounting studies image-query-free multi-category counting from the perspective of proposal consolidation. Instead of directly mapping redundant segmentation proposals to category counts, it explicitly models proposal identity, forms instance-level components, and produces category-count outputs with traceable group evidence. A 3,267-parameter category-shared relation head improves proposal partition quality under a controlled decoder comparison, reducing vector-level counting error relative to several similarity-based alternatives. Our analysis also reveals an inherent trade-off in proposal consolidation: more aggressive grouping reduces fragmentation but may increase instance merging errors. These findings suggest that reliable multi-category counting requires not only semantic recognition but also explicit control over instance identity. Future work should improve proposal recall and develop more adaptive mechanisms for balancing merge and fragmentation errors.
Acknowledgments
This work was supported by the National Natural Science Foundation (No. 62503505) and the Hunan Natural Science Foundation (No. 2025JJ60424).
References
Amini-Naieni, N.; Amini-Naieni, K.; Han, T.; and Zisserman, A. 2023. Open-world Text-specified Object Counting. In Proceedings of the British Machine Vision Conference (BMVC).
Amini-Naieni, N.; Han, T.; and Zisserman, A. 2024. CountGD: Multi-Modal Open-World Counting. In Advances in Neural Information Processing Systems (NeurIPS), volume 37.
Cherti, M.; Beaumont, R.; Wightman, R.; Wortsman, M.; Ilharco, G.; Gordon, C.; Schuhmann, C.; Schmidt, L.; and Jitsev, J. 2023. Reproducible Scaling Laws for Contrastive Language-Image Learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2818–2829.
Ciampi, L.; Messina, N.; Pierucci, M.; Amato, G.; Avvenuti, M.; and Falchi, F. 2025. Mind the Prompt: A Novel Benchmark for Prompt-Based Class-Agnostic Counting. In Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision (WACV), 7959–7968.
Gao, J.; Zhao, L.; and Li, X. 2024. NWPU-MOC: A Benchmark for Fine-Grained Multicategory Object Counting in Aerial Images. IEEE Transactions on Geoscience and Remote Sensing, 62: 1–14.
Godi, M.; Joppi, C.; Giachetti, A.; and Cristani, M. 2021. SIMCO: SIMilarity-based object Counting. In Proceedings of the International Conference on Pattern Recognition (ICPR), 47–52.
Hobley, M.; and Prisacariu, V. 2023. Learning to Count Anything: Reference-less Class-agnostic Counting with Weak Supervision. In T4V: Transformers for Vision Workshop at the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR).
Hobley, M. A.; and Prisacariu, V. A. 2024. ABC Easy as 123: A Blind Counter for Exemplar-Free Multi-Class Class-Agnostic Counting. In Proceedings of the European Conference on Computer Vision (ECCV), 304–319.
Hsieh, M.-R.; Lin, Y.-L.; and Hsu, W. H. 2017. Drone-Based Object Counting by Spatially Regularized Regional Proposal Network. In Proceedings of the IEEE International Conference on Computer Vision (ICCV), 4145–4153.
Huang, Z.; Dai, M.; Zhang, Y.; Zhang, J.; and Shan, H. 2024. Point, Segment and Count: A Generalized Framework for Object Counting. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 17067–17076.
Jiang, R.; Liu, L.; and Chen, C. 2023. CLIP-Count: Towards Text-Guided Zero-Shot Object Counting. In Proceedings of the 31st ACM International Conference on Multimedia (MM), 4535–4545.
Kang, S.; Moon, W.; Kim, E.; and Heo, J.-P. 2024. VL-Counter: Text-aware Visual Representation for Zero-Shot Object Counting. Proceedings of the AAAI Conference on Artificial Intelligence, 38(3): 2714–2722.
Kirillov, A.; Mintun, E.; Ravi, N.; Mao, H.; Rolland, C.; Gustafson, L.; Xiao, T.; Whitehead, S.; Berg, A. C.; Lo, W.Y.; Dollár, P.; and Girshick, R. 2023. Segment Anything. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), 4015–4026.
Lin, T.-Y.; Maire, M.; Belongie, S.; Hays, J.; Perona, P.; Ramanan, D.; Dollár, P.; and Zitnick, C. L. 2014. Microsoft COCO: Common Objects in Context. In Proceedings of the European Conference on Computer Vision (ECCV), 740–755.
Liu, C.; Zhong, Y.; Zisserman, A.; and Xie, W. 2022. CountTR: Transformer-based Generalised Visual Counting. In Proceedings of the British Machine Vision Conference (BMVC).
Liu, S.; Zeng, Z.; Ren, T.; Li, F.; Zhang, H.; Yang, J.; Jiang, Q.; Li, C.; Yang, J.; Su, H.; Zhu, J.; and Zhang, L. 2024. Grounding DINO: Marrying DINO with Grounded Pre-Training for Open-Set Object Detection. In Proceedings of the European Conference on Computer Vision (ECCV), 38–55.
Liu, S.; Zhang, P.; Zhang, S.; and Ke, W. 2025. CountSE: Soft Exemplar Open-set Object Counting. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), 21536–21546.
Minderer, M.; Gritsenko, A. A.; and Houlsby, N. 2023. Scaling Open-Vocabulary Object Detection. In Advances in Neural Information Processing Systems (NeurIPS), volume 36.
Mondal, A.; Nag, S.; Zhu, X.; and Dutta, A. 2025. OmniCount: Multi-label Object Counting with Semantic-Geometric Priors. Proceedings of the AAAI Conference on Artificial Intelligence, 39(18): 19537–19545.
Oquab, M.; Darcet, T.; Moutakanni, T.; Vo, H.; Szafraniec, M.; Khalidov, V.; Fernandez, P.; Haziza, D.; Massa, F.; El-Nouby, A.; Assran, M.; Ballas, N.; Galuba, W.; Howes, R.; Huang, P.-Y.; Li, S.-W.; Misra, I.; Rabbat, M.; Sharma, V.; Synnaeve, G.; Xu, H.; Jégou, H.; Mairal, J.; Labatut, P.; Joulin, A.; and Bojanowski, P. 2024. DINOv2: Learning Robust Visual Features without Supervision. Transactions on Machine Learning Research.
Pacini, G.; Ciampi, L.; Messina, N.; Tonellotto, N.; Amato, G.; and Falchi, F. 2026. Does it Really Count? Assessing Semantic Grounding in Text-Guided Class-Agnostic Counting. arXiv:2605.02752.
Qian, Y.; Guo, Z.; Deng, B.; Lei, C. T.; Zhao, S.; Lau, C. P.; Hong, X.; and Pound, M. P. 2025. T2ICount: Enhancing Cross-modal Understanding for Zero-Shot Counting. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 25336–25345.
Radford, A.; Kim, J. W.; Hallacy, C.; Ramesh, A.; Goh, G.; Agarwal, S.; Sastry, G.; Askell, A.; Mishkin, P.; Clark, J.; Krueger, G.; and Sutskever, I. 2021. Learning Transferable Visual Models from Natural Language Supervision.
In Proceedings of the International Conference on Machine Learning (ICML), 8748–8763.
Ranjan, V.; and Hoai, M. 2022. Exemplar Free Class Agnostic Counting. In Proceedings of the Asian Conference on Computer Vision (ACCV), 71–87.
Ranjan, V.; Sharma, U.; Nguyen, T.; and Hoai, M. 2021. Learning to Count Everything. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 3394–3403.
Ravi, N.; Gabeur, V.; Hu, Y.-T.; Hu, R.; Ryali, C.; Ma, T.; Khedr, H.; Rädle, R.; Rolland, C.; Gustafson, L.; Mintun, E.; Pan, J.; Alwala, K. V.; Carion, N.; Wu, C.-Y.; Girshick, R.; Dollár, P.; and Feichtenhofer, C. 2025. SAM 2: Segment Anything in Images and Videos. In Proceedings of the International Conference on Learning Representations (ICLR).
Ren, S.; He, K.; Girshick, R.; and Sun, J. 2015. Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks. In Advances in Neural Information Processing Systems (NeurIPS), volume 28.
Shi, M.; Lu, H.; Feng, C.; Liu, C.; and Cao, Z. 2022. Represent, Compare, and Learn: A Similarity-Aware Framework for Class-Agnostic Counting. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 9529–9538.
Spanakis, M.; Oikonomidis, I.; and Argyros, A. A. 2026. OCCAM: Class-Agnostic, Training-Free, Prior-Free and Multi-Class Object Counting. arXiv:2601.13871.
Đukić, N.; Lukežič, A.; Zavrtanik, V.; and Kristan, M. 2023. A Low-Shot Object Counting Network with Iterative Prototype Adaptation. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), 18872–18881.
Xu, J.; Le, H.; Nguyen, V.; Ranjan, V.; and Samaras, D. 2023. Zero-Shot Object Counting. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 15548–15557.
Xu, W.; Liang, D.; Zheng, Y.; Xie, J.; and Ma, Z. 2021. Dilated-Scale-Aware Category-Attention ConvNet for Multi-Class Object Counting. IEEE Signal Processing Letters, 28: 1570–1574.
Supplementary Materials
Jinshi Liu, Pan Liu, Lei He, Weichao Luo, Rui Qian
Shenzhen University The Hong Kong University of Science and Technology (Guangzhou)
Hunan University of Science and Technology Peng Cheng Laboratory Fudan University
jsl@szu.edu.cn, liup28292@gmail.com, helei_xb@hnust.edu.cn
luowch@pcl.ac.cn, qianruii@gmail.com
*Co-corresponding authors.
This supplement specifies the implementation choices, evaluator definitions, and supporting experiments for the method in the main paper.
Reproducibility Protocol
| Field | Configuration |
|---|---|
| Training seeds | 17, 42, 73 |
| COCO (Lin et al. 2014) | val2017 clean500; fixed |
| release and split | SHA256-ranked identities |
| Threshold-selection split | disjoint 45-image COCO inner-validation split (inner45) |
| Bootstrap repetitions / seed | 10,000 / 20260725 |
Table S1: Reproducibility settings for training, selection, and evaluation.
Development-split provenance. The training code consumes two fixed COCO train2017 role assignments stored in the source registry: 210 images marked relation_train and 45 images marked inner_validation. It does not generate either role by a random draw, a hash rule, or metric-based filtering. The sets contain 210 and 45 unique identities, respectively, with no overlap. SHA-256 of the numerically sorted, newline-delimited, 12-digit image IDs is 8f5728c98bf1 for train210 and 06744dca51b6 for inner45. Train210 contains 11,341 candidates, 3,262 reliable proposals, and 45,508 reliable unordered pairs; inner45 covers 60 of the 80 COCO categories.
COCO clean60 diagnostic set. Clean60 is the fixed 60-image COCO val2017 identity list in the released split file (identity SHA-256 f1fcbdcf). Because its construction does not specify a random-sampling formula, we treat clean60 as a diagnostic set and make no population-level representativeness claim. It is not used for relation-head training, decoder selection, or threshold selection. Its image hashes are disjoint from the 210-image relation-training set and the 45-image inner-validation set, both drawn from train2017, and clean500 is constructed after excluding all clean60 identities. The COCO80 targets contain 340 non-ignore instances from 54 categories and 155 positive image-category cells. Per image, the mean/median non-ignore instance count is 5.667/4 and the mean/median number of present categories is
| Setting | Value |
|---|---|
| SAM 2.1 (Ravi et al. 2025) checkpoint | sam2.1-hiera-small, SHA-256 prefix 0a4067b1 |
| Input resolution | checkpoint-native preprocessing |
| Points per side / crop layers | 24 / 0 |
| Predicted-IoU threshold | 0.7 |
| Stability threshold | 0.8 |
| Box NMS threshold | 0.7 |
| Minimum / maximum mask area fraction | |
| Near-duplicate rule | descending predicted IoU; discard if box IoU > 0.5 and mask IoU > 0.9 against an already-retained mask |
| Minimum box side / tiling | 4 pixels / none |
Table S2: Automatic mask generation and filtering.
2.583/2; the largest single-category count is 13, and 96.771% of the cells are zero.
Image-query-free protocol. UniCounting follows the run-level vocabulary protocol of Section 3.1. No per-image category cue is supplied, and FSC-147 target coordinates are extracted only after the full fixed-vocabulary prediction is produced.
FSC-147 annotation boundary. FSC-147 specifies one benchmark target but not every countable category in a scene.
Implementation Details
Computing Environment
All experiments were executed in the computing environment summarized below. The CUDA version supported by the NVIDIA driver is distinguished from the CUDA version against which PyTorch was compiled.
(a) Multi-category complete vector

GT person × 1 · umbrella × 1
Pred person × 1 · umbrella × 1
38 proposals → 2 admitted groups
Vector · False mass = 0
(b) Adjacent same-class instances

GT vase × 4
Pred vase × 4
78 proposals → 4 admitted groups
Vector · False mass = 0
(c) Distant co-occurring objects
GT person × 1 · surfboard × 1
Pred person × 1 · surfboard × 1
21 proposals → 2 admitted groups
Vector · False mass = 0
(d) Cat-television scene

GT cat × 1 · tv × 1
Pred cat × 1 · tv × 1
28 proposals → 2 admitted groups
Vector · False mass = 0
(e) Human-animal interaction
GT person × 1 · elephant × 1
Pred person × 1 · elephant × 1
12 proposals → 2 admitted groups
Vector · False mass = 0
(f) Occluded co-occurring objects

GT cat × 1 · suitcase × 1
Pred cat × 1 · suitcase × 1
24 proposals → 2 admitted groups
Vector · False mass = 0
Figure S1: Selected successful complete-vector predictions on COCO clean500. All examples use the primary UniCounting decoder with the fixed seed-17 checkpoint and thresholds selected on inner45. Colored contours indicate the representatives of admitted proposal components, and the accompanying summaries compare all nonzero ground-truth and predicted coordinates. The examples were filtered using fixed correctness and consolidation-complexity criteria and then selected for visual legibility and diversity; they are intended to illustrate successful behaviors rather than estimate average performance. Ground-truth annotations are used only for visualization and evaluation.
| Feature | Definition | Feature | Definition |
|---|---|---|---|
| 1 | 9 | clip()/5 | |
| 2 | 10 | ||
| 3 | 11 | clip() | |
| 4 | 12 | clip() | |
| 5 | 13 | ||
| 6 | 14 | ||
| 7 | 15 | ||
| 8 | 16 | 1 |
Candidate Generation
The same 24-point grid, zero crop layers, and no-tiling path is applied to every image. Candidates are processed greedily in descending predicted IoU for near-duplicate removal; exact predicted-IoU ties preserve the mask generator's output order. The formal decoder contains no density, resolution, count-bin, or ground-truth-dependent router.
Category and Relation Heads
COCO category prototypes average seven templates: a photo of a {}., a photo of the {}., a close-up photo of a {}., a cropped photo of a {}., a photo of one {}., an image of a {}., and a {} in the scene.. FSC-147 and OmniCount use a photo of {phrase}., a close-up photo of {phrase}., multiple {phrase}., a group of {phrase}., and cropped {phrase}.. FSC-147 combines canonical, alias, and description prototype groups with weights 0.50/0.25/0.25; OmniCount uses canonical taxonomy names only. For each of the seven background concepts in , averages the normalized embeddings of a photo of {}., a cropped photo of {}., and {} in the scene..
| Setting | Value |
|---|---|
| GPU / memory | NVIDIA GeForce RTX 4090 / 24,564 MiB (approximately 24 GB) |
| CPU | Intel Core i9-14900KF |
| System memory | 62 GiB available (approximately 64 GB physical memory) |
| Operating system | Ubuntu 24.04.4 LTS under WSL2 |
| Linux kernel | 6.6.114.1-microsoft-standard-WSL2 |
| Python | 3.12.3 |
| NVIDIA driver / supported CUDA | 591.86 / 13.1 |
| PyTorch / build | 2.12.0+cu130 / 13.0 |
| CUDA | |
| torchvision / cuDNN | 0.27.0+cu130 / 9.2.0 |
Hardware and software environment used for the experiments.
Directed relation features. Let and be the L2-normalized DINOv2 (Oquab et al. 2024) and OpenCLIP (Radford et al. 2021; Cherti et al. 2023) embeddings for view (masked, box, and context), let be mask area in pixels, and let be image area. We define as the SAM 2.1 predicted-IoU score returned for candidate . The stability score is used only for the 0.8 candidate-filtering threshold in Table S2 and is not part of . With , the feature order for is fixed as follows. The reverse feature is constructed by exchanging and in every row; in particular, Features 7–8, 11–12, and 13–14 exchange positions, while Feature 9 changes sign before clipping. Each dimension is centered by its relation-training mean and divided by its relation-training standard deviation after clamping that denominator below at . Feature 16 is therefore identically zero after standardization. It is retained only as an inactive compatibility placeholder and does not affect the logits; constant offsets are already supplied by the MLP biases.
Pseudo-Label Construction
For candidate and non-ignore ground-truth instance , define intersection-over-union, candidate purity, and ground-truth coverage as
The matched instance is , with the lower stored GT index breaking exact ties, and denotes the second-largest non-ignore purity. Candidate is reliable exactly when , , and its total overlap with ignore or crowd regions is at most . Same-category and same-instance pair targets compare the category and instance identities of reliable candidates. A di-
| Edge score | threshold | vector | micro-F1↑ |
|---|---|---|---|
| Mask containment | 0.005 | 12.5333 | 0.4289 |
| Mask IoU | 0.005 | 15.8222 | 0.3920 |
| CLIP cosine | 0.500 | 7.2444 | 0.4632 |
| DINO cosine | 0.310 | 7.1185 | 0.4160 |
| Relation-head score | 0.465 | 6.7930 | 0.4260 |
Table S4: Frozen threshold selection for the controlled edge-score study in inner45. Mask containment is , whereas mask IoU is . CLIP and DINO use cosine similarity between normalized 0.05 masked-view plus 0.95 box-view features.
| Method | Vector | Micro-F1↑ |
|---|---|---|
| Zero vector | 6.447 | 0.000 |
| UniCounting | 6.715±0.123 | 0.283±0.011 |
Table S5: OmniCount-sub complete-vector diagnostic. Both rows predict the same 191-dimensional vector. OmniCount-sub is a project holdout used only as a transfer diagnostic, not as an official benchmark.
rected completeness positive additionally requires both reliable proposals to match the same instance, containment , and a GT-coverage advantage of at least 0.2 for the larger-coverage proposal. No additional proposal-status classes or heuristic proposal labels are introduced.
| Setting | Value |
|---|---|
| DINOv2 checkpoint | facebook/dinov2-small, re-vision prefix ed25f3a |
| CLIP checkpoint | ViT-B-32laion2b_s34b_b79k, snapshot prefix 1a25a44 |
| Masked background fill | black |
| Context expansion / CLIP resolution | half a box width and height / 224 × 224 |
| Proposal feature weights | 0.05 masked + 0.95 box, then L2 normalization |
| Activation / normalization / dropout | GELU / training-set standardization / 0.1 |
| Relation feature dimension | 16 directed pair features |
| Relation MLP dimensions / parameters | 16 → 64 → 32, three biased 32 → 1 outputs / 1,088+2,080+99 = 3,267 |
| Pair rows / pruning | both directions of every reliable unordered pair / none before scoring |
Table S3: Feature extraction and trainable-head architecture.
Training and Decoding
The category head remains fixed. Every reliable unordered pair contributes the directed rows and , giving 91,016 rows from 45,508 pairs. Same-category and same-instance targets are duplicated across directions, so their directed positive/negative supports are 74,838/16,178
| Method / seed | TP | FP | FN | Micro-P | Micro-R | Micro-F1 |
|---|---|---|---|---|---|---|
| OWLv2-All80 | 432 | 202 | 1015 | 0.681 | 0.299 | 0.415 |
| UniCounting / 17 | 429 | 187 | 1,018 | 0.696 | 0.296 | 0.416 |
| UniCounting / 42 | 418 | 165 | 1,029 | 0.717 | 0.289 | 0.412 |
| UniCounting / 73 | 420 | 125 | 1,027 | 0.771 | 0.290 | 0.422 |
Table S6: Pooled image–category presence diagnostics on COCO clean500. TP, FP, and FN are reported for each prediction vector; precision, recall, and F1 are computed from those pooled counts. Its low micro-F1 is primarily associated with low micro recall rather than excessive false-positive presence.
and 45,628/45,388. Proposal-completeness targets remain directional, with 1,269 positives and 89,747 negatives: only when is the higher-coverage proposal satisfying the containment and coverage-gap rule. For branch , let and collect the logits and targets of its directed rows, and let and denote its positive and negative supports. The BCEWithLogits call uses pos_weight = , where . Writing this weighted loss as BCEWithLogits, the training objective is
Binary cross-entropy is applied to every directional logit before any direction averaging. The relation head is trained for 80 deterministic full-batch epochs with AdamW, learning rate , weight decay , and dropout 0.1. At inference, the same-category and same-instance logits are averaged across directions before the sigmoid, whereas completeness retains both directions for its diagnostic representative rule. Decoder choices and thresholds are selected only on the disjoint inner45 split using the staged criteria in the main paper.
UniCounting uses the same-instance score from the jointly trained relation head, top2-OR sparsification, union-find components, maximum-category-margin representative selection, representative raw-cosine labeling, and seven-concept background-margin admission. For relation-head seeds 17, 42, and 73, is 0.410, 0.400, and 0.400, and is -0.045626, -0.035712, and -0.017443. An admitted component adds one to its assigned category; a rejected component adds zero everywhere. Candidate indices follow fixed cache order, pair indices follow ascending upper-triangular enumeration, and vocabulary indices follow the released class list. Exact ties use the lower pair, candidate, or vocabulary index, respectively; equality at either threshold is accepted, and all eligible edges are retained when an endpoint has fewer than two.
Diagnostic decoder definitions. Let and be the direction-averaged sigmoid outputs. The “hard semantic instance” graph admits pair exactly when and , ranks eligible edges by , and then applies top2-OR. For seeds 17/42/73, is 0.920/0.940/0.940 and is 0.410/0.400/0.400. Exact edge-score ties use the lower ascending upper-triangular pair index.
For learned-completeness representative selection, let , where is the logistic sigmoid. Within a component , each candidate receives
and the representative maximizes ; ties are broken by the candidate's largest raw category cosine and then by the negative candidate index. Thus, exact remaining ties select the lower candidate index.
For component , define the representative-evidence vector , and let and be its largest and second-largest entries. The cosine-margin conjunction admits when and . For seeds 17/42/73, is (0.243097, 0.011030), (0.235304, 0.006040), and (0.243339, 0.007480). For component-support F1, one decoded component is one binary item: its target is positive exactly when it contains at least one reliable proposal, and its prediction is positive exactly when the conjunction admits it. Component-level TP, FP, and FN counts are pooled across inner45. Each threshold pair is selected from the 41-quantile Cartesian grid by this F1, then precision, then the smaller sum of the two thresholds. Across admission rules, mean inner45 micro-F1 is the selection metric and lower vector is the tie-break.
Extended Results
Evaluation Splits and Detector Protocols
Clean500 is formed by sorting the 4,940 eligible val2017 file names by SHA256(salt|file_name), after excluding the clean60 diagnostic identities, and taking the first 500. The salt is exp-v10-coco-val-clean500-v1-20260725.
The selection procedure reads no annotation, prediction, or metric, and clean500 overlaps clean60 in zero images. All thresholds are selected on inner45 and frozen before preprocessing any clean500 or transfer-set image. Ground-truth annotations are loaded only after the prediction files have been finalized.
Unless a table states otherwise, relation-head rows report the mean and sample standard deviation of the three relation-seed point estimates. Clean500 macro-F1 support contains 78 of the 80 COCO categories; toaster and hair drier are excluded because they have no positive ground-truth cells. Each paired confidence interval uses 10,000 image-bootstrap replicates with seed 20260725. Within a replicate, the same resampled image multiplicities are applied to every method and relation seed, each metric is recomputed separately for each seed, and the seed-wise metrics are then averaged. Macro-F1 support is recomputed within every replicate, and categories with zero positives in that replicate are excluded from its
| Grouping rule | Pair F1↑ | Purity↑ | Merge error↓ | Comp./instance↓ | Fragmented↓ | Rep. IoU↑ |
|---|---|---|---|---|---|---|
| No grouping / singletons | 0.0000 | 1.0000 | 0.0000 | 4.0770 | 0.6320 | 0.1680 |
| Mask containment | 0.6910 | 0.9090 | 0.1150 | 1.4150 | 0.1350 | 0.2020 |
| Mask IoU | 0.4984 | 0.9558 | 0.0515 | 1.8104 | 0.2282 | 0.1758 |
| CLIP cosine | 0.5040 | 0.6740 | 0.4680 | 1.6320 | 0.4300 | 0.1450 |
| DINO cosine | 0.6270 | 0.6510 | 0.5060 | 1.1950 | 0.1690 | 0.1760 |
| Relation-head score + overlap guard | 0.6820 | 0.8500 | 0.1660 | 1.4180 | 0.1830 | 0.2030 |
| Relation-head score | 0.6940 | 0.9250 | 0.1550 | 1.0370 | 0.0360 | 0.2150 |
Table S7: Full pre-admission partition diagnostics for the controlled edge and grouping ablation on COCO clean500. Rows follow Table 2 of the main paper. Every value is the arithmetic mean of seed-specific point metrics for seeds 17, 42, and 73. The candidate pool, pair universe, graph construction, representative rule, and labeling rule are fixed; only the edge score, common edge threshold, or stated grouping control changes. Admission is not applied for these partition diagnostics.
(a) Protocol comparison
| Method | Inference-time category input | Category space | Output form | Direct complete-vector comparison |
|---|---|---|---|---|
| ABC123 (Hobley and Prisacariu 2024) | None | Image-specific discovered types | Anonymous multi-type counts | No |
| OCCAM (Spanakis, Oikono-midis, and Argyros 2026) | None | Image-specific discovered types | Anonymous multi-type counts | No |
| OmniCount | Image-dependent category or point cue | Queried semantic categories | Named queried counts | Partial |
| OWLv2 (AllK) | Fixed K-class list | Run-level global named vocabulary | Complete K-vector after detection | Yes |
| UniCounting | None | Run-level global named vocabulary | Complete K-vector with group evidence | Yes |
(b) Cross-protocol single-coordinate diagnostics
| Method | Per-image cue | FSC-147 | CARPK (Hsieh, Lin, and Hsu 2017) | ||
|---|---|---|---|---|---|
| MAE↓ | RMSE↓ | MAE↓ | RMSE↓ | ||
| CountGD (Amini-Naieni, Han, and Zisserman 2024) | Image-dependent text/exemplar | 5.74 | 24.09 | 3.68 | 5.17 |
| OmniCount (Mondal et al. 2025) | Image-dependent point prompt | 19.24 | 115.27 | 10.66 | 13.15 |
| OCCAM-S (Spanakis, Oikonomidis, and Argyros 2026) | none | 16.92 | 110.83 | 10.06 | 13.81 |
| UniCounting | none | 26.409±0.008 | 120.717±0.006 | 4.057 | 5.509 |
Table S8: Protocol comparison and cross-protocol transfer diagnostics. UniCounting follows the run-level vocabulary protocol defined in Section 3.1 of the main paper. Panel (a) distinguishes the inference-time category input and output space of each method; direct comparability means evaluation against a complete vector over a run-level global named vocabulary. ABC123 is omitted from panel (b) because its reported FSC-147 transfer result uses only images containing fewer than 300 objects rather than the full test split. OCCAM-S is the single-class OCCAM configuration reported by Spanakis, Oikonomidis, and Argyros (2026). UniCounting's FSC-147 values are mean±sample standard deviation over three relation-head seeds. CARPK is reported from a single deterministic run; seed variability was not evaluated. These are single-coordinate transfer diagnostics rather than complete-vector evaluations; methods differ in their inference-time category inputs.
| Stage | Variant | Inner45 | COCO clean500 | OmniCount-sub 2K | |||
|---|---|---|---|---|---|---|---|
| Micro-F1↑ | Micro-F1↑ | Micro-F1↑ | |||||
| Graph | hard semantic ∧ instance | 32.978±0.868 | 0.300±0.003 | 30.597±1.040 | 0.291±0.003 | 26.553±1.073 | 0.144±0.003 |
| same-instance edges, all | 6.889±0.000 | 0.365±0.000 | 6.686±0.000 | 0.342±0.000 | 6.769±0.000 | 0.257±0.000 | |
| same-instance edges, top2★ | 6.867±0.059 | 0.417±0.005 | 6.810±0.010 | 0.350±0.002 | 6.976±0.009 | 0.250±0.002 | |
| Represent. | maximum area | 7.296±0.078 | 0.332±0.008 | 6.837±0.011 | 0.345±0.002 | 7.293±0.012 | 0.144±0.003 |
| learned completeness | 7.400±0.102 | 0.323±0.007 | 6.858±0.003 | 0.339±0.003 | 7.305±0.014 | 0.141±0.003 | |
| max-category-margin★ | 6.837±0.090 | 0.423±0.004 | 6.549±0.016 | 0.413±0.004 | 6.930±0.011 | 0.265±0.000 | |
| Labeling | component-mean category | 7.667±0.059 | 0.262±0.003 | 7.227±0.029 | 0.246±0.005 | 7.562±0.012 | 0.053±0.004 |
| representative raw cosines★ | 6.837±0.090 | 0.423±0.004 | 6.549±0.016 | 0.413±0.004 | 6.930±0.011 | 0.265±0.000 | |
| Admission | none | 6.837±0.090 | 0.423±0.004 | 6.549±0.016 | 0.413±0.004 | 6.930±0.011 | 0.265±0.000 |
| background-margin★ | 6.793±0.051 | 0.426±0.007 | 6.485±0.058 | 0.416±0.005 | 6.715±0.123 | 0.283±0.011 | |
| cosine + margin conjunction | 6.785±0.046 | 0.424±0.004 | 6.467±0.014 | 0.412±0.000 | 6.680±0.018 | 0.287±0.002 | |
Table S9: Complete decoder selection and frozen target-set audit. Inner45 is the only split used for selecting graph construction, representative, labeling, and admission variants. In the graph block, the representative is maximum-category-margin, labeling uses its raw cosines, and admission is disabled. The representative block carries forward the starred graph and uses representative raw-cosine labeling without admission; the labeling block additionally carries forward the starred representative; and the admission block carries forward all preceding starred choices. The clean500 and OmniCount-sub columns are reported only after all choices are frozen. Stars denote the variants selected on inner45; target-set winners are not used for model selection.
macro average. The reported 95% interval is the percentile interval over the seed-averaged replicates.
OWLv2-All80 (Minderer, Gritsenko, and Houlsby 2023) uses the fixed google/owlv2-base-patch16-ensemble checkpoint at the revision whose SHA begins cfd3195b; the full hash is provided with the accompanying artifacts. All 80 raw official COCO thing-category names are passed in one identical list for every image, without aliases or a prompt ensemble. Snapshot-native preprocessing and processor decoding are followed by classwise batched_nms at IoU 0.50. Every detection with score strictly above 0.350 contributes one count. The threshold is selected from 201 points on inner45 by minimum vector , then maximum micro-F1 and the higher threshold as ties. Its inner45 vector is 3.6889 and micro-F1 is 0.7843. Clean500 is not used for calibration.
The fully supervised reference uses torchvision Faster R-CNN with a ResNet-50-FPN v2 backbone and the FasterRCNN_ResNet50_FPN_V2 COCO_V1 weights (Ren et al. 2015). The released checkpoint SHA-256 begins dd69338a. Official preprocessing is followed by explicit classwise NMS at IoU 0.50, and detections are mapped from the torchvision label space to the canonical COCO80 coordinates. A strict score threshold of 0.775 is selected from 191 points on inner45 by minimum complete-vector , then maximum micro-F1 and the higher threshold as ties. Its inner45 vector is 2.3111 and micro-F1 is 0.8800. No clean500 annotation or metric is accessed before its predictions are sealed. This model uses full COCO box supervision and is therefore a supervised reference rather than a matched-training baseline.
Controlled Edge and Grouping Ablation
The controlled study fixes the candidate pool and unordered-pair universe together with the top2-OR rule, connected-component construction, maximum-category-margin representative rule, representative raw-cosine labeling rule, and run-matched background-margin admission rule. Five score rows apply these procedures after replacing only the pair score and its scalar threshold. The singleton control removes every edge, while the overlap guard additionally requires strictly positive mask intersection. A single threshold shared across seeds 17, 42, and 73 is selected for each score on the same 45-image inner-validation split. Selection minimizes three-seed mean vector , with mean micro presence F1 and then the higher threshold used as ties. The target tests are not consulted.
Table 2 of the main paper reports end-task metrics for the five edge scores together with the singleton and overlap-guard controls, while Table S8 reports their full partition diagnostics. Mask IoU uses the common threshold 0.005 selected in Table S4. The relation-head score uses the common threshold selected in the same table, whereas UniCounting uses the run-specific thresholds listed above.
Grouping diagnostic protocol. All grouping metrics are computed before category admission. Ground-truth masks are used only for post hoc evaluation, not for prediction. Let denote candidates satisfying the reliable-match rule above, retain for the matched non-ignore GT instance of reliable candidate , and let be the component partition. For , define and . Only components in enter purity and merge error.
For Pair F1, every unordered pair of reliable candidates is GT-positive when its two matched-instance indices agree and predicted-positive when both candidates lie in the same component. Counts are pooled across all images before computing
Let . Component purity and merge error are
Thus, purity is weighted by reliable-candidate count, whereas merge error gives each evaluable component one vote. Let be the supported GT instances and . Components per instance and Fragmented are
Their denominator excludes annotated instances with no reliable candidate. For every component, define
(S7)
with the lower stored GT index breaking exact ties. If is the selected representative, the reported aggregate is
Thus, each evaluable component across all images receives one vote. Pair counts are pooled before F1, and each reported relation-head metric is computed per seed and then averaged over the three relation-head seeds.
Candidate recall uses all retained pre-grouping proposals, without the reliable-candidate filter. For non-ignore ground-truth instance , let over every candidate from the same image. At threshold , the reported micro recall is
where G pools all non-ignore instances across clean500. Thus 62.4% at t = 0.50 and 48.8% at t = 0.75 measure the candidate-generation ceiling before edge scoring, grouping, representative selection, labeling, or admission.
Complete-Vector Transfer Diagnostic
OmniCount-sub is a sparse transfer diagnostic in which the zero vector obtains lower vector by predicting no positive coordinates, while UniCounting recovers nonzero category presence. This contrast shows why vector error should be interpreted jointly with presence F1.