# Disease and Defect Detection System for Raspberries Based on Convolutional Neural Networks
## 3 Materials and Methods
### Object Detection--Faster R-CNN Algorithm  
Object detection is the process of locating and classifying objects in an image. One approach to DL is the regions with convolutional neural networks (R-CNN) algorithm. This algorithm combines proposed rectangular regions with features extracted from convolutional neural networks. R-CNN is a two-stage detection algorithm. The first stage identifies a subset of regions in an image that may contain an object. The second stage classifies the object in each region.  
The R-CNN family of object detectors uses region proposals to detect objects within images. The number of proposed regions dictates the time it takes to detect objects in an image. The most evolved and widely used version of the family is Faster R-CNN [37]. It consists of two modules. The first module is a fully convolutional deep network proposing regions called region proposal network (region proposal network--RPN) to generate region proposals directly in the network. The second module is the Fast R-CNN detector [38] that uses the proposed regions. The generation of region proposals in the network is faster and better adapted to data. The whole system is a single, unified network for object detection (Figure 7). The RPN module tells the Fast R-CNN module where to look.  
A fundamental part of the Faster R-CNN algorithm is the convolutional network to be used as the feature extraction network; it is typically a pretrained CNN. In this paper, we evaluate some widely known pretrained CNN models, which are the following:  
* Inception-v3 [39]: The network is 48 layers deep, the architecture is built progressively, step by step, and has a combination of symmetric and asymmetric compiler blocks; it  
Figure 6: RGB camera and the illumination system of the raspberry tray quality estimation equipment.  
Figure 7: Structure of the Faster R-CNN object detector.  
is the third edition of Google's Inception Convolutional Neural Network, originally presented during the ImageNet Recognition Challenge.
* ResNet (ResNet-101 and ResNet-50) [40]: these two networks are from the ResNet family; both use residual blocks of direct access connections, reducing the number of parameters to be trained, with a good compromise between performance, structural complexity and training time.
* SqueezeNet [41]: the network is 18 layers deep, is a smaller network that was designed as a more compact replacement for AlexNet. It has almost \(50x\) fewer parameters than AlexNet, yet it performs 3x faster.
* VGG-16 and VGG-19 [42] version, Developed by the Visual Geometry Group (VGG) of the University of Oxford, is an AlexNet enhancement replacing large kernel-sized filters with multiple \(3\times 3\) kernel size filters one after another, increasing network depth and thus being able to learn more complex features.  
The software for the evaluation of raspberry trays is developed with the objective of classifying 4 _classes_ of defects or diseases that occur in raspberries; all these classes can be seen in Figure 8. Similarly, an object-detection model is trained and optimized for each class. This facilitates the optimization of the parameters according to the class to be detected.