{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/represent-compare-and-learn-a-similarity","title":"Represent, Compare, and Learn: A Similarity-Aware Framework for Class-Agnostic Counting","arxiv_id":"2203.08354","date":"2022-03-16","proceeding":"CVPR 2022 1","authors":["Min Shi","Hao Lu","Chen Feng","Chengxin Liu","Zhiguo Cao"],"abstract":"Class-agnostic counting (CAC) aims to count all instances in a query image given few exemplars. A standard pipeline is to extract visual features from exemplars and match them with query images to infer object counts. Two essential components in this pipeline are feature representation and similarity metric. Existing methods either adopt a pretrained network to represent features or learn a new one, while applying a naive similarity metric with fixed inner product. We find this paradigm leads to noisy similarity matching and hence harms counting performance. In this work, we propose a similarity-aware CAC framework that jointly learns representation and similarity metric. We first instantiate our framework with a naive baseline called Bilinear Matching Network (BMNet), whose key component is a learnable bilinear similarity metric. To further embody the core of our framework, we extend BMNet to BMNet+ that models similarity from three aspects: 1) representing the instances via their self-similarity to enhance feature robustness against intra-class variations; 2) comparing the similarity dynamically to focus on the key patterns of each exemplar; 3) learning from a supervision signal to impose explicit constraints on matching results. Extensive experiments on a recent CAC dataset FSC147 show that our models significantly outperform state-of-the-art CAC approaches. In addition, we also validate the cross-dataset generality of BMNet and BMNet+ on a car counting dataset CARPK. Code is at tiny.one/BMNet","url_abs":"https://arxiv.org/abs/2203.08354v1","url_pdf":"https://arxiv.org/pdf/2203.08354v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"represent-compare-and-learn-a-similarity","repo_url":"https://github.com/flyinglynx/Bilinear-Matching-Network","is_official":1,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"object-counting","task_name":"Object Counting"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[{"leaderboard":"/sota/object-counting-on-carpk","task":"Object Counting","dataset":"CARPK","model":"BMNet+","rank_in_archive_order":5,"of":15,"metrics":{"MAE":"5.76","RMSE":"7.83"},"uses_additional_data":false},{"leaderboard":"/sota/object-counting-on-fsc147","task":"Object Counting","dataset":"FSC147","model":"BMNet+","rank_in_archive_order":13,"of":19,"metrics":{"MAE(test)":"14.62","MAE(val)":"15.74","RMSE(test)":"91.83","RMSE(val)":"58.53"},"uses_additional_data":false}],"syntology":{"syntology_url":"https://syntology.ai/paper/2203.08354","atlas_url":"https://app.syntology.ai/?focus=2203.08354","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2203.08354"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-25T09:33:49+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/flyinglynx/Bilinear-Matching-Network","reach":null}],"summary":{"unverified":1},"by_repo_kind":{"official":{"samples":1,"ran":0,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"94a136237600556e","entry":"BilinearSimilarityMatcher","repo":"flyinglynx/Bilinear-Matching-Network","repo_kind":"official","path":"models/matcher.py","file_url":"https://github.com/flyinglynx/Bilinear-Matching-Network/blob/HEAD/models/matcher.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"94a136237600556e"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}