Plant Methods (Mar 2025)

GrainNet: efficient detection and counting of wheat grains based on an improved YOLOv7 modeling

  • Xin Wang,
  • Changchun Li,
  • Chenyi Zhao,
  • Yinghua Jiao,
  • Hengmao Xiang,
  • Xifang Wu,
  • Huabin Chai

DOI
https://doi.org/10.1186/s13007-025-01363-y
Journal volume & issue
Vol. 21, no. 1
pp. 1 – 22

Abstract

Read online

Abstract Background Seed testing plays a crucial role in improving crop yields.In actual seed testing processes, factors such as grain sticking and complex imaging environments can significantly affect the accuracy of wheat grain counting, directly impacting the effectiveness of seed testing. However, most existing methods primarily focus on simple counting tasks and lack general applicability. Results To enable fast and accurate counting of wheat grains under severe adhesion and complex scenarios, this study collected images of wheat grains from different varieties, backgrounds, densities, imaging heights, adhesion levels, and other natural conditions using various imaging devices and constructed a comprehensive wheat grain dataset through data enhancement techniques. We propose a wheat grain detection and counting model called GrainNet, which significantly improves the counting performance and detection speed across diverse conditions and adhesion levels by incorporating lightweight and efficient feature fusion modules. Specifically, the model incorporates an Efficient Multi-scale Attention (EMA) mechanism, effectively mitigating the interference of background noise on detection results. Additionally, the ASF-Gather and Distribute (ASF-GD) module optimizes the feature extraction component of the original YOLOv7 network, improving the model’s robustness and accuracy in complex scenarios. Ablation experiments validate the effectiveness of the proposed methods.Compared with classic models such as Faster R-CNN, YOLOv5, YOLOv7, and YOLOv8, the GrainNet model achieves better detection performance and computational efficiency in various scenarios and adhesion levels. The mean Average Precision reached 93.15%, the F1 score was 0.946, and the detection speed was 29.10 frames per second (FPS). A comparative analysis with manual counting results revealed that the GrainNet model achieved the highest coefficient of determination and Mean Absolute Error values for wheat grain counting tasks, which were 0.93 and 5.97, respectively, with a counting accuracy of 94.47%. Conclusions Overall, the GrainNet model presented in this study enables accurate and rapid recognition and quantification of wheat grains, which can provide a reference for effective seed examination of wheat grains in real scenarios. Related content can be accessed through the following link: https://github.com/1371530728/grainnet.git .

Keywords