# Imperfect Wheat Grain Recognition Combined with an Attention Mechanism and Residual Network
## 4 Conclusions  
In this paper, we combined an attention mechanism and the ResNet model to classify imperfect wheat grains, and proposed an imperfect wheat grain recognition method based on the attention mechanism. The study compared the recognition effect of the ResNet model with and without an attention mechanism. The results showed that the recognition accuracies of the five ResNet models with an attention mechanism were improved compared to that without an attention mechanism. The recognition accuracy of ResNet-50 was 97.5%. The confusion matrix and classification performance of the ResNet-50 model, with and without an attention mechanism, were calculated and the results showed that the ResNet-50 model with an attention mechanism was better than the model without attention mechanism in classifying the perfect wheat grains and the five types of imperfect wheat grains, because of the increased training parameters, resulting in an increase in training time. However, the stability of the model was enhanced, so it was feasible to introduce an attention mechanism into the classification of imperfect wheat grains.  
The method proposed in this study can provide a new idea for the automatic identification of imperfect wheat grains in practical applications. The research results of effectively improving the automatic recognition accuracy of imperfect wheat grains are of great significance for intelligent and automatic classification of grain quality. However, the classification work of this study was limited to a single wheat grain, which is inefficient in practical applications. In the future work, we will identify a large number of tiled wheat grains in an image, and consider the problems of grain segmentation and target detection.  
Conceptualization, W.Z. and H.M.; methodology, W.Z. and H.M. and X.L. ([PERSON]); validation, W.B., S.C. and P.Z.; formal analysis, P.Z. and X.L. ([PERSON]); investigation, H.M.; resources, X.L. ([PERSON]) and X.L. ([PERSON]); data curation, X.L. ([PERSON]), Q.W.; writing--original draft preparation, W.Z.; writing--review and editing, W.Z. and H.M.; visualization, H.M.; supervision, L.G.; project administration, J.J.; funding acquisition, Q.W. All authors have read and agreed to the published version of the manuscript.  
This research was funded by the Open Research Fund of National Engineering Research Center for Agro-Ecological Big Data Analysis & Application, Anhui University, grant number AE201905; the Natural Science Foundation of Higher Education of Anhui Province, grant number KJ2019A0210; the Key research and development project of Anhui Province, grant number 201904c03020007; and the Major Science and Technology Project of Anhui Province, grant number S201903a06020020.  
Not applicable.  
Data Availability Statement: Data sharing is not applicable to this article.  
The authors declare no conflict of interest.  
\begin{table}
\begin{tabular}{c c c c c c c c c c} \hline \hline \multirow{2}{*}{**Grains Type of Wheat**} & \multicolumn{6}{c}{**Predicted Species**} & \multicolumn{6}{c}{**Classification Performance**} \\ \cline{2-11}  & **Scab** & **Insect-Damaged** & **Sprouted** & **Mildew** & **Broken** & **Perfect** & **Precision** & **Recall** & **F-Measure** \\ \hline Scab & 97 & 0 & 0 & 1 & 0 & 2 & 98.98 & 97 & 97.98 \\ Insect-damaged & 0 & 99 & 1 & 0 & 0 & 0 & 100 & 99 & 99.5 \\ Sprouted & 0 & 0 & 99 & 1 & 0 & 0 & 93.4 & 99 & 96.12 \\ Mildew & 1 & 0 & 4 & 95 & 0 & 0 & 97.94 & 95 & 96.43 \\ Broken & 0 & 0 & 1 & 0 & 96 & 3 & 100 & 96 & 97.96 \\ Perfect & 0 & 0 & 1 & 0 & 0 & 99 & 95.19 & 99 & 97.06 \\ \hline \hline \end{tabular}
\end{table}
Table 6: Confusion matrix and classification performance of ResNet-50 model with attention.