A Deep Learning Approach for Cattle Classification to Enhance Livestock Monitoring

Authors

  • Farah Kareem Department of AI and Data Science, FAST National University of Computer and Emerging Sciences (FAST-NUCES), Karachi, Pakistan
  • Syed Umaid Ahmed Department of AI and Data Science, FAST National University of Computer and Emerging Sciences (FAST-NUCES), Karachi, Pakistan
  • Muhammad Farrukh Shahid Department of AI and Data Science, FAST National University of Computer and Emerging Sciences (FAST-NUCES), Karachi, Pakistan
  • M. Hassan Tanveer Department of Robotics and Mechatronics Engineering, Kennesaw State University, Marietta, GA, USA

Keywords:

Cattle Identification, Deep Learning, Convolutional Neural Network, Vision Transformer, Sustainable Agriculture

Abstract

The classification of cattle from frontal face images is an important step toward automated livestock management, disease tracking, and optimization of farm productivity. In this study, we compare the performance of three deep learning architectures, Vision Transformer (ViT), Swin Transformer, and ResNet18, for large-scale, multiclass cattle classification. The proposed system is trained and evaluated on a cow dataset from Karachi, Pakistan, which includes approximately 459 distinct classes, making it one of the largest publicly available cow image datasets. All the models were trained and tested in similar experimental conditions, which ensures a fair comparison. The highest classification accuracy was achieved by the Vision Transformer with 96.27%, compared to 95.86% and 94.48% in both ResNet18 and Swin Transformer, respectively. In addition, the ViT model attained a macro precision of 0.94, recall of 0.95, and F1-score of 0.94, while ResNet18 achieved 0.94, 0.95, and 0.94, and Swin Transformer achieved 0.92, 0.93, and 0.92, respectively. The training process converged within 100 epochs, with final training and validation losses of 0.0176 and 0.2420 for ViT, 0.0228 and 0.2172 for ResNet18, and 0.0527 and 0.3159 for Swin Transformer, indicating stable learning behavior across models. The obtained results indicate that transformer-based architectures effectively capture fine-grained facial features in cattle compared to traditional CNNs. In addition, the Top-5 accuracies of all models were more than 99%, which highlights the appropriateness of all models to large-scale, multiclass cattle identification. Hence, the proposed work illustrates that these models can improve classification accuracy, which will aid in accurate livestock tracking, traceability, and help to identify diseases in their early stages, which will eventually increase productivity and the development of sustainable agriculture. The current research also fits in with the United Nations Sustainable Development Goals, SDG 2 (Zero Hunger) and SDG 12 (Responsible Consumption and Production), as it contributes to effective livestock management and sustainable agricultural practices.

References

Munir Ahmad, Sagheer Abbas, “AI-Driven livestock identification and insurance management system,” Egypt. Informatics J., vol. 24, no. 3, p. 100390, 2023, doi: https://doi.org/10.1016/j.eij.2023.100390.

Guoming Li, Galen E. Erickson, “Individual Beef Cattle Identification Using Muzzle Images and Deep Learning Techniques,” Animals, vol. 12, no. 11, 2022, doi: 10.3390/ani12111453.

Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun, “Deep Residual Learning for Image Recognition,” arXiv:1512.03385, 2015, [Online]. Available: https://arxiv.org/abs/1512.03385

A. Dosovitskiy et al., “An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale,” ICLR 2021 - 9th Int. Conf. Learn. Represent., Oct. 2020, Accessed: May 16, 2024. [Online]. Available: https://arxiv.org/abs/2010.11929v2

Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, Baining Guo, “Swin Transformer: Hierarchical Vision Transformer using Shifted Windows,” arXiv:2103.14030, 2021, [Online]. Available: https://arxiv.org/abs/2103.14030

Christian Lamping, Gert Kootstra, “Transformer-based similarity learning for re-identification of chickens,” Smart Agric. Technol., vol. 11, p. 100945, 2025, doi: https://doi.org/10.1016/j.atech.2025.100945.

Syed Umaid Ahmed, Jaroslav Frnda, “Dataset of cattle biometrics through muzzle images,” Data Br., vol. 53, p. 110125, 2024, doi: https://doi.org/10.1016/j.dib.2024.110125.

Hua Meng, Lina Zhang, “Livestock Biometrics Identification Using Computer Vision Approaches: A Review,” Agriculture, vol. 15, no. 1, p. 102, 2025, doi: https://doi.org/10.3390/agriculture15010102.

Ishana Attri, Lalit Kumar Awasthi, “A review of deep learning techniques used in agriculture,” Ecol. Inform., vol. 77, p. 102217, 2023, doi: https://doi.org/10.1016/j.ecoinf.2023.102217.

“Goal 2: Zero Hunger - United Nations Sustainable Development.” Accessed: Mar. 17, 2026. [Online]. Available: https://www.un.org/sustainabledevelopment/hunger/

“Goal 3 | Department of Economic and Social Affairs.” Accessed: Sep. 02, 2025. [Online]. Available: https://sdgs.un.org/goals/goal3#targets_and_indicators

Md Ekramul Hossain, Muhammad Ashad Kabir, “A systematic review of machine learning techniques for cattle identification: Datasets, methods and future directions,” Artif. Intell. Agric., vol. 6, pp. 138–155, 2022, doi: https://doi.org/10.1016/j.aiia.2022.09.002.

