Enhancing Livestock Detection: An Efficient Model Based on YOLOv8
Abstract
:1. Introduction
- 1.
- A CBAM is integrated into the C2f module of YOLOv8n to analyze image information more effectively and emphasize salient features. By enhancing the representational capacity of the output feature information, the model’s detection accuracy is consequently improved.
- 2.
- The lightweight up-sampling operator CARAFE is introduced to solve the shortcomings of conventional up-sampling operators, which have small receptive fields and disregard the semantic content of feature maps.
- 3.
- To mitigate the loss of small target feature information, an additional small object detection layer is incorporated into the YOLOv8n neck structure. This layer facilitates the extraction of livestock characteristics and details across multiple receptive fields.
2. Materials and Methodology
2.1. Obtaining Images and Creating Datasets
2.1.1. Data Gathering
2.1.2. Preparing Images and Building Datasets
2.2. Network Architecture of CCS-YOLOv8
2.2.1. Model of YOLOv8 Network
2.2.2. CBAM Attention Mechanism
2.2.3. CARAFE
2.2.4. Small Object Detection Layer
2.2.5. CCS-YOLOv8 Algorithm
2.3. Experimental Design
2.4. Indicators for Model Evaluation
3. Experimental Results and Analysis
3.1. Improved CCS-YOLOv8 Model
3.1.1. Changes in Losses
3.1.2. Changes in Performance
- In group A images, the YOLOv8n baseline model misdetects two of the sheep as four for the densely distributed sheep in the overhead view, while the CCS-YOLOv8 model correctly recognizes these sheep targets. Compared to YOLOv8n, CCS-YOLOv8 demonstrates better detection performance when detecting densely distributed sheep targets with occlusion.
- In group B images, the YOLOv8n model suffers from the problems of missed detection of lamb targets and repeated detection of adult sheep when dealing with situations where adult sheep and lambs are in the same frame, while the CCS-YOLOv8 model effectively avoids such errors. This result indicates that, compared to the baseline model, CCS-YOLOv8 has a stronger ability to detect lamb targets and significantly reduces the risk of missed and repeated detections.
- In group C images, in the oblique side view, the CCS-YOLOv8 model accurately detects a small yak in the distance, while the YOLOv8n model misses the detection. This confirms that the CCS-YOLOv8 model demonstrates better performance in detecting small targets.
3.2. Ablation Experiment
3.3. In Contrast to Other Mainstream Models
3.4. Robustness Test
4. Discussion
5. Conclusions
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Acknowledgments
Conflicts of Interest
Abbreviations
AP | Average Precision |
box_loss | Bounding Box Loss |
BCE | Binary Cross Entropy |
CARAFE | Content-Aware ReAssembly of FEatures |
CBAM | Convolutional Block Attention Module |
CCS-YOLOv8 | Comprehensive Contextual Sensing YOLOv8 |
cls_loss | Localization Loss |
CSP | Cross Stage Partial DarkNet-53 |
C3 | Cross Stage Partial Network with 3 Convolutions |
dfl_loss | Distribution Focal Loss |
DFL | Distribution Focal Loss |
Faster R-CNN | Faster Region with CNN Feature |
FN | False Negative |
FP | False Positive |
FPN | Feature Pyramid Network |
GAP | Global Average Pooling |
GMP | Global Maximum Pooling |
IOU | Intersection over Union |
mAP | Mean Average Precision |
MLP | Multi-Layer Perception |
PAN | Path Aggregation Network |
R-CNN | Region with CNN Feature |
SPPNet | Spatial Pyramid Pooling Network |
TP | True Positive |
UAV | Unmanned Aerial Vehicle |
YOLO | You Only Look Once |
References
- Xue, Z.; Zhang, Z.; Lu, X.; Zou, Y.; Lu, Y.; Jiang, M.; Tong, S.; Zhang, K. Predicted areas of potential distributions of alpine wetlands under different scenarios in the Qinghai-Tibetan Plateau, China. Glob. Planet. Chang. 2014, 123, 77–85. [Google Scholar] [CrossRef]
- Yang, H.; Gou, X.; Xue, B.; Xu, J.; Ma, W. How to effectively improve the ecosystem provisioning services in traditional agricultural and pastoral areas in China? Ecol. Indic. 2023, 150, 110244. [Google Scholar] [CrossRef]
- Kou, Y.; Yuan, Q.; Dong, X.; Li, S.; Deng, W.; Ren, P. Dynamic Response and Adaptation of Grassland Ecosystems in the Three-River Headwaters Region under Changing Environment: A Review. Int. J. Environ. Res. Public Health 2023, 20, 4220. [Google Scholar] [CrossRef] [PubMed]
- Zhou, W.; Gang, C.; Zhou, L.; Chen, Y.; Li, J.; Ju, W.; Odeh, I. Dynamic of grassland vegetation degradation and its quantitative assessment in the northwest China. Acta Oecologica 2014, 55, 86–96. [Google Scholar] [CrossRef]
- Li, H.; Li, T.; Sun, W.; Zhang, W.; Zha, X. Degradation of wetlands on the Qinghai-Tibetan Plateau causing a loss in soil organic carbon in 1966–2016. Plant Soil 2021, 467, 253–265. [Google Scholar] [CrossRef]
- Troiano, C.; Buglione, M.; Petrelli, S.; Belardinelli, S.; De Natale, A.; Svenning, J.C.; Fulgione, D. Traditional Free-Ranging Livestock Farming as a Management Strategy for Biological and Cultural Landscape Diversity: A Case from the Southern Apennines. Land 2021, 10, 957. [Google Scholar] [CrossRef]
- Tan, K.; Ni, L.; Gong, B.; Jia, C.; Fang, Y.; Tang, L.; Huang, Z.; Ji, X.; Jia, K. Application of Yolo Algorithm in Livestock Counting and Identificatiom System. In Proceedings of the 2023 20th International Computer Conference on Wavelet Active Media Technology and Information Processing (ICCWAMTIP), Chengdu, China, 15–17 December 2003; pp. 1–6. [Google Scholar] [CrossRef]
- Lallo, C.H.O.; Cohen, J.; Rankine, D.; Taylor, M.; Cambell, J.; Stephenson, T. Characterizing heat stress on livestock using the temperature humidity index (THI)-prospects for a warmer Caribbean. Reg. Environ. Chang. 2018, 18, 2329–2340. [Google Scholar] [CrossRef]
- Bao, J.; Xie, Q. Artificial intelligence in animal farming: A systematic literature review. J. Clean. Prod. 2022, 331, 129956. [Google Scholar] [CrossRef]
- Rančić, K.; Blagojević, B.; Bezdan, A.; Ivošević, B.; Tubić, B.; Vranešević, M.; Pejak, B.; Crnojević, V.; Marko, O. Animal Detection and Counting from UAV Images Using Convolutional Neural Networks. Drones 2023, 7, 179. [Google Scholar] [CrossRef]
- Moradeyo, O.; Olaniyan, A.S.; Ojoawo, A.O.; Olawale, J.; Bello, R.W. YOLOv7 Applied to Livestock Image Detection and Segmentation Tasks in Cattle Grazing Behavior, Monitor and Intrusions. J. Appl. Sci. Environ. Manag. 2023, 27, 953–958. [Google Scholar] [CrossRef]
- Ahmad, M.; Abbas, S.; Fatima, A.; Issa, G.F.; Ghazal, T.M.; Khan, M.A. Deep Transfer Learning-Based Animal Face Identification Model Empowered with Vision-Based Hybrid Approach. Appl. Sci. 2023, 13, 1178. [Google Scholar] [CrossRef]
- Liang, F.; Zhou, Y.; Chen, X.; Liu, F.; Zhang, C.; Wu, X. Review of target detection technology based on deep learning. In Proceedings of the 5th International Conference on Control Engineering and Artificial Intelligence, Sanya, China, 14–16 January 2021; pp. 132–135. [Google Scholar] [CrossRef]
- Girshick, R.; Donahue, J.; Darrell, T.; Malik, J. Rich Feature Hierarchies for Accurate Object Detection and Semantic Segmentation. In Proceedings of the 2014 IEEE Conference on Computer Vision and Pattern Recognition, Columbus, OH, USA, 23–28 June 2014; pp. 580–587. [Google Scholar] [CrossRef]
- Girshick, R. Fast R-CNN. In Proceedings of the IEEE International Conference on Computer Vision (ICCV), Santiago, Chile, 7–13 December 2015. [Google Scholar]
- Ren, S.; He, K.; Girshick, R.; Sun, J. Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks. IEEE Trans. Pattern Anal. Mach. Intell. 2017, 39, 1137–1149. [Google Scholar] [CrossRef]
- Guo, B.; Ling, S.; Tan, H.; Wang, S.; Wu, C.; Yang, D. Detection of the Grassland Weed Phlomoides umbrosa Using Multi-Source Imagery and an Improved YOLOv8 Network. Agronomy 2023, 13, 3001. [Google Scholar] [CrossRef]
- Jiang, P.; Ergu, D.; Liu, F.; Cai, Y.; Ma, B. A Review of Yolo Algorithm Developments. Procedia Comput. Sci. 2022, 199, 1066–1073. [Google Scholar] [CrossRef]
- Xiao, Z.; Wan, F.; Lei, G.; Xiong, Y.; Xu, L.; Ye, Z.; Liu, W.; Zhou, W.; Xu, C. FL-YOLOv7: A Lightweight Small Object Detection Algorithm in Forest Fire Detection. Forests 2023, 14, 1812. [Google Scholar] [CrossRef]
- Du, X.; Qi, Y.; Zhu, J.; Li, Y.; Liu, L. Enhanced lightweight deep network for efficient livestock detection in grazing areas. Int. J. Adv. Robot. Syst. 2024, 21, 17298806231218865. [Google Scholar] [CrossRef]
- Pu, J.; Yu, C.; Chen, X.; Zhang, Y.; Yang, X.; Li, J. Research on Chengdu Ma Goat Recognition Based on Computer Vison. Animals 2022, 12, 1746. [Google Scholar] [CrossRef] [PubMed]
- Kurniadi, F.A.; Setianingsih, C.; Syaputra, R.E. Innovation in Livestock Surveillance: Applying the YOLO Algorithm to UAV Imagery and Videography. In Proceedings of the 2023 IEEE 9th International Conference on Smart Instrumentation, Measurement and Applications (ICSIMA), Kuala Lumpur, Malaysia, 17–18 October 2023; pp. 246–251. [Google Scholar] [CrossRef]
- Zhang, X.; Xuan, C.; Ma, Y.; Liu, H.; Xue, J. Lightweight model-based sheep face recognition via face image recording channel. J. Anim. Sci. 2024, 102, skae066. [Google Scholar] [CrossRef] [PubMed]
- Yao, H.; Qin, R.; Chen, X. Unmanned Aerial Vehicle for Remote Sensing Applications—A Review. Remote Sens. 2019, 11, 1443. [Google Scholar] [CrossRef]
- Terven, J.; Córdova-Esparza, D.M.; Romero-González, J.A. A Comprehensive Review of YOLO Architectures in Computer Vision: From YOLOv1 to YOLOv8 and YOLO-NAS. Mach. Learn. Knowl. Extr. 2023, 5, 1680–1716. [Google Scholar] [CrossRef]
- Redmon, J.; Farhadi, A. Yolov3: An incremental improvement. arXiv 2018, arXiv:1804.02767. [Google Scholar]
- Wang, C.Y.; Liao, H.Y.M.; Wu, Y.H.; Chen, P.Y.; Hsieh, J.W.; Yeh, I.H. CSPNet: A new backbone that can enhance learning capability of CNN. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops, Seattle, WA, USA, 14–19 June 2020; pp. 390–391. [Google Scholar]
- Li, Y.; Fan, Q.; Huang, H.; Han, Z.; Gu, Q. A Modified YOLOv8 Detection Network for UAV Aerial Image Recognition. Drones 2023, 7, 304. [Google Scholar] [CrossRef]
- He, K.; Zhang, X.; Ren, S.; Sun, J. Spatial Pyramid Pooling in Deep Convolutional Networks for Visual Recognition. In Proceedings of the Computer Vision—ECCV 2014, Zurich, Switzerland, 6–12 September 2014; Fleet, D., Pajdla, T., Schiele, B., Tuytelaars, T., Eds.; Springer: Cham, Switzerland, 2014; pp. 346–361. [Google Scholar] [CrossRef]
- Lin, T.Y.; Dollár, P.; Girshick, R.; He, K.; Hariharan, B.; Belongie, S. Feature Pyramid Networks for Object Detection. In Proceedings of the 2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), Honolulu, HI, USA, 21–26 July 2017; pp. 936–944. [Google Scholar] [CrossRef]
- Liu, S.; Qi, L.; Qin, H.; Shi, J.; Jia, J. Path Aggregation Network for Instance Segmentation. In Proceedings of the 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition, Salt Lake City, UT, USA, 18–23 June 2018; pp. 8759–8768. [Google Scholar] [CrossRef]
- Zhang, H.; Wang, Y.; Dayoub, F.; Sünderhauf, N. VarifocalNet: An IoU-aware Dense Object Detector. In Proceedings of the 2021 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), Nashville, TN, USA, 20–25 June 2021; pp. 8510–8519. [Google Scholar] [CrossRef]
- Li, X.; Wang, W.; Wu, L.; Chen, S.; Hu, X.; Li, J.; Tang, J.; Yang, J. Generalized focal loss: Learning qualified and distributed bounding boxes for dense object detection. Adv. Neural Inf. Process. Syst. 2020, 33, 21002–21012. [Google Scholar]
- Zagoruyko, S.; Komodakis, N. Paying More Attention to Attention: Improving the Performance of Convolutional Neural Networks via Attention Transfer. arXiv 2017, arXiv:1612.03928. [Google Scholar]
- Woo, S.; Park, J.; Lee, J.Y.; Kweon, I.S. CBAM: Convolutional Block Attention Module. In Proceedings of the Computer Vision—ECCV 2018, Munich, Germany, 8–14 September 2018; Ferrari, V., Hebert, M., Sminchisescu, C., Weiss, Y., Eds.; Springer: Cham, Switzerland, 2018; pp. 3–19. [Google Scholar] [CrossRef]
- Wang, J.; Chen, K.; Xu, R.; Liu, Z.; Loy, C.C.; Lin, D. CARAFE: Content-Aware ReAssembly of FEatures. In Proceedings of the 2019 IEEE/CVF International Conference on Computer Vision (ICCV), Seoul, Republic of Korea, 27 October–2 November 2019; pp. 3007–3016. [Google Scholar] [CrossRef]
- Liu, W.; Anguelov, D.; Erhan, D.; Szegedy, C.; Reed, S.; Fu, C.Y.; Berg, A.C. SSD: Single Shot MultiBox Detector. In Proceedings of the Computer Vision—ECCV 2016, Amsterdam, The Netherlands, 11–14 October 2016; Leibe, B., Matas, J., Sebe, N., Welling, M., Eds.; Springer: Cham, Switzerland, 2016; pp. 21–37. [Google Scholar] [CrossRef]
- Ge, Z.; Liu, S.; Wang, F.; Li, Z.; Sun, J. Yolox: Exceeding yolo series in 2021. arXiv 2021, arXiv:2107.08430. [Google Scholar]
- Li, C.; Li, L.; Jiang, H.; Weng, K.; Geng, Y.; Li, L.; Ke, Z.; Li, Q.; Cheng, M.; Nie, W.; et al. YOLOv6: A Single-Stage Object Detection Framework for Industrial Applications. arXiv 2022, arXiv:2209.02976. [Google Scholar]
- Wang, C.; Bochkovskiy, A.; Liao, H. YOLOv7: Trainable Bag-of-Freebies Sets New State-of-the-Art for Real-Time Object Detectors. In Proceedings of the 2023 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), Vancouver, BC, Canada, 17–23 June 2023; pp. 7464–7475. [Google Scholar] [CrossRef]
- Zhu, P.; Wen, L.; Du, D.; Bian, X.; Fan, H.; Hu, Q.; Ling, H. Detection and tracking meet drones challenge. IEEE Trans. Pattern Anal. Mach. Intell. 2021, 44, 7380–7399. [Google Scholar] [CrossRef]
- Zhu, G.; Zhu, F.; Wang, Z.; Xiong, G.; Tian, B. Small Target Detection Algorithm Based On Multi-target Detection Head And Attention Mechanism. In Proceedings of the 2023 IEEE 3rd International Conference on Digital Twins and Parallel Intelligence (DTPI), Orlando, FL, USA, 7–9 November 2023; pp. 1–6. [Google Scholar] [CrossRef]
- Youssef, Y.; Elshenawy, M. Automatic Vehicle Counting and Tracking in Aerial Video Feeds using Cascade Region-based Convolutional Neural Networks and Feature Pyramid Networks. Transp. Res. Rec. 2021, 2675, 304–317. [Google Scholar] [CrossRef]
Parameter | Setting | Parameter | Setting |
---|---|---|---|
optimizer | SGD | epochs | 300 |
momentum | 0.937 | batch | 16 |
seed | 0 | workers | 8 |
imgsz | 640 | close_mosaic | 10 |
lr0 | 0.01 | lr1 | 0.01 |
Model | Precision (%) | Recall (%) | [email protected] (%) | [email protected] (%) | [email protected]:0.95 (%) | F1-Score (%) |
---|---|---|---|---|---|---|
YOLOv8n | 83 | 74.3 | 78.6 | 53.7 | 48.8 | 78.4 |
+C2fCBAM | 85.2 | 74.8 | 79.7 | 55.2 | 49.8 | 79.4 |
+CARAFE | 82.6 | 76.9 | 79.7 | 55.2 | 50 | 79.2 |
+small object detection layer | 84.9 | 77.9 | 82.7 | 59 | 52.7 | 80.4 |
+C2fCBAM+CARAFE | 82.8 | 77.2 | 80.2 | 56.2 | 51 | 79.4 |
+C2fCBAM+small object detection layer | 84.9 | 79.3 | 82.4 | 59.8 | 52.8 | 82 |
+CARAFE+small object detection layer | 83.9 | 80.6 | 82.6 | 59.6 | 52.7 | 81.6 |
CCS-YOLOv8 | 84.1 | 82.2 | 84.4 | 60.3 | 53.6 | 83.1 |
Model | Precision (%) | Recall (%) | [email protected] (%) | [email protected] (%) | [email protected]:0.95 (%) | F1-Score (%) | Parameters (M) | FLOPs (G) |
---|---|---|---|---|---|---|---|---|
Faster R-CNN | 75.3 | 58.3 | 66.9 | 46.1 | 41 | 65.7 | 41.75 | 87.9 |
SSD [37] | 75.6 | 65.2 | 75.7 | 45.6 | 43.5 | 70 | 25.12 | 88.2 |
YOLOv3tiny | 80.1 | 68.5 | 71.1 | 48 | 44.5 | 73.8 | 12.14 | 19 |
YOLOv5s | 84.1 | 80.1 | 81.1 | 55.8 | 50.6 | 82.1 | 7.04 | 16 |
YOLOXs [38] | 80.5 | 75.8 | 81.3 | 53.5 | 49.6 | 78.1 | 8.97 | 13.4 |
YOLOv6n [39] | 80.1 | 74.1 | 76.5 | 52.8 | 48.3 | 77 | 4.24 | 11.9 |
YOLOv7tiny [40] | 84.1 | 79.6 | 81.7 | 53.2 | 49.3 | 81.8 | 6.03 | 13.2 |
YOLOv8n | 83 | 74.3 | 78.6 | 53.7 | 48.8 | 78.4 | 3.01 | 8.2 |
YOLOv8s | 83.9 | 80.2 | 82 | 59.3 | 52.8 | 82 | 11.1 | 28.7 |
CCS-YOLOv8 | 84.1 | 82.2 | 84.4 | 60.3 | 53.6 | 83.1 | 3.38 | 13.7 |
Model | Precision (%) | Recall (%) | [email protected] (%) | [email protected] (%) | [email protected]:0.95 (%) | F1-Score (%) |
---|---|---|---|---|---|---|
YOLOv8n | 40.4 | 29.7 | 27.3 | 14.9 | 15.0 | 34.2 |
CCS-YOLOv8 | 42.6 | 33.5 | 31.1 | 16.8 | 17.1 | 37.5 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2024 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Fang, C.; Li, C.; Yang, P.; Kong, S.; Han, Y.; Huang, X.; Niu, J. Enhancing Livestock Detection: An Efficient Model Based on YOLOv8. Appl. Sci. 2024, 14, 4809. https://doi.org/10.3390/app14114809
Fang C, Li C, Yang P, Kong S, Han Y, Huang X, Niu J. Enhancing Livestock Detection: An Efficient Model Based on YOLOv8. Applied Sciences. 2024; 14(11):4809. https://doi.org/10.3390/app14114809
Chicago/Turabian StyleFang, Chengwu, Chunmei Li, Peng Yang, Shasha Kong, Yaosheng Han, Xiangjie Huang, and Jiajun Niu. 2024. "Enhancing Livestock Detection: An Efficient Model Based on YOLOv8" Applied Sciences 14, no. 11: 4809. https://doi.org/10.3390/app14114809
APA StyleFang, C., Li, C., Yang, P., Kong, S., Han, Y., Huang, X., & Niu, J. (2024). Enhancing Livestock Detection: An Efficient Model Based on YOLOv8. Applied Sciences, 14(11), 4809. https://doi.org/10.3390/app14114809