تشخیص و دسته‌بندی تیپ گاو بر اساس انحراف انتهای ستون فقرات با استفاده از یادگیری ماشین

نوع مقاله : مقاله پژوهشی

نویسندگان

1 محقق، بخش تحقیقات فنی و مهندسی کشاورزی، مرکز تحقیقات و آموزش کشاورزی و منابع طبیعی استان اصفهان، سازمان تحقیقات، آموزش و ترویج

2 استادیار پژوهش، بخش تحقیقات فنی و مهندسی کشاورزی، مرکز تحقیقات و آموزش کشاورزی و منابع طبیعی استان اصفهان، سازمان تحقیقات، آموزش

3 دانشیار پژوهش، بخش تحقیقات فنی و مهندسی کشاورزی، مرکز تحقیقات و آموزش کشاورزی و منابع طبیعی استان اصفهان، سازمان تحقیقات، آموزش

چکیده

در مزارع پرورش گاو شیری، عملیات یادگیری ماشینی می‌تواند بر اساس امتیازدهی وضعیت بدنی (BCS) با بهره‌گیری از ویژگی‌های استخراج‌شده از تصاویر برای شناسایی و طبقه‌بندی انواع گاوها مورد استفاده قرار گیرد. به‌طور خاص، الگوریتم‌های یادگیری ماشین می‌توانند انحنای ستون فقرات را اغلب با شناسایی نقاط کلیدی و برازش یک خط یا منحنی، تجزیه و تحلیل کنند تا بین نژادهای مختلف گاو تمایز قائل شوند و وضعیت آن را ارزیابی کنند. در این مطالعه، جهت تشخیص و طبقه‌بندی انواع تیپ گاو بر اساس وضعیت انحنای انتهای ستون فقرات (کفل) از مدل‌های یادگیری ماشین که در سال‌های اخیر به‌طور مکرر در علوم کامپیوتر مورد استفاده قرار گرفته‌اند، شامل SVM، KNN و CNN همراه با شبکه از پیش آموزش‌دیده مبتنی بر یادگیری عمیق Resnet50 به‌منظور افزایش موفقیت معماری‌ها استفاده شد. در هر یک از الگوریتم‌ها استخراج و ثبت و ادغام ویژگی‌های تصاویر برای تشخیص نوع تیپ گاوها انجام گرفت و در نهایت الگوریتم CNN از پیش آموزش‌دیده مبتنی بر یادگیری عمیق با بالاترین میزان دقت (93 درصد) توانست نوع تیپ گاو را درست تشخیص دهد. بنابراین می‌توان با تلفیق این سیستم پردازشی با مکانیزم تصویربرداری، امکان تشخیص و طبقه‌بندی گاوها را بر اساس انواع حالات و مشخصات بدنی در محیط‌های گاوداری در مدت زمان کوتاه‌تر، ساده‌تر و کاربرپسند فراهم ساخت. این رویکرد نیاز به استخراج دستی ویژگی‌های دام را حذف می‌کند، بکارگیری نیروی انسانی را کاهش می‌دهد و به‌دقت تشخیص بهبودیافته‌ای دست می‌یابد.

کلیدواژه‌ها

موضوعات


عنوان مقاله [English]

Identifying and classifying cow types based on spinal end deviation using machine learning

نویسندگان [English]

  • mohsen daneshman vaziri 1
  • Abdollah Imanmehr 2
  • mohsen Heidarisoltanabadi 3
1 Researcher, Agricultural Engineering Research Department, Isfahan Agricultural and Natural Resources Research and Education Center, AREEO, Isfahan, Iran..
2 Assistant professor, Agricultural Engineering Research Department, Isfahan Agricultural and Natural Resources Research and Education Center, AREEO, Isfahan, Iran.
3 Associated professor, Agricultural Engineering Research Department, Isfahan Agricultural and Natural Resources Research and Education Center, AREEO, Isfahan, Iran.
چکیده [English]

