## 3 Proposed Deep-Learning-Based Defective Bean Inspection Scheme (DL-DBIS)
### Design of Defect-Sensitive Inspection Deep Network (DIDN)  
During the bean roasting process, some related works [1] show that a defective bean could affect flavor of over 50 normal beans. Thus, our defect-sensitive inspection scheme needs to meticulously differentiate defective beans from normal ones. Figure 5 shows the architecture of the DIDN, which is an improvement version of our previously designed deep network [36]. The DIDN consists of four main components and each of them are described below. The first component is the dual object feature extractor, used to extract object features from image inputs. For generality of system design, the term \"object\" is used for representing coffee beans in this paper. This module adopts two methods as underlying feature extraction engines: one is YOLOv3, which is a deep network structure for object feature predictions; the other is Hough circle (HC) transform, which is to extract circular shapes from a given image. Details of the two methods will be presented later. The second component is the HC-based undecidable bounding box pruning module, which is used to pruning those undecidable bounding boxes by using HC information. An undecidable bounding box means more than two or no objects appear stay inside a bounding box, which is generated by the DL model. For many DL-based object detection methods, such situations frequently happen in the intermediate data, and usually the application interface suppresses most these data and uses the case of highest probability for result interpretations. In our scheme, only undecidable bounding boxes are pruning and all decidable bounding boxes are reserved, since they provide information of object confidence and class probabilities for calibrating other overlapped bounding boxes. The third component is the HC-assisting object identification module, which is used to find out each predicted object with assistance of HCs. Comparing to the YOLOv3, our scheme does not identify an object merely on class probabilities, which may lead to misjudgments if defective beans are heavily overlapped. Our experiments will show the superiority of this module in Section 6. The fourth component is the Gaussian-based calibration module for determining classes of identified objects by calibrating class probabilities of prediction object features. This component determines the bounding boxes of final object estimation. With the proposed DIDN architecture, objects can be accurately detected with two sorts of prediction features and a sequence of post processing on them for improving inspection quality. \begin{table}
\begin{tabular}{l l} \hline Module & Interaction with related modules \\ LBIDB & provides the human-labeling training data to DSMC, GIMG, and low-detection-rate bean image generation (LBIG). \\ DSMC & creates a defect-sensitive model \(M_{k}^{DS}\) for GIMG and DMQC. \\ GIMG & creates a generative network model for LBIG. \\ LBIG & generates \(IMG^{LBIG}\) and \(L^{LBIG}\) via BSDN for AIQC. \\ AIQC & verifies the quality of \(IMG^{LBIG}\) and \(L^{LBIG}\) from LBIG and produces \(IMG^{AIQC}\) and \(L^{AIQC}_{k}\) for DMQC. \\ DMQC & verifies the quality of \(M_{k}^{DS}\) from DSMC with \(IMG^{AIQC}_{k}\) and \(L^{AIQC}_{k}\) and activates DSMC for the next \\  & model training iteration if current model is not qualified. \\ \hline \end{tabular}
\end{table} 
Table 1: The interaction relationship of modules in the proposed scheme, as shown in Figure 4.  
We next briefly present the concepts of YOLOv3 and HC transform, as they are adopted in the dual object feature extractor. The YOLOv3 architecture [37] is adopted in the dual object feature extractor, shown in Figure 5. YOLOv3 totally has 106 convolutional and residual layers, where three scales of prediction features in the tensor forms (\(82\times 82\), \(96\times 96\), \(108\times 108\)) are outputted for making final object detection decisions with the non-max suppression (NMS) method [24].