Contrastive learning with multi-centroid proxy loss for domain adaptive cattle identification
Abstract
Visual identification of cattle in the wild is essential to provide continuous individual monitoring applicable to precision livestock farming. Supervised learning heavily relies on annotation, which is really a time-consuming work for cattle labeling. Domain adaptive cattle identification aims at transferring knowledge learned from the source domain with rich annotations to the unlabeled target domain. Pseudo-label-based contrastive learning with a unique centroid inevitably incorporates information from different identities due to imperfect clustering. Thus, a contrastive learning with multi-centroid proxy (CL-MCP) for domain adaptive cattle identification was proposed with more local centroids to enhance the reliability of pseudo-labels for a more compact cluster in the target feature space. Firstly, a target domain feature storage module and a momentum update strategy were proposed to progressively update the target domain features for effective training with a stable clustering space. Secondly, a multi-centroid storage module and a proxy representation method were proposed to learn more informative local clusters and provide a representative proxy for each class to efficiently form correct clusters in the feature space. Finally, the domain-specific proxy-level contrastive loss was presented to enlarge the similarity between a query and its positive proxy while reducing the similarities among the query and its negative proxies for more compact clustering. It is encouraging to find that our CL-MCP mechanism performs better than Deep Metric Learning (DML) approaches for identifying individuals from different farms or unseen viewpoints or of a new breed. The datasets, MVCAID100, CNSID100, and Cattle-2022, are available on https://pan.baidu.com/s/19hoWd__7NMLvdLNp-otDSRg (code: d3oa). The results of this study can provide an effective cattle identification method applicable to automated production monitoring, behavioral and physiological observation, health and welfare supervision in precision livestock farming, and animal science research.
Keywords: cattle identification, precision livestock farming, unsupervised domain adaptation (UDA), contrastive learning; unsupervised learning
DOI: 10.25165/j.ijabe.20261901.9242
Citation: Zhao J M, Lian Q S, Zhao Y F. Contrastive learning with multi-centroid proxy loss for domain adaptive cattle identification. Int J Agric & Biol Eng, 2026; 19(1): 187–196.References
[1] Awad A I. From classical methods to animal biometrics: A review on cattle identification and tracking. Computers and Electronics in Agriculture, 2016; 123: 423–435.
[2] Qiao Y L, Kong H, Clark C, Lomax S, Su D, Eiffert S, et al. Intelligent perception for cattle monitoring: A review for cattle identification, body condition score evaluation, and weight estimation. Computers and Electronics in Agriculture, 2021; 185: 106143.
[3] Andrew W, Gao J, Mullan S, Campbell N, Dowsey A W, Burghardt T. Visual identification of individual Holstein-Friesian cattle via deep metric learning. Computers and Electronics in Agriculture, 2021; 185: 106133.
[4] Andrew W, Greatwood C, Burghardt T. Visual localization and individual identification of Holstein-Friesian cattle via deep learning. In: 2017 IEEE International Conference on Computer Vision Workshops (ICCVW), Venice: IEEE, 2017; pp.2850–2859. doi: 10.1109/ICCVW.2017.336.
[5] Zhao J M, Lian Q S. Compact loss for visual identification of cattle in the wild. Computers and Electronics in Agriculture, 2022; 195: 106784.
[6] Zhao J M, Lian Q S, Xiong N N. Multi-center agent loss for visual identification of Chinese Simmental in the wild. Animals, 2022; 12(4): 459.
[7] Zhao J M, Lian Q S. Multi-centers softmax reciprocal average precision loss for deep metric learning. Neural Computing and Application, 2023; 35(16): 11989–11999.
[8] Wang Y W, Mücher S, Wang K W, Wang W S, Kooistra L. Deep metric learning for individual cattle identification using coat patterns: Proposal for a best practice. Computers and Electronics in Agriculture, 2025; 238: 110754.
[9] Ge Y X, Zhu F, Chen D P, Zhao R, Li H S. Self-paced contrastive learning with hybrid memory for domain adaptive object re-id. arXiv, 2014; arXiv: 2006.02713. doi: 10.48550/arXiv.2006.02713.
[10] Wu Y H, Huang T T, Yao H T, Zhang C, Shao Y J, Han C C, et al. Multi-centroid representation network for domain adaptive person re-ID. In: Proceedings of the 36th AAAI Conference on Artificial Intelligence, 2022; pp.2750-2758. doi: 10.1609/aaai.v36i3.20178.
[11] Kaur A, Kumar M, Jindal M K. Cattle identification with muzzle pattern using computer vision technology: a critical review and prospective. Soft Computing, 2022; 26: 4771–4795.
[12] Kaur A, Kumar M, Jindal M K. Shi-Tomasi corner detector for cattle identification from muzzle print image pattern. Ecological Informatics, 2022; 68: 101549.
[13] Kumar S, Chaube M K, Kumar S. Secure and sustainable framework for cattle recognition using wireless multimedia networks and machine learning techniques. IEEE Transactions on Sustainable Computing, 2022; 7(3): 696–708.
[14] Kumar S, Kumar S, Shafi M, Chaube M K. A novel multimodal framework for automatic recognition of individual cattle based on hybrid features using sparse stacked denoising autoencoder and group sparse representation techniques. Multimedia Tools and Applications, 2022; 81(21): 31075–31106.
[15] Kumar S, Pandey A, Sai Ram Satwik K, Kumar S, Singh S K, Singh A K, Mohan A. Deep learning framework for recognition of cattle using muzzle point image pattern. Measurement, 2018; 116: 1–17.
[16] Kumar S, Singh S K. Automatic identification of cattle using muzzle point pattern: A hybrid feature extraction and classification paradigm. Multimedia Tools and Applications, 2017; 76: 26551–26580.
[17] Kumar S, Singh S K, Singh R S, Singh A K, Tiwari S. Real-time recognition of cattle using animal biometrics. Journal of Real-Time Image Processing, 2017; 13(3): 505–526.
[18] Li G M, Erickson G E, Xiong Y J. Individual beef cattle identification using muzzle images and deep learning techniques. Animals, 2022; 12(11): 1453.
[19] Noviyanto A, Arymurthy A M. Beef cattle identification based on muzzle pattern using a matching refinement technique in the SIFT method. Computers and Electronics in Agriculture, 2013; 99: 77–84.
[20] Lu Y, He X F, Wen Y, Wang P. A new cow identification system based on iris analysis and recognition. International Journal of Biometrics, 2014; 6: 18–32.
[21] Sun S N, Yang S C, Zhao L D. Noncooperative bovine iris recognition via SIFT. Neurocomputing, 2013; 120: 310–317.
[22] Saygili A, Cihan P, Ermutlu C Ş, Aydin U, Aydın U. CattNIS: Novel identification system of cattle with retinal images based on feature matching method. Computers and Electronics in Agriculture, 2024; 221: 108963.
[23] Li Z, Lei X M. Cattle face recognition under partial occlusion. Journal of Intelligent and Fuzzy Systems, 2022; 43: 66–77.
[24] Li Z, Lei X M, Liu H. A lightweight deep learning model for cattle face recognition. Computers and Electronics in Agriculture, 2022; 195: 106848.
[25] Weng Z, Meng E S, Liu S Q, Zhang Y, Zheng Z Q, Gong C L. Cattle face recognition based on a two-branch convolutional neural network. Computers and Electronics in Agriculture, 2022; 196: 106871.
[26] Xu B B, Wang W S, Guo L F, Chen G P, Li Y F, Cao Z, et al. CattleFaceNet: A cattle face identification approach based on Retinaface and Arcface loss. Computers and Electronics in Agriculture, 2022; 193: 106675.
[27] Xu B B, Wang W S, Guo L F, Chen G P, Wang Y W, Zhang W J, et al. Evaluation of deep learning for automatic multi-view face detection in cattle. Agriculture, 2021; 11(11): 1062.
[28] Liu P, Zhao J M. Part-attention-based pseudo-label refinement reciprocal compact loss for unsupervised cattle face recognition. Electronics, 2025; 14(12): 2343.
[29] Yang M, Li Q, Zhao J M, Wang Y M, Gao J F, Xue F F. Dual-stream modality prompt network for individual cattle identification. International Journal of Machine Learning and Cybernetics, 2025; 16: 10925–10938.
[30] Li W Y, Ji Z T, Wang L, Sun C H, Yang X T. Automatic individual identification of Holstein dairy cows using tailhead images. Computers and Electronics in Agriculture, 2017; 142: 622–631.
[31] Zhao K X, Jin X, Ji J T, Wang J, Ma H, Zhu X F. Individual identification of Holstein dairy cows based on detecting and matching feature points in body images. Biosystems Engineering, 2019; 181: 128–139.
[32] Yu P, Burghardt T, Dowsey A W, Campbell N W. Holstein-Friesian re-identification using multiple cameras and self-supervision on a working farm. Computers and Electronics in Agriculture, 2025; 237(PartB): 110568.
[33] Chen Y B, Zhu X T, Gong S G. Instance-guided context rendering for cross-domain person re-identification. In: 2019 IEEE/CVF International Conference on Computer Vision (ICCV), Seoul: IEEE, 2019; pp.232–242. doi: 10.1109/ICCV.2019.00032.
[34] Wei L H, Zhang S L, Gao W, Tian Q. Person transfer GAN to bridge domain gap for person re-identification. In: 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition, Salt Lake City: IEEE, 2018; pp.79–88. doi: 10.1109/CVPR.2018.00016.
[35] Zou Y, Yang X D, Yu Z D, Vijaya Kumar B V K, Kautz J. Joint disentangling and adaptation for cross-domain person re-identification. In: European Conference on Computer Vision (ECCV), 2020; pp.87–104. doi: 10.1007/978-3-030-58536-5_6.
[36] Fu Y, Wei Y C, Wang G S, Zhou Y Q, Shi H H, Uiuc U, et al. Self-similarity grouping: A simple unsupervised cross domain adaptation approach for person re-identification. In: 2019 IEEE/CVF International Conference on Computer Vision (ICCV), 2019; pp.6111–6120. doi: 10.1109/ICCV.2019.00621.
[37] Ge Y X, Chen D P, Li H S. Mutual mean-teaching: Pseudo label refinery for unsupervised domain adaptation on person re-identification. International Conference on Learning Representations (ICLR), 2020. doi: 10.48550/arXiv.2001.01526.
[38] Song L C, Wang C, Zhang L F, Du B, Zhang Q, Huang C, et al. Unsupervised domain adaptive re-identification: Theory and practice. Pattern Recognition, 2020; 102: 107173.
[39] Zhang X Y, Cao J W, Shen C H, You M Y. Self-training with progressive augmentation for unsupervised cross-domain person re-identification. In: 2019 IEEE/CVF International Conference on Computer Vision (ICCV), Seoul: IEEE, 2019; pp.8221–8230. doi: 10.1109/ICCV.2019.00831.
[40] Chen X L, He K M. Exploring simple Siamese representation learning. In: 2021 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), Nashville: IEEE, 2021; pp.15745–15753. doi: 10.1109/CVPR46437.2021.01549.
[41] Tian Y L, Krishnan D, Isola P. Contrastive multiview coding. In: European Conference on Computer Vision (ECCV), 2020; pp.776–794. doi: 10.1007/978-3-030-58621-8_45.
[42] Chen T, Kornblith S, Norouzi M, Hinton G. A simple framework for contrastive learning of visual representations. In: International Conference on Machine Learning, 2020; arXiv: 2002.05709. doi: 10.48550/arXiv.2002.05709.
[43] He K M, Fan H Q, Wu Y X, Xie S N, Girshick R. Momentum contrast for unsupervised visual representation learning. In: 2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), Seattle: IEEE, 2020; pp.9726–9735. doi: 10.1109/CVPR42600.2020.00975.
[44] Qian Q, Shang L, Sun B G, Hu J H, Tacoma T, Li H. Softtriple loss: Deep metric learning without triplet sampling. In: 2019 IEEE/CVF International Conference on Computer Vision (ICCV), Seoul: IEEE, 2019; pp.6449–6457. doi: 10.1109/ICCV.2019.00655.
Downloads
Published
How to Cite
Issue
Section
License
Copyright (c) 2026 International Journal of Agricultural and Biological Engineering

This work is licensed under a Creative Commons Attribution 4.0 International License.
IJABE is an international peer reviewed, open access journal, adopting Creative Commons Copyright Notices as follows.
Authors who publish with this journal agree to the following terms:
- Authors retain copyright and grant the journal right of first publication with the work simultaneously licensed under a Creative Commons Attribution License that allows others to share the work with an acknowledgement of the work's authorship and initial publication in this journal.
- Authors are able to enter into separate, additional contractual arrangements for the non-exclusive distribution of the journal's published version of the work (e.g., post it to an institutional repository or publish it in a book), with an acknowledgement of its initial publication in this journal.
- Authors are permitted and encouraged to post their work online (e.g., in institutional repositories or on their website) prior to and during the submission process, as it can lead to productive exchanges, as well as earlier and greater citation of published work (See The Effect of Open Access).