OCCAM: Class-Agnostic, Training-Free, Prior-Free and Multi-Class Object Counting

1 Computer Science Department, University of Crete, Heraklion, Greece 2 Institute of Computer Science (ICS), Foundation for Research & Technology - Hellas (FORTH), Heraklion, Greece
OCCAM Teaser Image

We propose a class-agnostic multi-class object counting approach that takes as input an RGB image and outputs a count of object instances per detected class.

Abstract

Class-Agnostic object Counting (CAC) involves counting instances of objects from arbitrary classes within an image. Due to its practical importance, CAC has received increasing attention in recent years. Most existing methods assume a single object class per image, rely on extensive training of large deep learning models and address the problem by incorporating additional information, such as visual exemplars or text prompts. In this paper, we present OCCAM, the first training-free approach to CAC that operates without the need of any supplementary information. Moreover, our approach addresses the multi-class variant of the problem, as it is capable of counting the object instances in each and every class among arbitrary object classes within an image. We leverage Segment Anything Model 2 (SAM2), a foundation model, and a custom threshold-based variant of the First Integer Neighbor Clustering Hierarchy (FINCH) algorithm to achieve competitive performance on widely used benchmark datasets, FSC-147 and CARPK. We propose a synthetic multi-class dataset and F1 score as a more suitable evaluation metric.

Methodology

OCCAM Pipeline Image

Given an RGB image as input, a dense grid of seed points is constructed, which are passed to SAM2 to produce a collection of binary masks. These masks are then filtered to obtain a refined set of candidate object masks. Each candidate object mask is used to extract an aspect-ratio-preserving bounding box region, which is passed through ResNet50 to produce a feature vector. These vectors are then grouped using a custom threshold-based variant of FINCH algorithm, resulting in a final set of clusters.

Qualitative Results

BibTeX

@misc{spanakis2026occamclassagnostictrainingfreepriorfree,
      title={OCCAM: Class-Agnostic, Training-Free, Prior-Free and Multi-Class Object Counting}, 
      author={Michail Spanakis and Iason Oikonomidis and Antonis Argyros},
      year={2026},
      eprint={2601.13871},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2601.13871}, 
}