In dairy farms, machine learning operations can be used to identify and classify cow types based on body condition scoring (BCS) using features extracted from images. In particular, machine learning algorithms can analyze the curvature of the spine, often by identifying key points and fitting a line or curve, to distinguish between different breeds of cattle and assess their condition. In this study, machine learning models that have been frequently used in computer science in recent years, including SVM, KNN, and CNN, were used in conjunction with a pre-trained deep learning network Resnet50 to enhance the success of the architectures. In each of the algorithms, image features were extracted, registered, and merged to identify the type of cows, and finally, the pre-trained CNN algorithm based on deep learning was able to correctly identify the type of cow with the highest accuracy (93 percent). Therefore, by combining this processing system with the imaging mechanism, it is possible to identify and classify cows based on various states and physical characteristics in cattle environments in a shorter, simpler, and more user-friendly time. This approach eliminates the need for manual extraction of livestock features, reduces the use of human resources, and achieves improved recognition accuracy.

کلیدواژه‌ها [English]

  • Body condition scoring
  • cow rump curvature
  • machine learning algorithms
  • convolutional neural network
  • deep learning

EXTENDED ABSTRACT

 

Introduction

Dairy cow body condition scoring (BCS) is a vital management practice used to assess nutritional status, health, and productivity potential. Traditionally, BCS is performed manually by experienced evaluators who rely on visual and tactile cues. However, manual scoring is subjective, time-consuming, and prone to variability and human error, making it impractical for large-scale operations. Advances in computer vision and machine learning have enabled automated BCS systems, offering consistent and objective evaluations. A critical visual marker for BCS estimation is the curvature or deviation of the rump area (the terminal part of the spine). This morphological feature is closely related to body fat reserves and musculoskeletal health. Prior research has used 2D and 3D imaging with regression analysis to automate BCS. Yet many approaches require expensive 3D equipment or involve complex manual feature engineering. Recent developments in convolutional neural networks (CNNs), transfer learning, and pre-trained architectures such as ResNet50 have shown promise in automating feature extraction and classification tasks with high accuracy. The present study aims to design and evaluate a practical, image-based, automated system for intelligent detection and classification of cow types based on rump deviation using machine learning algorithms. The ultimate goal is to provide dairy farms with a low-cost, user-friendly, and real-time tool for BCS-related phenotyping to improve herd management efficiency.

Method

The study employed three machine learning algorithms—Support Vector Machine (SVM), K-Nearest Neighbors (KNN), and a Convolutional Neural Network (CNN) leveraging the ResNet50 architecture—for classifying cows into three types based on rump curvature: upward deviation (A type), downward deviation (B type), and horizontal (C type). A dataset of 150 images was collected from various farms, with 50 images per type, captured using standard digital cameras and smartphones. Images were preprocessed by cropping to isolate the rump area and were labeled and sorted into folders by type. The dataset was split into training, validation, and test sets in an 8:1:1 ratio. Feature extraction for SVM and KNN was performed using ResNet50 as a fixed feature extractor. CNN training used ResNet50 with fine-tuned layers for classification. Experiments were implemented in MATLAB R2021b. Evaluation metrics included accuracy, precision, recall (sensitivity), F1 score, confusion matrices, intersection over union (IoU), and mean average precision (mAP). For each algorithm, predictions on the test set were compared to ground-truth labels to compute performance metrics.

Results

The KNN classifier achieved an overall accuracy of 82%, with an F1 score averaging 81% across classes. Its confusion matrix revealed relatively high false positives, especially between A and C types, resulting in lower overlap scores (mean IoU ~67%). The SVM model showed improved performance, achieving 86% accuracy and an average F1 score of 85%, with better precision-recall balance and higher IoU (~75%). The CNN model using fine-tuned ResNet50 outperformed the others, achieving 91% accuracy, 93% precision, 90% recall, and an F1 score of 90%, with the highest mean IoU (~82%). Confusion matrices demonstrated that CNN produced the lowest misclassification rates among the three algorithms. CNN's high overlap values indicated strong alignment between predicted and actual classes, and its superior F1 score reflected balanced precision and recall. These results underscore the model's ability to extract subtle image features relevant to rump curvature and BCS-related phenotypes. Compared to prior studies reporting accuracies in the 82–97% range (using depth cameras, attention mechanisms, or multimodal data), this approach demonstrated comparable or better performance with simple 2D imaging and transfer learning. The system reduces manual feature engineering, enables real-time classification, and supports scalable deployment in dairy farms.