Meghna Luthra, Meghna Sharma, Poonam Chaudhary, “Comprehensive Survey on Cattle Identification Approaches: From Traditional to Deep Learning Aspects,” J. Basic Sci. Eng., vol. 21, no. 1, 2024, [Online]. Available: https://www.yjgkx.org/uploads/archives/f3376599-35f1-46e5-8ad6-29c2269fdb27.pdf

Dongxu Li, Baoshan Li, Qi Li, Yueming Wang, Mei Yang & Mingshuo Han, “Cattle identification based on multiple feature decision layer fusion,” Sci. Rep., 2024, [Online]. Available: https://www.nature.com/articles/s41598-024-76718-x

Y. C. Binghao Ye, “Cow individual identification method based on local feature guided neural network,” CFIMA 2024 - Proc. 2024 2nd Int. Conf. Front. Intell. Manuf. Autom., p. 109718, 2025, [Online]. Available: https://dl.acm.org/doi/10.1145/3704558.3704597

A. Bhujel, Y. Wang, Y. Lu, D. Morris, and M. Dangol, “A systematic survey of public computer vision datasets for precision livestock farming,” Comput. Electron. Agric., vol. 229, p. 109718, Feb. 2025, doi: 10.1016/j.compag.2024.109718.

A. Inam, H. Rehman, M. F. Shahid, and S. U. Ahmed, “Leveraging Artificial Intelligence for Age Prediction in Cattle based on Dentition,” Proc. 2025 4th Int. Conf. Comput. Inf. Technol. ICCIT 2025, pp. 496–501, 2025, doi: 10.1109/ICCIT63348.2025.10989431.

Y. LeCun, L. Bottou, Y. Bengio, and P. Haffner, “Gradient-based learning applied to document recognition,” Proc. IEEE, vol. 86, no. 11, pp. 2278–2323, 1998, doi: 10.1109/5.726791.

Elif Akarsu, Tevhit Karacalı, “Combining Deep Features with Classical Discriminants: High-Accuracy Animal Classification Using ResNet-18 and LDA,” Int. J. Innov. Res. Rev., vol. 9, no. 2, 2025, [Online]. Available: https://www.injirr.com/article/view/253

Shijun Li, Lili Fu, “Individual dairy cow identification based on lightweight convolutional neural network,” PLoS One, 2021, [Online]. Available: https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0260510

Bingxuan Li, Jiandong Fang & Yvdong Zhao, “RTDETR-Refa: a real-time detection method for multi-breed classification of cattle,” J. Real-Time Image Process., vol. 22, 2025, [Online]. Available: https://link.springer.com/article/10.1007/s11554-024-01613-7

W. Andrew, J. Gao, S. Mullan, N. Campbell, A. W. Dowsey, and T. Burghardt, “Visual identification of individual Holstein-Friesian cattle via deep metric learning,” Comput. Electron. Agric., vol. 185, p. 106133, Jun. 2021, doi: 10.1016/j.compag.2021.106133.

N. Kumar and S. K. Singh, “Multi-Directional Shifted Patch Encoding With Transformers for Non-Invasive Cattle Identification,” IEEE Trans. Biometrics, Behav. Identity Sci., vol. 7, no. 4, pp. 620–631, 2025, doi: 10.1109/TBIOM.2025.3599374.

Nidhi Kundu, Geeta Rani, “IoT and Interpretable Machine Learning Based Framework for Disease Prediction in Pearl Millet,” Sensors, vol. 21, no. 16, p. 5386, 2021, doi: https://doi.org/10.3390/s21165386.

Michael Agbo Tettey Soli, Dacosta Agyei, Waliyyullah Umar Bandawu, Leonard Mensah Boante, Justice Kwame Appati, “A Modified Hierarchical Vision Transformer Model for Poultry Disease Detection,” IET Image Process., vol. 19, no. 1, 2025, [Online]. Available: https://ietresearch.onlinelibrary.wiley.com/doi/10.1049/ipr2.70115

Minyue Zhong, Yao Tan, “A Method for Recognition of Cattle Noseprint based Fusing Swin Transformer and Triplet Network,” ACM Int. Conf. Proceeding Ser., 2024, [Online]. Available: https://dl.acm.org/doi/10.1145/3652628.3652716

N. Kumar and S. K. Singh, “CattleDiT: A Distillation-Driven Transformer for Cattle Identification,” IEEE Trans. Biometrics, Behav. Identity Sci., vol. 7, no. 4, pp. 824–836, 2025, doi: 10.1109/TBIOM.2025.3565516.

O. Russakovsky et al., “ImageNet Large Scale Visual Recognition Challenge,” Int. J. Comput. Vis. 2015 1153, vol. 115, no. 3, pp. 211–252, Apr. 2015, doi: 10.1007/s11263-015-0816-y.

D. . Powers, “Evaluation: from precision, recall and F-measure to ROC, informedness, markedness and correlation,” arXiv Prepr. arXiv2010.16061, 2020, [Online]. Available: https://arxiv.org/pdf/2010.16061

G. L. Marina Sokolova, “A systematic analysis of performance measures for classification tasks,” Inf. Process. Manag., vol. 45, no. 4, pp. 427–437, 2009, doi: https://doi.org/10.1016/j.ipm.2009.03.002.

Downloads

Published

2026-05-16

How to Cite

Farah Kareem, Syed Umaid Ahmed, Muhammad Farrukh Shahid, & M. Hassan Tanveer. (2026). A Deep Learning Approach for Cattle Classification to Enhance Livestock Monitoring. International Journal of Innovations in Science & Technology, 8(3), 562–573. Retrieved from https://journal.50sea.com/index.php/IJIST/article/view/1802