# Disease and Defect Detection System for Raspberries Based on Convolutional Neural Networks
## 4 Results
### Object-Detection Models Training  
A Faster R-CNN network is created given a pretrained feature extraction network, specifically one for each of the pretrained CNNs defined in Section 3.2. Network training was performed using the Stochastic Gradient Descent (SGD) optimizer with momentum. Parameter optimization is performed during training. The number of regions to sample, which controls the number of image regions per image, varies between 128 and 256 regions. Positive training samples used are those that overlap with the ground truth frames by 0.5 to 1.0, as measured by the intersection over union (IoU) metric of the bounding box. Negative training samples are those that overlap between 0 and 0.4. Furthermore, a sweep of anchor box pyramid scale factor values used to successively upscale anchor box sizes is performed. The values are from 1 through 2. High values produce faster results and small values produce greater accuracy. The evaluation of the results of the object detector models trained for each class individually is performed as follows:  
* The Average Precision (AP) calculated from the area under the Precision-Recall curve is determined. * A value called Detection Rate (\(DR\)) is estimated; this value is given by: \[DR=\frac{\text{number of Objects Detected}}{\text{Objects Ground Truth}}\] (1) where the number of detected objects is formed by the sum of True Positive (TP) and False Positive (FP). Thus, if \(DR<1\) indicates an underestimation of the number of detected objects, if \(DR>1\) it would be overestimating the number of real detected objects. Finally, \(DR=1\) or approximately one would be ideal in this case. Table 3 shows a summary of the AP results obtained from the Precision-Recall curves after the optimization of the parameters in the training of the object detector models for each network used as the basis of the Faster R-R-CNN algorithm. The \(DR\) value obtained for each class and network used is also shown. In the Albinism class, it can be seen from Figure 10 and the curves that the lowest-performing network is Inception V3, as indicated by the values in Table 3 with an AP = 0.22 and a \(DR=0.84\) indicating a significant underestimation of the possible objects in the images. SqueezeNet, with an AP = 0.52 is the second best in this class, but has a \(DR=1.51\), indicating that it detects approximately 51% more objects than are labeled in the test images, i.e., it produces a high number of FPs, making it unfeasible for use. ResNet50 and ResNet101 present very similar results, with an AP of 0.48 and 0.46 respectively, and a \(DR\) in both cases with an absolute deviation of 7%, being globally the second-best networks as backbone of the Faster R-CNN for this class of raspberry. The VGG nets for this class are the best choice. As can be seen in Figure 10 and Table 3, they present the best AP values and their \(DR\) are among the most adequate. \begin{table}
\begin{tabular}{l c c c c c c c c} \hline \hline \multirow{2}{*}{**CNN**} & \multicolumn{2}{c}{**Albinism**} & \multicolumn{2}{c}{**Fungus-Rust**} & \multicolumn{2}{c}{**Peduncle**} & \multicolumn{2}{c}{**Overripeness**} \\ \cline{2-9}  & **AP** & \(DR\) & **AP** & \(DR\) & **AP** & \(DR\) & **AP** & \(DR\) \\ \hline Inception V3 & 0.22 & 0.84 & 0.03 & 0.24 & 0.38 & 1.11 & 0.05 & 0.42 \\ SqueezeNet & 0.52 & 1.51 & 0.33 & 2.08 & 0.37 & 1.32 & 0.19 & 2.10 \\ ResNet50 & 0.48 & 0.93 & 0.17 & 0.52 & 0.47 & 1.12 & 0.18 & 0.88 \\ ResNet101 & 0.46 & 1.07 & 0.29 & 0.70 & 0.40 & 1.03 & 0.22 & 0.99 \\ VGG16 & 0.55 & 1.10 & 0.42 & 0.90 & 0.46 & 1 & 0.27 & 1.33 \\ VGG19 & 0.55 & 1.07 & 0.35 & 1.02 & 0.45 & 0.90 & 0.25 & 1.15 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: AP and \(DR\) values for each class according to the CNN network used in the object detector training. In the Fungus-Rust class, Figure 11 shows the results for raspberries presenting fungus-rust. For this type of defect/disease it is observed that almost all the nets lowered the yield with respect to the AP values.