## 2 Methods
### Training of Pattern Detection Model  
In recent years, object detection technology has achieved rapid development, and the object detection network based on deep learning has greatly improved the ability of object detection. At present, there are two main methods: one depends on region proposal, such as R-CNN (region convolutional neural network) [17], Fast R-CNN [18], Faster R-CNN [13] and R-FCN [19]; the other does not rely on region proposal and directly estimates candidate object recommendations, such as SSD [20] and YOLO [21; 22; 23] family. After R-CNN [17] and Fast R-CNN [18], Microsoft's [PERSON] proposed Faster R-CNN [13] to optimize the running time of the detection network. The region proposal network (RPN) was proposed to generate the proposal region. RPN replaces the previous methods such as Selective Search [24] and EdgeBoxes [25] and it shares the convolution feature of the full map with the detection network so that the region proposal detection takes very little time. The Faster R-CNN structural framework consists of RPN + Fast R-CNN. The RPN network is mainly used to generate high-quality proposal region boxes, and Fast R-CNN is used to learn high-quality proposal region features and classify objects. The overall framework of Faster R-CNN is shown in Figure 4.  
Figure 4: Faster region convolutional neural network (R-CNN) overall framework. (**a**) The streamlined flow chart of the Faster R-CNN framework [26]. (**b**) The detailed flow chart of the Faster R-CNN [13]. Faster R-CNN proposes the region proposal network and improves the efficiency of object detection. This provides feasibility for detecting multi-period patterns with Faster R-CNN. Three nets (ZF-Net [27], VGG16 [28] and Rse-Net-101 [29]) were respectively used as the pre-trained model of Faster R-CNN, where the pattern dataset contained 5382 patterns and a total of six types of patterns: F\({}_{i}\), F\({}_{r}\), F\({}_{w}\), F\({}_{s1}\), F\({}_{s2}\) and F\({}_{s3}\) (see Figure 3). The number of various pattern images was 894, 899, 902, 892, 904 and 891. Image size was 512 \(\times\) 640 pixels. The pattern dataset was randomly divided into validation set, test set and train set according to the ratio of 2:2:6. Then, the divided datasets were used for training of Faster R-CNN (ZF-Net), Faster R-CNN (VGG16) and Faster R-CNN (ResNet-101), respectively. The experimental platforms included Windows 7, GPU GTX1080 ti, Matlab 2014a and Visual Studio 2013, and the whole experiment was based on the deep learning framework Caffe. The compared results are shown in Table 1, where the performance of the three pattern detection models can be seen. Precision represented the detection accuracy of the pattern. Balanced accuracy (Ba) was used to evaluate balanced accuracy of the pattern dataset. Kappa (K) was used to evaluate the accuracy of the pattern classification. Mean average precision (mAP) was the main indicator for evaluating the main detection results, because mAP was the actual metric for object detection. From Table 1, it can be concluded that the precision, K, Ba and mAP of the Resnet-101 net as the pre-trained model were higher than the other two nets, and thus Resnet-101 was chosen as the pre-trained model in this paper. Figure 5 shows the detection results of the six patterns (\(F_{i}\), \(F_{r}\), \(F_{w}\), \(F_{s1}\), \(F_{s2}\) and \(F_{s3}\)) on the Faster R-CNN model. The boxes of different colors represent the different pattern categories detected by the model; the upper left corner of the box represents the classification result, pattern category and category score for the object of the box region. Since the patterns \(F_{s1}\), \(F_{s2}\), \(F_{s3}\) and \(F_{r}\) had the characteristics of large pattern pitch, small volume and regular shape, we chose to completely surround the pattern with the bounding box. The patterns \(F_{i}\) and \(F_{c}\) were irregular shapes and could not be completely surrounded by the bounding box, so we regarded a part of the pattern having the periodic characteristics as the detection object.