YOLOv5DA: An Improved YOLOv5 Model for Posture Detection of Grouped Pigs
Abstract
:1. Introduction
2. Materials and Methods
2.1. Data Acquisition
2.2. Dataset Construction
- (1)
- The captured surveillance videos were processed into frames, with one frame being extracted every two seconds and removal of similar images inside. After processing, a total of 7220 images were obtained.
- (2)
- The obtained images were annotated with the LabelMe annotation tool [25], which annotated the position of each pig and their posture categories (standing, side lying, and prone lying) in each picture [15]. As shown in Figure 1, we assigned the pigs in standing posture a yellow bounding box, the pigs in side-lying posture a green bounding box, and the pigs in prone-lying posture a light blue bounding box.
- (3)
- The annotated images were then divided into the training set, validation set, and test set using the random sampling technique with an 8:1:1 ratio, which corresponded to 5,776, 722, and 722 pictures, respectively. Then, the total number of samples in the divided pictures and the number of samples from three different postures were counted, and the statistical results are shown in Table 1.
2.3. YOLOv5
2.4. YOLOv5DA
- (1)
- Mosaic9 data augmentation
- (2)
- Deformable convolution
- (3)
- Adaptive Spatial Feature Fusion
2.5. Experimental Environment
2.6. Performance Evaluation
3. Results
3.1. Training Evaluation
3.2. Results and Analysis of Ablation Experiments
3.3. Results and Analysis of Comparative Experiments
3.4. Posture Distribution
4. Conclusions
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Conflicts of Interest
References
- Larsen, M.L.; Wang, M.; Norton, T. Information technologies for welfare monitoring in pigs and their relation to Welfare Quality®. Sustainability 2021, 13, 692. [Google Scholar] [CrossRef]
- Shi, Z.; Li, B.; Zhang, X.; Wang, C.; Zhou, D.; Zhang, G. Using floor cooling as an approach to improve the thermal environment in the sleep area in an open pig house. Biosyst. Eng. 2006, 93, 359–364. [Google Scholar] [CrossRef]
- Chen, Z.; Lu, J.; Wang, H. A Review of Posture Detection Methods for Pigs Using Deep Learning. Appl. Sci. 2023, 13, 6997. [Google Scholar] [CrossRef]
- Xu, J.; Zhou, S.; Xu, A.; Ye, J.; Zhao, A. Automatic scoring of postures in grouped pigs using depth image and CNN-SVM. Comput. Electron. Agric. 2022, 194, 106746. [Google Scholar] [CrossRef]
- Thompson, R.; Matheson, S.M.; Plötz, T.; Edwards, S.A.; Kyriazakis, I. Porcine lie detectors: Automatic quantification of posture state and transitions in sows using inertial sensors. Comput. Electron. Agric. 2016, 127, 521–530. [Google Scholar] [CrossRef]
- Tassinari, P.; Bovo, M.; Benni, S.; Franzoni, S.; Poggi, M.; Mammi, L.M.E.; Mattoccia, S.; Di Stefano, L.; Bonora, F.; Barbaresi, A.; et al. A computer vision approach based on deep learning for the detection of dairy cows in free stall barn. Comput. Electron. Agric. 2021, 182, 106030. [Google Scholar] [CrossRef]
- Xie, J.; Peng, J.; Wang, J.; Chen, B.; Jing, T.; Sun, D.; Gao, P.; Wang, W.; Lu, J.; Yetan, R.; et al. Litchi Detection in a Complex Natural Environment Using the YOLOv5-Litchi Model. Agronomy 2022, 12, 3054. [Google Scholar] [CrossRef]
- Lei, K.; Zong, C.; Yang, T.; Peng, S.; Zhu, P.; Wang, H.; Teng, G.; Du, X. Detection and analysis of sow targets based on image vision. Agriculture 2022, 12, 73. [Google Scholar] [CrossRef]
- Zonderland, J.J.; van Riel, J.W.; Bracke, M.B.; Kemp, B.; den Hartog, L.A.; Spoolder, H.A. Tail posture predicts tail damage among weaned piglets. Appl. Anim. Behav. Sci. 2009, 121, 165–170. [Google Scholar] [CrossRef]
- Krugmann, K.L.; Mieloch, F.J.; Krieter, J.; Czycholl, I. Can Tail and Ear Postures Be Suitable to Capture the Affective State of Growing Pigs? J. Appl. Anim. Welf. Sci. 2021, 24, 411–423. [Google Scholar] [CrossRef]
- Everingham, M.; Van Gool, L.; Williams, C.K.; Winn, J.; Zisserman, A. The pascal visual object classes (voc) challenge. Int. J. Comput. Vis. 2010, 88, 303–338. [Google Scholar] [CrossRef]
- Yan, H.; Liu, Z.; Cui, Q. Multi-target detection based on feature pyramid attention and deep convolution network for pigs. Trans. Chin. Soc. Agric. Eng. (Trans. CSAE) 2020, 36, 193–202. [Google Scholar]
- Cheng, M.; Yuan, H.; Wang, Q.; Cai, Z.; Liu, Y.; Zhang, Y. Application of deep learning in sheep behaviors recognition and influence analysis of training data characteristics on the recognition effect. Comput. Electron. Agric. 2022, 198, 107010. [Google Scholar] [CrossRef]
- Yu, Z.; Liu, Y.; Yu, S.; Song, Z.; Yan, Y.; Li, F.; Wang, Z.; Tian, F. Teat detection of dairy cows based on deep learning neural network FS-YOLOv4 model. Comput. Electron. Agric. 2022, 200, 107224. [Google Scholar] [CrossRef]
- Nasirahmadi, A.; Sturm, B.; Edwards, S.; Jeppsson, K.-H.; Olsson, A.-C.; Müller, S.; Hensel, O. Deep learning and machine vision approaches for posture detection of individual pigs. Sensors 2019, 19, 3738. [Google Scholar] [CrossRef] [PubMed]
- Zheng, C.; Zhu, X.; Yang, X.; Wang, L.; Tu, S.; Xue, Y. Automatic recognition of lactating sow postures from depth images by deep learning detector. Comput. Electron. Agric. 2018, 147, 51–63. [Google Scholar] [CrossRef]
- Riekert, M.; Klein, A.; Adrion, F.; Hoffmann, C.; Gallmann, E. Automatically detecting pig position and posture by 2D camera imaging and deep learning. Comput. Electron. Agric. 2020, 174, 105391. [Google Scholar] [CrossRef]
- Huang, Y.; Liu, J.; Tan, Z.; Liu, K.; Chen, M. An Improved Pig Counting Algorithm Based on YOLOv5 and DeepSORT Model. Sensors 2023, 23, 6309. [Google Scholar] [CrossRef]
- Witte, J.-H.; Gómez, J.M. Introducing a new Workflow for Pig Posture Classification based on a combination of YOLO and EfficientNet. In Proceedings of the Hawaii International Conference on System Sciences, Honolulu, HI, USA, 4–7 January 2022. [Google Scholar]
- Huang, L.; Xu, L.; Wang, Y.; Peng, Y.; Zou, Z.; Huang, P. Efficient Detection Method of Pig-Posture Behavior Based on Multiple Attention Mechanism. Comput. Intell. Neurosci. 2022, 2022, 1759542. [Google Scholar] [CrossRef]
- Ji, H.; Yu, J.; Lao, F.; Zhuang, Y.; Wen, Y.; Teng, G. Automatic position detection and posture recognition of grouped pigs based on deep learning. Agriculture 2022, 12, 1314. [Google Scholar] [CrossRef]
- Ultralytics. YOLOv5 2020. 2020. Available online: https://github.com/ultralytics/yolov5 (accessed on 1 August 2024).
- Dai, J.; Qi, H.; Xiong, Y.; Li, Y.; Zhang, G.; Hu, H.; Wei, Y. Deformable convolutional networks. In Proceedings of the IEEE International Conference on Computer Vision, Venice, Italy, 22–29 October 2017. [Google Scholar]
- Liu, S.; Huang, D.; Wang, Y. Learning spatial fusion for single-shot object detection. arXiv 2019, arXiv:1911.09516. [Google Scholar]
- Torralba, A.; Russell, B.C.; Yuen, J. Labelme: Online image annotation and applications. Proc. IEEE 2010, 98, 1467–1484. [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]
- Tian, Y.; Yang, G.; Wang, Z.; Wang, H.; Li, E.; Liang, Z. Apple detection during different growth stages in orchards using the improved YOLO-V3 model. Comput. Electron. Agric. 2019, 157, 417–426. [Google Scholar] [CrossRef]
- Yin, Y.; Li, H.; Fu, W. Faster-YOLO: An accurate and faster object detection method. Digit. Signal Process. 2020, 102, 102756. [Google Scholar] [CrossRef]
- Redmon, J.; Divvala, S.; Girshick, R.; Farhadi, A. You Only Look Once: Unified, Real-Time Object Detection. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Las Vegas, NV, USA, 27–30 June 2016. [Google Scholar]
- Redmon, J.; Farhadi, A. YOLO9000: Better, Faster, Stronger. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Honolulu, HI, USA, 21–26 July 2017. [Google Scholar]
- Farhadi, A.; Redmon, J. Yolov3: An incremental improvement. Comput. Vis. Pattern Recognit. 2018, 1804, 1–6. [Google Scholar]
- Bochkovskiy, A.; Wangm, C.-Y.; Liao, H.-Y.M. Yolov4: Optimal Speed and Accuracy of Object Detection. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, Seattle, WA, USA, 14–19 June 2020. [Google Scholar]
- Uzar, M.; Öztürk, Ş.; Bayrak, O.C.; Arda, T.; Öcalan, N.T. Performance analysis of YOLO versions for automatic vehicle detection from UAV images. Adv. Remote Sens. 2021, 1, 16–30. [Google Scholar]
- Lin, T.Y.; Dollár, P.; Girshick, R.; He, K.; Hariharan, B.; Belongie, S. Feature pyramid networks for object detection. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Honolulu, HI, USA, 21–26 July 2017. [Google Scholar]
- Liu, S.; Qi, L.; Qin, H.; Shi, J.; Jia, J. Path aggregation network for instance segmentation. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Salt Lake City, UT, USA, 18–22 June 2018. [Google Scholar]
- Wang, Z.; Wu, L.; Li, T.; Shi, P. A smoke detection model based on improved YOLOv5. Mathematics 2022, 10, 1190. [Google Scholar] [CrossRef]
- Pacal, I.; Karaboga, D. A robust real-time deep learning based automatic polyp detection system. Comput. Biol. Med. 2021, 134, 104519. [Google Scholar] [CrossRef]
- Zhao, S.; Zhang, S.; Lu, J.; Wang, H.; Feng, Y.; Shi, C.; Li, D.; Zhao, R. A lightweight dead fish detection method based on deformable convolution and YOLOV4. Comput. Electron. Agric. 2022, 198, 107098. [Google Scholar] [CrossRef]
- Cheng, L.; Yan, J.; Chen, M.; Lu, Y.; Li, Y.; Hu, L. A multi-scale deformable convolution network model for text recognition. In Proceedings of the Thirteenth International Conference on Graphics and Image Processing (ICGIP 2021), Kunming, China, 18–20 August 2021; SPIE: Bellingham, WA, USA, 2022; Volume 12083. [Google Scholar]
- Li, Y.; Zhou, S.; Chen, H. Attention-based fusion factor in FPN for object detection. Appl. Intell. 2022, 52, 15547–15556. [Google Scholar] [CrossRef]
- Cheng, X.; Yu, J. RetinaNet with difference channel attention and adaptively spatial feature fusion for steel surface defect detection. IEEE Trans. Instrum. Meas. 2020, 70, 2503911. [Google Scholar] [CrossRef]
- Qiao, Y.; Guo, Y.; He, D. Cattle body detection based on YOLOv5-ASFF for precision livestock farming. Comput. Electron. Agric. 2023, 204, 107579. [Google Scholar] [CrossRef]
- Dhiman, P.; Kukreja, V.; Manoharan, P.; Kaur, A.; Kamruzzaman, M.M.; Ben Dhaou, I.; Iwendi, C. A novel deep learning model for detection of severity level of the disease in citrus fruits. Electronics 2022, 11, 495. [Google Scholar] [CrossRef]
- Jiang, D.; Li, G.; Tan, C.; Huang, L.; Sun, Y.; Kong, J. Semantic segmentation for multiscale target based on object recognition using the improved Faster-RCNN model. Futur. Gener. Comput. Syst. 2021, 123, 94–104. [Google Scholar] [CrossRef]
- Zhang, F.; Fan, Y.; Cai, T.; Liu, W.; Hu, Z.; Wang, N.; Wu, M. OTL-classifier: Towards imaging processing for future un-manned overhead transmission line maintenance. Electronics 2019, 8, 1270. [Google Scholar] [CrossRef]
- Zhang, Y.; Cai, W.; Fan, S.; Song, R.; Jin, J. Object Detection Based on YOLOv5 and GhostNet for Orchard Pests. Information 2022, 13, 548. [Google Scholar] [CrossRef]
- Gadosey, P.K.; Li, Y.; Agyekum, E.A.; Zhang, T.; Liu, Z.; Yamak, P.T.; Essaf, F. SD-UNET: Stripped down U-net for seg-mentation of biomedical images on platforms with low computational budgets. Diagnostics 2020, 10, 110. [Google Scholar] [CrossRef]
- Tian, Z.; Shen, C.; Chen, H.; He, T. Fcos: Fully convolutional one-stage object detection. In Proceedings of the IEEE/CVF International Conference on Computer Vision, Seoul, Republic of Korea, 27 October–2 November 2019. [Google Scholar]
- Spoolder, H.A.; Aarnink, A.A.; Vermeer, H.M.; van Riel, J.; Edwards, S.A. Effect of increasing temperature on space requirements of group housed finishing pigs. Appl. Anim. Behav. Sci. 2012, 138, 229–239. [Google Scholar] [CrossRef]
- Huynh, T.; Aarnink, A.; Gerrits, W.; Heetkamp, M.; Canh, T.; Spoolder, H.; Kemp, B.; Verstegen, M. Thermal behaviour of growing pigs in response to high temperature and humidity. Appl. Anim. Behav. Sci. 2005, 91, 1–16. [Google Scholar] [CrossRef]
Categories | Training Set | Validation Set | Test Set | Total |
---|---|---|---|---|
Standing | 25,346 | 1353 | 1419 | 28,118 |
Side lying | 8645 | 501 | 484 | 9630 |
Prone lying | 21,667 | 1254 | 1206 | 24,127 |
Total | 55,658 | 3108 | 3109 | 61,875 |
Experimental Configuration | Parameter | |
---|---|---|
Hardware environment | CPU | IntelI XeonI Gold 6130 |
GPU | NVIDIA GeForce RTX 2080Ti | |
Software environment | OS | CentOS 7.6 |
Deep learning framework | Pytorch 1.8.1 |
AP | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Class | Mosaic9 | DC | ASFF | Standing | Prone Lying | Side Lying | mAP | GFLOPs | Params | |
YOLOv5s | — | — | — | 99.4 | 98.7 | 98.0 | 85.1 | 15.8 | 7.02 M | |
YOLOv5s | √ | — | — | 99.5 | 99.0 | 98.8 | 85.8 | 15.8 | 7.02 M | |
YOLOv5s | √ | √ | — | 99.4 | 99.0 | 98.7 | 86.1 | 16.7 | 7.87 M | |
YOLOv5s | √ | √ | √ | 99.4 | 99.1 | 99.1 | 86.8 | 25.2 | 13.3 M |
AP | ||||||
---|---|---|---|---|---|---|
Models | Standing | Prone Lying | Side Lying | mAP | GFLOPs | Params |
Faster-RCNN | 98.9 | 98.6 | 96.7 | 80.7 | 91.01 | 41.13 M |
YOLOv4 | 99.0 | 98.3 | 96.5 | 82.0 | 70.72 | 63.9 M |
FCOS | 98.8 | 96.7 | 97.0 | 79.0 | 78.67 | 31.84 M |
CenterNet | 98.7 | 99.3 | 99.0 | 84.2 | 56.64 | 34.4 M |
YOLOv5s | 99.4 | 98.7 | 98.0 | 85.1 | 15.8 | 7.02 M |
YOLOv5DA | 99.4 | 99.1 | 99.1 | 86.8 | 25.2 | 13.3 M |
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
Shi, W.; Wang, X.; Li, X.; Fu, Y.; Liu, X.; Wang, H. YOLOv5DA: An Improved YOLOv5 Model for Posture Detection of Grouped Pigs. Appl. Sci. 2024, 14, 10104. https://doi.org/10.3390/app142210104
Shi W, Wang X, Li X, Fu Y, Liu X, Wang H. YOLOv5DA: An Improved YOLOv5 Model for Posture Detection of Grouped Pigs. Applied Sciences. 2024; 14(22):10104. https://doi.org/10.3390/app142210104
Chicago/Turabian StyleShi, Wenhui, Xiaopin Wang, Xuan Li, Yuhua Fu, Xiaolei Liu, and Haiyan Wang. 2024. "YOLOv5DA: An Improved YOLOv5 Model for Posture Detection of Grouped Pigs" Applied Sciences 14, no. 22: 10104. https://doi.org/10.3390/app142210104
APA StyleShi, W., Wang, X., Li, X., Fu, Y., Liu, X., & Wang, H. (2024). YOLOv5DA: An Improved YOLOv5 Model for Posture Detection of Grouped Pigs. Applied Sciences, 14(22), 10104. https://doi.org/10.3390/app142210104