Conclusion

This study demonstrates the feasibility and effectiveness of using machine learning—particularly CNN with ResNet50—for automated classification of cow types based on rump curvature, serving as a proxy for body condition scoring. Among the tested methods, CNN–ResNet50 achieved the highest accuracy (91%) and F1 score (90%), outperforming KNN and SVM classifiers. The proposed system offers a practical, low-cost solution that eliminates the need for manual scoring, reduces labor, minimizes subjective error, and facilitates real-time herd management. Such tools can help dairy farmers make timely decisions on feeding and health interventions, ultimately improving productivity and animal welfare. Future work could expand the dataset, incorporate multimodal imaging, and deploy the model in field conditions to validate robustness and generalizability. Overall, the study confirms that deep learning with transfer learning on 2D RGB images can reliably support precision livestock farming by automating BCS estimation from visually salient anatomical markers like rump curvature.

Author Contributions

Conceptualization, M.D.V. and A.I.; methodology, M.D.V., A.I. and M.H; software, M.D.V. and A.I; validation, M.D.V., A.I. and M.H; investigation, M.D.V and A.I.; resources, M.H; data curation, A.I; writing—original draft preparation, M.D.V. and A.I; writing—review and editing, A.I.; visualization, M.D.V.; supervision, A.I.; project administration, A.I.; funding acquisition, A.I., All authors have read and agreed to the published version of the manuscript.

Data Availability Statement

Data available on request from the authors.

Acknowledgements

The authors gratefully acknowledge the technical support from Isfahan Agricultural and Natural Resources Research and Education Center.

Ethical considerations

The authors avoided data fabrication, falsification, plagiarism, and misconduct.

Conflict of interest.

The author declares no conflict of interest.

