Real-Time Detection Technology of Corn Kernel Breakage and Mildew Based on Improved YOLOv5s
Abstract
:1. Introduction
2. Materials and Methods
2.1. Corn Kernel Image Acquisition Device
2.2. Corn Kernel Sample Image Dataset
2.3. Recognition Model Construction
2.3.1. YOLOv5s Algorithm
2.3.2. CBAM Attention Mechanism
2.3.3. SPPCPSC Pyramid Pooling Structure
2.3.4. Transformer Prediction Heads
3. Results and Analysis
3.1. Experimental Environment and Parameter Setting
3.2. Evaluation Metrics
3.3. Experimental Comparison and Analysis
3.3.1. Ablation Experiments
3.3.2. Experimental Analysis of Different Model Algorithms
3.3.3. Improved Algorithm Detection Experiment
4. Conclusions
- (1)
- This paper takes real-time detection of corn kernel breakage and mildew during the harvesting of corn kernels as the research content. Aiming at low recognition caused by the variety of corn kernel morphology, intense kernel movement, and complex and changing environment during corn kernel harvesting, this paper proposes a new recognition model algorithm: CST-YOLOv5s based on YOLOv5s for corn kernel breakage and mildew. Firstly, the CBAM attention mechanism is added to the backbone network of YOLOv5s to finely allocate and process the feature information, highlighting the features of corn breakage and mildew. Secondly, the pyramid pooling structure SPPCPSC, SPP and CPSC technologies are used to extract and fuse features of different scales, improving the precision of object detection. Finally, the original prediction head is converted into a transformer prediction head to explore the prediction potential with a multi-head attention mechanism.
- (2)
- Using the same training and validation sets, multi-scale training was conducted on different improved algorithms and model algorithms. Through ablation experiments, it was shown that the CST-YOLOv5s model significantly improved the detection effect of corn kernel breakage and mildew. Compared with the original YOLOv5s model, the average precision (AP) of corn kernel breakage and mildew recognition increased by 5.2% and 7.1%, respectively, and the mean average precision (mAP) of all kinds of corn kernel recognition is 96.1%, and the frame rate is 36.7 FPS. Compared with YOLOv4-tiny, YOLOv6n, YOLOv7, YOLOv8s, and YOLOv9-E detection model algorithms, the CST-YOLOv5s model has better overall performance in terms of detection accuracy and speed. This study can provide a reference for real-time detection of breakage and mildew kernels during the harvesting process of corn kernels.
- (3)
- In future research, we will increase the number of corn variety samples and enrich the dataset of breakage and mildew corn kernels. At present, we only focus on the detection of corn kernels on one side and cannot judge the state of other surfaces. In the later stage, we will carry out research on the recognition of the whole surface of corn kernels to further improve the detection precision.
Author Contributions
Funding
Institutional Review Board Statement
Data Availability Statement
Conflicts of Interest
References
- Nie, S.; Ma, S.; Peng, Y.; Wang, W.; Li, Y. Research Progress of Rapid Optical Detection Technology and Equipment for Grain Quality. Trans. Chin. Soc. Agric. Mach. 2022, 53, 1–12. [Google Scholar]
- Yang, S.; Cao, Y.; Zhao, H.; Fei, M. Research progress of rapid detection technology in grain mildew. Cereals Oils 2018, 31, 21–23. [Google Scholar]
- Zhang, J.; Jin, Y.; Yin, J. Research Progress of Machine Vision Technology in Rice Quality Detection. J. Chin. Cereals Oils 2022, 37, 302–310. [Google Scholar]
- Li, Z. Research on Maize Seed Quality Inspection Based on Machine Vision. Master’s Thesis, Shijiazhuang Tidao University, Shijiazhuang, China, 2023. [Google Scholar]
- Cui, X.; Zhang, P.; Zhao, J.; Xu, W.; Ma, W.; Jin, C. Study on Inspection of Corn Seed Breakage Based on Machine Vision. J. Agric. Mech. Res. 2019, 41, 28–33+84. [Google Scholar]
- Chen, J.; Gu, Y.; Lian, Y.; Han, M. Online recognition method of impurities and broken paddy grains based on machine vision. Trans. Chin. Soc. Agric. Eng. 2018, 34, 187–194. [Google Scholar]
- Zhu, X.; Du, Y.; Chi, R.; Deng, X. Design of On-line Detection Device for Grain Breakage of Corn Harvester Based on OpenCV. In Proceedings of the 2019 ASABE Annual International Meeting, Boston, MA, USA, 7 July–10 July 2019. [Google Scholar]
- Fan, B. Research on Rice Appearance Quality Detection System Based on Machine Vision. Master’s Thesis, Hebei Agricultural University, Baoding, China, 2022. [Google Scholar]
- Niu, S.; Ma, R.; Xu, X.; Liang, A.; Mu, C.; Xu, J.; Ma, D. Research on MobileNetV2 Maize Seed Variety Recognition Based on Improved Attention Mechanisn CBAM based on machine vision. J. Chin. Cereals Oils Assoc. 2023, 1–12. [Google Scholar] [CrossRef]
- Pan, W.; Sun, M.; Yuan, Y.; Liu, P. Identification Method of W heat Grain Phenotype B ased on Deep Learning of ImCascade R-CNN based on machine vision. Smart Agric. 2023, 5, 110–120. [Google Scholar]
- Wang, Q. Study On Online Real-time Detection System of FHB Wheat Kernels and Identification of FHB Kernels Based on Deep Learning. Master’s Thesis, Nanjing Agricultural University, Nanjing, China, 2021. [Google Scholar]
- Zhang, H.; Yan, N.; Wu, X.; Wang, C.; Luo, B. Design and Experiment of Online Maize Single Seed Detection and Sorting Device Learning. Trans. Chin. Soc. Agric. Mach. 2022, 53, 159–166. [Google Scholar]
- Wu, Z. Research on an Online Monitoring System for Impurity Breakage Rate in Rice and Wheat Grains Based on Mask R_CNN. Master’s Thesis, Jiangsu University, Zhenjiang, China, 2022. [Google Scholar]
- Li, X.Y.; Du, Y.F.; Yao, L.; Wu, J.; Liu, L. Design and Experiment of a Broken Corn Kernel Detection Device Based on the YOLOv4-Tiny Algorithm. Agriculture 2021, 11, 1238. [Google Scholar] [CrossRef]
- Bochkovskiy, A.; Wang, C.-Y.; Liao, H.-Y.M. YOLOv4: Optimal speed and accuracy of object detection. arXiv 2020, arXiv:2004.10934. [Google Scholar]
- Jocher, G.; Chaurasia, A.; Stoken, A.; Borovec, J.; Kwon, Y.; Michael, K.; Fang, J.; Wong, C.; Yifu, Z.; Montes, D. ultralytics/YOLOv5: v6. 2-YOLOv5 classification models, apple m1, reproducibility, clearml and deci. ai integrations. Zenodo 2022. [Google Scholar] [CrossRef]
- Li, C.; Li, L.; Jiang, H.; Weng, K.; Geng, Y.; Li, L.; Ke, Z.; Li, Q.; Cheng, M.; Nie, W. YOLOv6: A single-stage object detection framework for industrial applications. arXiv 2022, arXiv:2209.02976. [Google Scholar]
- Wang, C.-Y.; Bochkovskiy, A.; Liao, H.-Y.M. YOLOv7: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, Vancouver, BC, Canada, 17–24 June 2023; pp. 7464–7475. [Google Scholar]
- Wang, C.-Y.; Yeh, I.-H.; Liao, H.-Y.M. YOLOv9: Learning What You Want to Learn Using Programmable Gradient Information. arXiv 2024, arXiv:2402.13616. [Google Scholar]
- Geng, D.; Wang, Q.; Li, H.; He, Q.; Yue, D.; Ma, J.; Wang, Y.; Xu, H. Online detection technology for broken corn kernels based on deep learning Learning. Trans. Chin. Soc. Agric. Eng. 2023, 39, 270–278. [Google Scholar]
- Lan, Y.; Sun, B.; Zhang, L.; Zhao, D. Identifying diseases and pests in ginger leaf under natural scenes using improved YOLOv5s. Trans. Chin. Soc. Agric. Eng. 2024, 40, 210–216. [Google Scholar]
- Ding, R.; Chen, B. Tomato recognition and detection algorithm based on improved YOLOv5. J. Fujian Univ. Technol. 2023, 21, 585–591. [Google Scholar]
- Sun, F.; Wang, Y.; Lan, P.; Zhang, X.; Chen, X.; Wang, Z. Identification of apple fruit diseases using improved YOLOv5s and transfer learning. Trans. Chin. Soc. Agric. Eng. 2022, 38, 171–179. [Google Scholar]
- Wei, T.; Liu, T.; Zhang, S.; Li, S.; Miao, H.; Liu, S. Research on pepper picking robot recognition and positioning method based on improved YOLOv5s. J. Yangzhou University. (Nat. Sci. Ed.) 2023, 26, 61–69. [Google Scholar]
- Xu, H.; Tang, Z.; Zhang, J.; Zhu, P. Research on Optimization of YOLOv5s Detection Algorithm for Steel Surface Defect based on improved YOLOv5s. Comput. Eng. Appl. 2024, 60, 306–314. [Google Scholar]
- Zuo, H.; Huang, Q.; Yang, J.; Sun, Q.; Li, S.; Li, L. Improved YOLOv5s-based Detection Method for Crop Yellow Ieaf Curl Virus Disease. Trans. Chin. Soc. Agric. Mach. 2023, 1–11. [Google Scholar]
- Chen, Y.; Wu, X.; Zhang, Z.; Yan, J.; Zhang, F.; Yu, L. Method for identifying tea diseases in natural environment using improved YOIOv5s. Trans. Chin. Soc. Agric. Eng. 2023, 39, 185–194. [Google Scholar]
- Zhu, X.; Chen, F.; Zheng, Y.; Li, Z.; Zhang, X. Identification of olive cultivars using bilinear netw orks and attention mechanisms. Trans. Chin. Soc. Agric. Eng. 2023, 39, 183–192. [Google Scholar]
- Li, L.; Lu, S.; Ren, H.; Xu, G.; Zhou, Y. Mulberry Branch Identification and Location Method Based on Improved YOLO v5 in Complex Environment. Trans. Chin. Soc. Agric. Mach. 2024, 55, 249–257. [Google Scholar]
- Yang, H.W.; Liu, Y.Z.; Wang, S.W.; Qu, H.X.; Li, N.; Wu, J.; Yan, Y.F.; Zhang, H.J.; Wang, J.X.; Qiu, J.F. Improved Apple Fruit Target Recognition Method Based on YOLOv7 Model. Agriculture 2023, 13, 1278. [Google Scholar] [CrossRef]
- Wang, L.; Liu, J.; Wang, W. Small target detection method in UAV images based on dilated convolution fusion Transformer. J. Comput. Appl. 2024, 1–10. [Google Scholar]
- Liu, W.; Lu, X. Research Progress of Transformer Based on Computer Vision. Comput. Eng. Appl. 2022, 58, 012033. [Google Scholar]
- Bao, W.; Xie, W.; Hu, G.; Yang, X.; Su, B. Wheat ear counting method in UAV images based on TPH-YOLO. Trans. Chin. Soc. Agric. Eng. 2023, 39, 155–161. [Google Scholar]
- Wang, P.; Du, J.; Zhang, Y.; Liu, J.; Li, H.; Wang, C. Yield Estimation of Winter Wheat Based on Multiple Remotely Sensed Parameters and CNN-Transformer. Trans. Chin. Soc. Agric. Mach. 2024, 55, 154–163. [Google Scholar]
- Wang, X.; Liu, Z. Infrared small target detection based on multi-layers multi-directions Transformer. Acta Aeronaut. Astronaut. Sin. 2024, 1–14. [Google Scholar] [CrossRef]
- Fang, S.D.; Wang, Y.F.; Zhou, G.X.; Chen, A.B.; Cai, W.W.; Wang, Q.F.; Hu, Y.H.; Li, L.J. Multi-channel feature fusion networks with hard coordinate attention mechanism for maize disease identification under complex backgrounds. Comput. Electron. Agric. 2022, 203, 107486. [Google Scholar] [CrossRef]
- Yang, S.Z.; Wang, W.; Gao, S.; Deng, Z.P. Strawberry ripeness detection based on YOLOv8 algorithm fused with LW-Swin Transformer. Comput. Electron. Agric. 2023, 215, 108360. [Google Scholar] [CrossRef]
Dataset | Whole Corn Kernels | Breakage Corn Kernels | Mildew Corn Kernels |
---|---|---|---|
Training set | 13,783 | 5907 | 5904 |
Validation set | 1494 | 747 | 726 |
Test set | 1415 | 730 | 735 |
Total (sheets) | 16,692 | 7384 | 7365 |
Model | Size (Pixels) | mAP0.5% | mAP0.5–0.95% | Paramters/×106 M | Model Size/MB | FPS |
---|---|---|---|---|---|---|
YOlOv5n | 640 | 0.822 | 0.763 | 1.7 | 3.5 | 48.5 |
YOlOv5s | 640 | 0.926 | 0.872 | 7.0 | 13.5 | 42.6 |
YOlOv5m | 640 | 0.931 | 0.882 | 20.9 | 40 | 35.6 |
YOlOv5l | 640 | 0.936 | 0.887 | 46.1 | 88.3 | 28.7 |
YOlOv5x | 640 | 0.941 | 0.891 | 86.2 | 164 | 20.7 |
Model | Average Precision AP/% | P/% | R/% | mAP/% | Model Size /MB | |||||
---|---|---|---|---|---|---|---|---|---|---|
CBAM | SPPCPSC | Transformer | Whole Corn Kernels | Breakage Corn Kernels | Mildew Corn Kernels | |||||
YOLOv5s | × | × | × | 91.2 | 90.9 | 87.6 | 90.6 | 90.5 | 89.9 | 13.5 |
√ | × | × | 93.4 | 91.8 | 91.6 | 93.5 | 91.9 | 92.3 | 13.7 | |
× | √ | × | 93.1 | 94.5 | 90.8 | 93.2 | 94.6 | 92.8 | 25.9 | |
× | × | √ | 93.3 | 90.4 | 92.1 | 93.4 | 90.5 | 92.0 | 13.6 | |
√ | √ | × | 94.1 | 94.4 | 92.6 | 94.3 | 94.7 | 93.7 | 26 | |
√ | × | √ | 95.8 | 95.1 | 93.5 | 96.0 | 95.4 | 94.8 | 13.7 | |
× | √ | √ | 95.5 | 95.8 | 92.2 | 95.8 | 96.1 | 94.5 | 25.8 | |
√ | √ | √ | 97.5 | 96.1 | 94.7 | 97.2 | 97.5 | 96.1 | 26 |
Model | Average Precision AP/% | P/% | R/% | mAP/% | Model Size /MB | FPS | ||
---|---|---|---|---|---|---|---|---|
Whole Corn Kernels | Breakage Corn Kernels | Mildew Corn Kernels | ||||||
YOLOv4-Tiny | 89.3 | 88 | 85.7 | 87.1 | 87.4 | 87.7 | 27.6 | 34.5 |
YOLOv6n | 88.3 | 87.2 | 84.3 | 86.1 | 86.4 | 86.6 | 17.6 | 39.8 |
YOLOv7 | 95.2 | 93.8 | 92.9 | 95.5 | 92.2 | 94 | 71.2 | 20.9 |
YOLOv8s | 95.1 | 95.7 | 92.4 | 95.4 | 95.9 | 94.4 | 50.6 | 25.2 |
YOLOv9-E | 93.1 | 99.1 | 95.6 | 95.9 | 98.3 | 95.9 | 116 | 6.5 |
CST-YOLOv5s | 97.5 | 96.1 | 94.7 | 97.2 | 97.5 | 96.1 | 26 | 36.7 |
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
Liu, M.; Liu, Y.; Wang, Q.; He, Q.; Geng, D. Real-Time Detection Technology of Corn Kernel Breakage and Mildew Based on Improved YOLOv5s. Agriculture 2024, 14, 725. https://doi.org/10.3390/agriculture14050725
Liu M, Liu Y, Wang Q, He Q, Geng D. Real-Time Detection Technology of Corn Kernel Breakage and Mildew Based on Improved YOLOv5s. Agriculture. 2024; 14(5):725. https://doi.org/10.3390/agriculture14050725
Chicago/Turabian StyleLiu, Mingming, Yinzeng Liu, Qihuan Wang, Qinghao He, and Duanyang Geng. 2024. "Real-Time Detection Technology of Corn Kernel Breakage and Mildew Based on Improved YOLOv5s" Agriculture 14, no. 5: 725. https://doi.org/10.3390/agriculture14050725
APA StyleLiu, M., Liu, Y., Wang, Q., He, Q., & Geng, D. (2024). Real-Time Detection Technology of Corn Kernel Breakage and Mildew Based on Improved YOLOv5s. Agriculture, 14(5), 725. https://doi.org/10.3390/agriculture14050725