Feed 0% source
AI/ML AI-generated

Count Anything

Generated by a local model (nvidia/Gemma-4-26B-A4B-NVFP4) from a scientific paper, claim-checked against the full text. Provenance is open by design.

If you have ever watched a crowd-counting model fail when faced with a sudden shift in object scale, you know the pain. A model trained on large, sparse pedestrians often collapses when asked to count tiny, dense cells under a microscope. This happens because current counting research is fragmented. Models are usually specialists tied to specific visual domains, scales, or density distributions.

The Problem

Most existing counting models are bound to narrow scenarios. A model that excels at counting vehicles in remote sensing imagery will likely struggle with repetitive textures in agricultural crops. Current approaches generally fall into three buckets, each with a breaking point.

Density-estimation models predict a continuous heatmap (a grayscale map representing object concentration). They are effective for dense crowds but lack "instance-grounding." This means they cannot provide a one-to-one correspondence between a prediction and a specific object. Detection-based models provide clear locations but frequently miss or merge small, crowded, or weakly bounded objects. Point-regression models attempt to find discrete centers. However, they often lack the geometric context needed for large, sparse objects. As shown in, a generalist model must reconcile these conflicting requirements.

Figure 1
Figure 1. Overall framework of the proposed Count Anything. where ˆpn and ˆsn denote the location and confidence score of the n-th predicted instance. The final count is the cardinality of this set, i.e., ˆcT = | ˆPT |.

It must follow a natural-language query while providing spatial evidence for every count.

How It Works

The authors propose "Count Anything," a model that rejects the idea of a single counting representation. Instead, they implement a dual-granularity architecture. This design treats sparse and dense counting as complementary tasks.

  1. Text-Conditioned Encoding: The model uses a backbone based on SAM3 (a pretrained segment-anything model) to extract visual features. These features are conditioned on the user's text query. This allows the model to focus on the specific semantic concept requested.
  2. Region-level Sparse Counter (RSC): This branch uses a DETR-like (Detection Transformer) architecture. It predicts bounding boxes and their centers. It acts as an "anchor" logic. It provides stable geometric bounds for large, sparse, or clearly defined objects.
  3. Pixel-level Dense Counter (PDC): The PDC handles cases where the RSC fails, such as tiny, overlapping cells. It operates on high-resolution features. It performs dense point-level enumeration. It predicts coordinate offsets relative to a spatial grid to capture small, weakly bounded targets.
  4. Complementary Count Fusion (CCF): Both branches might predict the same object. To prevent this, the model uses a parameter-free fusion rule during inference. As illustrated in, if an RSC region and a PDC point overlap, the model compares their confidence scores.
Figure 2
Figure 2. Illustration of CCF. Each RSC prediction is compared with the nearest PDC point inside its region, and only the higher-confidence one is kept. During inference, RSC and PDC produce region-level candidates and dense point candidates, respectively.

It suppresses the lower-confidence prediction. This prevents the "double-counting" error found when simply unioning the two sets.

The model is trained using "point-centric supervision." This allows the researchers to ingest messy, real-world data. It unifies heterogeneous annotations—like bounding boxes, polygons, and masks—into a single training signal. Every valid instance is supervised by a central point.

Numbers

The authors evaluate their model on a massive new dataset called CLOC. This dataset contains 220K images and 15M instances across six domains. The headline result is a significant jump in accuracy. The paper reports a Mean Absolute Error (MAE) of 9.34 and a Root Mean Square Error (RMSE) of 33.34 on the CLOC test split. This substantially outperforms previous open-world methods like CLIP-Count or CountGD++.

For engineers concerned with deployment, the computational footprint is documented in [Table 7]. Under a 1008×1008 input resolution, the model has 848.62M parameters. It requires 5.44 TFLOPs per forward pass. On an RTX 4090, the authors report an average latency of 95.55 ms. Peak memory usage is 6.53 GB. This latency profile makes the model suitable for high-resolution batch processing or interactive inspection tools on modern workstation hardware.

What's Missing

There are gaps that a practitioner should note. First, the model relies heavily on a pretrained text-conditioned visual encoder (SAM3). The paper does not investigate behavior when text queries are highly ambiguous. If your use case involves esoteric scientific jargon, the "text-guided" aspect might become a bottleneck.

Second, the CLOC dataset is imbalanced. The authors admit that visual-domain scales are not perfectly balanced. General Scene and Remote Sensing dominate the dataset. This means the model's "generalist" capabilities might be biased toward these domains. This could lead to higher error rates in smaller domains like Microbiology or Agriculture.

Finally, the CCF fusion rule is a heuristic. The authors note in their ablation studies ([Table 10]) that the choice of neighbor group size is sensitive. In extremely crowded or occluded scenes, the current logic might still struggle to distinguish between a legitimate duplicate and two very closely adjacent instances.

Should You Prototype This

Yes, if your work involves high-precision counting in specialized domains like agriculture, pathology, or remote sensing. The ability to unify heterogeneous annotations into a single training pipeline is a massive operational win. This is particularly useful when dealing with "dirty" real-world data that lacks uniform formats.

The dual-granularity approach is a strong architectural bet for variable-scale objects. If you are currently struggling with a model that misses small objects in dense clusters, the RSC/PDC split is a pattern worth implementing. Code is reportedly available at count-anything. Start by testing it on your domain's "hard" cases. Look specifically for the scale transitions where single-paradigm models typically break.

Figures from the paper

Figure 3
Figure 3. Qualitative comparison of counting predictions. Text prompts are shown on the left, and numbers denote ground-truth or predicted counts. Table 2: Evaluation on crowd counting subtask.
Figure 4
Figure 4. Effect of training data scale. Data scaling. Figure 4 visualizes the effect of CLOC training data scale by plotting MAE and RMSE under different ratios.
Figure 5
Figure 5. Qualitative visualization of Complementary Count Fusion. Orange boxes and points denote RSC predictions, while blue points denote PDC predictions. In the CCF panel, crossed markers indicate suppressed duplicate predictions between the two branches.
Figure 6
Figure 6. Additional qualitative comparisons on the General Scene domain. 22 Count Anything (Ours) Ground Truth CLIP-Count CountGD++ CountSE GroundingDINO SAM3 27 28 68.17 16 47 14 41 “people” 25 25 13.64 0 45 6 35 “airplanes” 10 10 66.73 0 20 1 0 “windmills” 186 204 23.22 14 94 13 92 “storage tanks” “cars”
Novelty
0.0/10
Overall
0.0/10
#object counting#cross-domain#text-guided#dual-granularity#dataset
How this was made
Generation

Model: nvidia/Gemma-4-26B-A4B-NVFP4
Persona: habr_engineer
Refinement: 0
Pipeline: forge-1.0

Verification

Evaluator: nvidia/Gemma-4-26B-A4B-NVFP4
Score: 97% (passed)
Claims verified: 16 / 16

Translation

Model: nvidia/Gemma-4-26B-A4B-NVFP4

Hardware & cost

NVIDIA GB10 · 128 GB unified · NVFP4 · 100% local · $0 cloud
Tokens: 151,672
Wall-time: 433.4s
Tokens/s: 349.9

Next up

W-Switch and W-Composite: Prompt-Aware Weighting for Multi-Concept LoRA Compo...

8.0/10· 6 min