Alvarez, J. R., Arroqui, M., Mangudo, P., Toloza, J., Jatip, D., Rodriguez, J., Teyseyre, A., Sanz, C., Zunino, A. & Machado, C. (2018). Body condition estimation on cows from depth images using Convolutional Neural Networks. Comput. Electron. Agric. 155, 12–22.
Alvarez, J. R., Arroqui, M., Mangudo, P., Toloza, J., Jatip, D., Rodriguez, J. M., Teyseyre, A., Sanz, C., Zunino, A., Machado, C., Mateos, C. (2019). Estimating body condition score in dairy cows from depth images using convolutional neural networks, transfer learning and model Ensembling techniques. Agronomy. 9 (2), 90. https://doi.org/10.3390/ agronomy9020090.
Amin, A. K. M. R., Islam, M. T. & Hossain, M. S. (2022). Smart livestock monitoring: A computer vision-based approach to detect cattle body posture and condition. IEEE Access. 10, 114566–114579. https://doi.org/10.1109/ACCESS.2022.3218910
Bewley, J., Peacock, A., Lewis, O., Boyce, R., Roberts, D., Coffey, M., Kenyon, S. & Schutz, M. (2008). Potential for Estimation of Body Condition Scores in Dairy Cattle from Digital Images. J. Dairy Sci. 91, 3439–3453.
Devi, I., Sharma, R., Kumar, A., & Thakur, A. (2024). Deep learning aided computer vision system for automated linear type trait evaluation in dairy cows. Smart Agricultural Technology. 8, 100509. https://doi.org/10.1016/j.atech.2024.100509
Duda, R. O., Hart, P. E., & Stork, D. G. (2001). Pattern Classification. Wiley-Interscience
Hansen, M. F., Smith, M. L., Smith, L. N., Abdul Jabbar, K. & Forbes, D. (2018). Automated monitoring of dairy cow body condition, mobility and weight using a single 3D video capture device. Comput. Ind. 98, 14–22. https://doi.org/10.1016/j.compind.2018.02.011.
Hou, H., Shi, W., Guo, J., Zhang, Z., Shen, W., & Kou, S. (2021). Cow Rump Identification Based on Lightweight Convolutional Neural Networks. Information. 12(9), 361. https://doi.org/10.3390/info12090361
Huang, X. P., Feng, T., Guo, Y. Y. & Liang, D. (2023). Lightweight dairy cow body condition scoring method is based on improved YOLOv5s (in Chinese). Nongye Jixie Xuebao/Trans. Chin. Soc. Agric. Mach. 54, 287–296. https://doi.org/10.6041/j.issn.1000-1298.2023. 06.030.
Iandola, F., Han, S., Moskewicz, M., Ashraf, K., Dally, W. & Keutzer, K. (2016). SqueezeNet: AlexNet-level accuracy with 50x fewer parameters and <0.5 MB model size. arXiv:1602.07360.
Imamura, S., Zin, T.T., Kobayashi, I. & Horii, Y. (2017). Automatic evaluation of cow’s bodycondition-score using 3D camera. 2017 IEEE 6th Global Conference on Consumer Electronics. pp. 1–2. https://doi.org/10.1109/GCCE.2017.8229435.
Li, J., Sun, P., Qin, C., Li, F.-d. & Wen, J. (2013). Research advance of body condition score in the management of feeding the dairy cows (in Chinese). China Anim. Husb. Vet. Med. 40, 115–119. https://doi.org/10.3969/j.issn.1671-7236.2013.10.025.
Li, X., Hu, Z., Huang, X., Feng, T., Yang, X. & Li, M. (2019). Cow body condition score estimation with convolutional neural networks. 2019 IEEE 4th International Conference on Image, Vision and Computing (ICIVC). pp. 433–437. https://doi.org/10.1109/ icivc47709.2019.8981055.
Liu, Y. & Qin, J. (2021). Research and application of dairy cow's body condition score based on attention mechanism. 2021 IEEE 6th International Conference on Cloud Computing and Big Data Analytics (ICCCBDA). pp. 600–606. https://doi.org/10.1109/ icccbda51879.2021.9442608.
Maimon, O. & Rokach, L. (2010). Data Mining and Knowledge Discovery Handbook. 2nd ed. Springer Publishing Company, Incorporated.
Moradian, M. & Sepehrifar, M. K. (2009), Improving the accuracy of the KNN algorithm in data mining using dependency rules. 15th Annual International Conference of the Iranian Computer Association. Tehran, https://civilica.com/doc/78938. (In Persian).
Neary Micheil & Ann Yager. (2002). Body Condition Scoring in Farm Animals. Purdue University, Department of Animal Sciences, pp. 1-8.
Nguyen, T. T., Van den Berg, J., van Mourik, S., & Hogeveen, H. (2018). Automatic body condition scoring in dairy cows using deep learning. Computers and Electronics in Agriculture. 153, 346–356. https://doi.org/10.1016/j.compag.2018.08.046.
Paul, A., Mondal, S., Kumar, S., Kumari, T. (2020). Body condition scoring in dairy cows - a conceptual and systematic review. Ind. J. Anim. Res. 54 (8), 929–935. https://doi.org/ 10.18805/ijar.B-3859.
Qiao, Y., Guo, Y. & He, D. (2023). Cattle body detection based on YOLOv5-ASFF for precision livestock farming. Comput. Electron. Agric. 204, 107579. https://doi.org/10.1016/j. compag.2022.107579.
Qiao, Y., Kong, H., Clark, C., Lomax, S., Su, D., Eiffert, S. & Sukkarieh, S. (2021). Intelligent perception for cattle monitoring: a review for cattle identification, body condition score evaluation, and weight estimation. Comput. Electron. Agric. 185, 106143. https://doi. org/10.1016/j.compag.2021.106143.
Redmon, J., Divvala, S., Girshick, R. & Farhadi, A. (2016). You only look once: unified, realtime object detection. Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR). pp. 779–788. https://doi.org/10.1109/cvpr.2016.91.
Ren, S. Q., He, K. M., Girshick, R. & Sun, J. (2017). Faster R-CNN: towards real-time object detection with region proposal networks. IEEE Trans. Pattern Anal. Mach. Intell. 39 (6), 1137–1149. https://doi.org/10.1109/Tpami.2016.2577031.
Roii, S., Yael, E., Yisrael, P. & Ilan, H. (2016). Development of automatic body condition scoring using a low-cost 3-dimensional Kinect camera. J. Dairy Sci. 99 (9), 7714–7725. https://doi.org/10.3168/jds.2015-10607.
Shafiei, Sh. & Nakhaei, N. (2018), A technique to improve the speed and accuracy of the KNN classifier algorithm. Journal of Science and Engineering Elites. Vol. 3(5). 134-142. (In Persian).
Shi, W.; Dai, B.; Shen, W.; Sun, Y.; Zhao, K. & Zhang, Y. (2023). Automatic estimation of dairy cow body condition score based on attention-guided 3D point cloud feature extraction. Comput. Electron. Agric. 206, 107666.
Shigeta, M., Ike, R., Takemura, H. & Ohwada, H. (2018). Automatic measurement and determination of body condition score of cows based on 3D images using CNN. J. Rob. Mechatronics. 30 (2), 206–213. https://doi.org/10.20965/jrm.2018.p0206.
Simonyan, K. & Zisserman, A. (2015). Very Deep Convolutional Networks for Large-Scale Image Recognition. arXiv:1409.1556.
Sokolova, M. & Lapalme, G. (2009). A systematic analysis of performance measures for classification tasks. Inf. Process. Manage. 45 (4), 427–437.
Song, X., Bokkers, E. A. M., van Mourik, S., Groot Koerkamp, P. W. G. & vander Tol, P. P. J. (2019). Automated body condition scoring of dairy cows using 3-dimensional feature extraction from multiple body regions. J. Dairy Sci. 102 (5), 4294–4308. https://doi.org/10. 3168/jds.2018-15238.
Tian, Y., Li, L., & Zhang, H. (2020). Automatic recognition of back posture in dairy cows for lameness detection using deep learning. Computers and Electronics in Agriculture. 177, 105708. https://doi.org/10.1016/j.compag.2020.105708.
Wang, Y., Zhang, R., Liu, Y., & Fu, Z. (2020). Automatic estimation of dairy cow body condition score using back posture extraction with deep learning. Biosystems Engineering. 195, 186–198. https://doi.org/10.1016/j.biosystemseng.2020.04.015.
Wu, Y., Li, Y., Zhao, Y., Yang, P., Li, Z. & Guo, H. (2021). Review of research on body condition score for dairy cows based on computer vision (in Chinese). Nongye Jixie Xuebao/ Trans. Chin. Soc. Agric. Mach. 52, 268–275. https://doi.org/10.6041/j.issn.1000-1298. 2021.S0.033.
Yukun, S., Pengju, H., Yujie, W., Ziqi, C., Yang, L., Baisheng, D., Runze, L. & Yonggen, Z. (2019). Automatic monitoring system for individual dairy cows based on a deep learning framework that provides identification via body parts and estimation of body condition score. J. Dairy Sci. 102, 10140–10151.
Zhao, K., Liu, X. & Ji, J. (2021). Automatic body condition scoring method for dairy cows based on EfficientNet and convex Hull feature of point cloud (in Chinese). Trans. Chin. Soc. Agric. Mach. 52, 192–201 +173. https://doi.org/10.6041/j.issn.1000- 1298.2021.05.021.
Zhao, K., Zhang, M., Shen, W., Liu, X., Ji, J., Dai, B. & Zhang, R. (2023). Automatic body condition scoring for dairy cows based on efficient net and convex hull features of point clouds. Comput. Electron. Agric. 205, 107588.
Zin, T. T., Seint, P. T., Tin, P., Horii, Y. & Kobayashi, I. (2020). Body condition score estimation based on regression analysis using a 3D camera. Sensors. 20 (13). https://doi.org/10. 3390/s20133705.