# Deep Learning Model for the Inspection of Coffee Bean Defects
## 3 Results
### Experimental Results
\begin{table}
\begin{tabular}{c c c c c c c c c} \hline \hline \(T\backslash\)P1 & **Cut** & **Good-f2 & **Good-b2 & **Immuters** & **Sour** & **Insect-f2 & **Insect-b2 & **Withered** & **Acc** \\ \hline Cut & 114 & 0 & 0 & 0 & 4 & 7 & 2 & 9 & 86.1\% \\ Good-f2 & 0 & 182 & 3 & 0 & 0 & 0 & 0 & 0 & 95.1\% \\ Good-b2 & 0 & 7 & 280 & 0 & 0 & 0 & 0 & 0 & 98.3\% \\ Immature & 0 & 0 & 0 & 165 & 0 & 0 & 0 & 0 & 98.8\% \\ \multicolumn{2}{c}{Sour} & 0 & 0 & 0 & 113 & 0 & 1 & 0 & 93.0\% \\ Insect-f2 & 2 & 1 & 0 & 0 & 2 & 194 & 6 & 2 & 94.2\% \\ Insect-b2 & 0 & 0 & 0 & 5 & 10 & 0 & 147 & 2 & 90.3\% \\ \multicolumn{2}{c}{Withered} & 11 & 1 & 4 & 14 & 16 & 1 & 24 & 110 & 69.4\% \\ \hline \hline \end{tabular} 1
[FOOTNOTE:1]Footnote 1: footnotemark: T.: Ture, P: Predicted. 2  
\end{table} 
Table 7: Confusion matrix of the AlexNet-aj model. Following dimensionality reduction, the surface texture of coffee beans, such as wrinkles, could still be observed in Convolutional Layers 2 and 3 (Figure 10). In the AlexNet-aj model, the max-pooling layer was used to enhance features and reduce noise. However, coffee bean defects appear similar to noise; therefore, defect features were eliminated during the noise reduction process. The new network-dr model uses convolutional layers to reduce image dimensionality, and its pooling layers use stride to enhance image features. The results indicated that in the aforementioned model, the appearance and textural features of coffee beans were retained and successfully propagated to the subsequent layers. After the dimensionality reduction method was improved, the difficulty in distinguishing between immature and sour samples decreased considerably; however, confusion still existed between cut and insect-n samples (Table 8). The insect damage features and surface wrinkle features were highly similar (Figure 11), and padding caused blurriness in the target image in Convolutional Layers 2 and 3. Specifically, the insect damage feature near the edge was blurred and enlarged, which caused it to appear similar to a surface wrinkle. \begin{table}
\begin{tabular}{c c c c c c c c c c} \hline \hline T\(\backslash\)P\({}^{\text{1}}\) & Cut & Good-f \({}^{\text{2}}\) & Good-b \({}^{\text{2}}\) & Immature & **Sour** & **Insect-f \({}^{\text{2}}\)** & **Insect-b \({}^{\text{2}}\)** & **Withered** & **Acc** \\ \hline Cut & 123 & 0 & 0 & 0 & 2 & 2 & 1 & 9 & 89.8\% \\ Good-f \({}^{\text{2}}\) & 0 & 182 & 3 & 0 & 0 & 0 & 0 & 0 & 98.4\% \\ Good-b \({}^{\text{2}}\) & 0 & 3 & 284 & 0 & 0 & 0 & 0 & 0 & 99.0\% \\ Immature & 0 & 0 & 0 & 163 & 0 & 0 & 1 & 1 & 98.8\% \\ Sour & 0 & 0 & 0 & 0 & 112 & 0 & 2 & 0 & 99.1\% \\ Insect-f \({}^{\text{2}}\) & 4 & 0 & 0 & 0 & 0 & 194 & 5 & 5 & 93.7\% \\ Insect-b \({}^{\text{2}}\) & 0 & 0 & 0 & 0 & 3 & 0 & 155 & 6 & 93.9\% \\ Withered & 16 & 0 & 0 & 2 & 4 & 0 & 20 & 139 & 77.2\% \\ \hline \hline \end{tabular} \({}^{\text{1}}\) T: Ture, P: Predicted. \({}^{\text{2}}\) f: front side, b: back side.  
\end{table} 
Table 8: Confusion matrix of the new network-dr model. Figure 9: Convolution visualization results of the AlexNet-aj model (the columns of images from left to right represent the results obtained for Convolutional Layers 1–5). After the effect of padding was eliminated, the outer contour of a coffee bean became more distinguishable and the irregular shape of a widhered bean was clearly visible (Figure 12). The features of an insect-damaged bean were not enlarged or blurred, and its shape was distinct from that of a widhered bean (Figure 13). Therefore, the difficulty in distinguishing between widhered and insect-damaged beans decreased considerably. The improvement in the dimensionality reduction method and the removal of the padding function considerably increased the feature extraction efficiency. To further increasing the model accuracy, additional features must be extracted. The ReLU can generate a large number of dead neurons, which impede the propagation of data in a neural network. This problem should be addressed to increase the number of features extracted.