# Solder Joint Defect Detection in the Connectors Using Improved Faster-RCNN Algorithm
## 4 Discussion  
In this paper, the algorithm of Faster-RCNN was improved. The five transformation modes of left-right flipping, up-down flipping, diagonal flipping, random brightness, and random contrast were used in the data set to solve the problem of small amount of data in the original data set and avoid the situation of under-fitting during network model training. According to the generation mode of anchor boxes in RPN, this paper proposed to cluster the data sets using k-means clusters, analyzed the average IOU of anchor boxes generated by clustering algorithm in the case of different k values, and then selected appropriate clusters number to generate anchor boxes, which improved the positioning accuracy of proposals. Given the insufficiency of feature extraction network for connector's solder joint defect feature extraction capability, the convolutional neural network with deeper layers is needed. In addition, considering that the deepening of the network may cause gradient explosion and reduce the accuracy of the model, this paper proposed to replace the VGG-16 with ResNet-101. After network replacement, the algorithm mentioned in this paper has enhanced its own ability to extract solder joint defect characteristics of connectors, and the network model has higher accuracy and stability.  
After comparing and analyzing the actual detection capability and model precision of different algorithms, we find that the algorithm proposed in this paper is superior to the original Faster-RCNN in all aspects. The mAP of the algorithm increased from 0.8554 to 0.941, increasing by 8%. The final top-1 accuracy rate increased from 78 to 94%, with an improvement of 16%. Nevertheless, 94% of top-1 accuracy has been able to meet the needs of industrial detection.  
We hope to detect the solder joint defects automatically with machine vision, so the algorithm proposed can only detect the solder joint image collected by the optical camera, but cannot detect the defects such as cracks or bubbles inside the solder joint. Currently, there are various types of connectors used in electronic products, and the sample used in this paper is only D-type data interface connector with 9 pins. However, the defect type and appearance of solder joint of connector are basically the same because the shape of welding cup of different connector is similar. Therefore the improved Faster-RCNN algorithm  
Figure 12: Some of typical detect results. In the pictures, hg represents qualified solder joint; dx represents multi-tin solder joint; sx represents less-tin solder joint; lh represents connected welding solder joint; xj represents tin tip solder joint.  
proposed in this paper can still obtain similar high accuracy rate, for the detection of solder joint defects in different connectors.  
In the industry, there are many kinds of defects in connector solder joints. This paper only took 4 typical defect types and qualified solder joints as examples to train the model in this paper, it is still a long way to go in terms of ultimate practicality. Meanwhile, due to the lack of computing power, the algorithm of batch size 256 can see the loss jumping in the training process. The reason is that the smaller batch size does not match the images of more data sets, so the batch normalization effect of each batch of images is poor, which affects the model training and reduces the test accuracy to a certain extent. Therefore, in the following research, we will increase the types and images of solder joint defects, and at the same time consider more optimized training methods, so as to increase the algorithm's ability to detect more kinds of solder joint defects on the premise of ensuring high accuracy and at the same time reduce the detection cost.