## 4 Design
### Classification Network Structure Design  
The RPN is only responsible for the generation of candidate regions, and the region after the generation needs a classification network to be designed to identify it. Here, based on the characteristics of the detected image, a general method for improving the positive sample is proposed. The classification network maps the candidate regions generated by the RPN back to the feature map. The candidate regions contain positive and negative samples, where the positive samples represent the defect regions, the negative samples represent the non-category regions, and the positive and negative samples are filtered according to the IoU (Intersection-over-Union). The calculation formula of IoU is shown in Equation (1); that is, the intersection area between the real border A and the predicted border B divided by the union between the real border A and the predicted border B:  
\[IoU=\frac{area(A\cap B)}{area(A\cup B)} \tag{1}\]  
Usually, positive and negative samples have a great impact on the performance of the model. In general, it is necessary to maintain an approximately 1:3 ratio of positive and negative samples to achieve the best classification effect. If \(IoU\) is greater than a certain threshold, it can be classified as a positive sample. If \(IoU\) is less than a certain threshold, it will be used as a negative sample. In the general object recognition field, \(IoU\) takes a value of 0.5 as the judgment value for dividing the positive and negative samples. In practice, in the RPN output stage, the \(IoU\) screening threshold of the positive and negative samples needs to be adjusted. Here, since the identified objects are different in the detected image, the pits and the breaches are small, and the abrasion and scratches are large; thus, the small target defects such as the pit and the breach defects are sensitive to the offset of the bounding box. It is easy to treat this as a negative sample, resulting in too many positive samples and too few positive samples. Therefore, using 0.5 as the screening threshold in the identification of shaft surface defects obviously produces a large number of negative samples. Here, we propose a multiple \(IoU\) value setting idea; the principle is shown in Figure 10, where border 1 is the ground truth (real border) generated by our label, and border 3 and border 2 are all converted from the anchor. Now, let \(IoU\)=\(x\), and below the value of \(x\) (generally \(x\) = 0.5), we then select two \(IoU\) values: \(x_{1}\) and \(x_{2}\), and \(0<x_{1}<x_{2}<x\). Assuming the \(IoU\) value of border 3 and border 1 and the \(IoU\) value of border 2 and border 1 are between \(x_{1}\) and \(x_{2}\), respectively, both will be judged as positive samples. However, although the \(IoU\) value of border 2 and border 1 are within the screening range of the positive sample, the defect object is not within border 2, and it is obviously undesirable for this to be judged as a positive sample. For border 3, with the same \(IoU\) value, the defect object is obviously in bounding box 3, and its  
Figure 9: Region Proposal Network (RPN) implementation process. judgmentas positive sample is suitable. Thus, we will discard the candidate regions generated by the small-size anchor and select the candidate regions generated by the large-size anchor. The screening process of positive and negative samples is shown in Figure 11. The _IoU_ between the input candidate region and the ground truth is directly discriminated as a negative sample if \(IoU<x_{1}\); if \(x_{1}<IoU<x_{2}\) (let \(x_{2}\)=\(x\)),the candidate region generated by the anchor of \(128^{2}\) (the largest-size group) is used as a positive sample, and the rest as a negative sample; if \(IoU>x_{2}\), it is determined as a positive sample. If \(x_{2}\) is not equal to \(x\), the chance of the selection of positive samples can be increased again.