In response to the current issues of time-consuming,labor-intensive,and subjective wheat grain detection,this study focuses on the imperfect wheat grain as the research object.Deep learning methods are used to experimentally study the intelligent detection method of imperfect wheat grains.The study builds a wheat imperfect grain image acquisition platform,establishes a deep learning detection model for wheat imperfect grains based on the fine-grained characteristics of wheat imperfect grains,proposes an improved wheat imperfect grain counting method,and designs a wheat imperfect grain detection and counting system.The main research content and conclusions are as follows:(1)By building a wheat imperfect grain image acquisition platform and collecting images of imperfect wheat grains according to experimental requirements,a single-grain wheat imperfect grain database and a multi-grain wheat imperfect grain database have been established.The single-grain database is used to improve the model’s generalization ability.The collected images are subjected to data augmentation processing to obtain 16,000 images for model training.The multi-grain database is used to verify the detection performance of the detection model on highly adhesive wheat grains.Two types of wheat imperfect grain test sets(LWGB and HWGB)with low and high densities were established,and the images were labeled using annotation software to complete the dataset production.(2)A method for identifying imperfect wheat grains by combining the attention mechanism with the residual network(ResNet)is proposed.The recognition accuracy of the method is verified by adding attention mechanism modules at different depths of the residual network.Five different depth residual networks(18,34,50,101,and 152)were selected for the experiment.It was found that the recognition accuracy of each network model was improved after adding the attention mechanism.The average recognition rate of ResNet-50 reached 96.5%after adding the attention mechanism.For ResNet-50 with the attention mechanism,the optimal learning rate was further screened to be 0.0003,and the average recognition accuracy reached 97.5%.This work can provide guidance for using machine vision to detect and identify imperfect wheat grains.(3)An improved YOLOX deep learning method is proposed for the classification and detection of imperfect wheat grains.The Convolutional Block Attention Module(CBAM),which includes spatial attention models and channel attention models,is integrated into YOLOX.Ablation experiments were conducted on the addition position of CBAM to determine the optimal addition position.Two types of test sets were used to evaluate the performance of the trained model and compared with common object detection models,including SSD,Faster R-CNN,YOLOv4,and YOLOX.The results showed that CBAM-YOLOX performed best among the comparison methods,and the average mean average precision(mAP)of the LWGB and HWGB test datasets reached 92.99%and 91.09%,respectively.Compared with YOLOX,CBAM-YOLOX improved the mAP of the LWGB and HWGB test datasets by 0.76%and 1.26%,respectively.It can be seen that the improved CBAM-YOLOX also has good detection effect when the density of wheat grains is high.(4)Based on the improved CBAM-YOLOX detection model,an improved method for counting imperfect wheat grains is proposed.The improved counting method can accurately output the number of each type of imperfect grain and the total number of grains and ensure their consistency,aiming at the problem of repeated counting caused by the phenomenon that a single wheat grain may have multiple imperfect features.At the same time,the above detection and counting functions are integrated,and a wheat imperfect grain detection and counting system is designed and implemented based on PyQt,which realizes image,video detection,and batch detection functions,providing a solution for high-throughput,high-accuracy,and other requirements in wheat grain detection. |