Automation! Automatic detection of defects in die castings based on machine learning
Time:2024-05-05 17:08:14 / Popularity: / Source:
Die castings are widely used in automobiles, medical equipment, electronic equipment, communication equipment and other fields. Their performance will affect service life of entire equipment, it is of positive significance to conduct defect detection and life assessment. Die castings are prone to defects during production process, such as water lines, blistering, shrinkage cavities, discoloration, mechanical strain, deformation, cracks, flash, fleshy and mold-sticking strains, etc. Traditional methods are mostly manual detection, which has poor detection results, is time-consuming and labor-intensive. In recent years, deep learning technology has attracted increasing attention. Its deep integration with factory production can greatly improve detection efficiency of casting defects and improve working environment.
Researchers improved YOLACT algorithm, which can identify defects and perform semantic segmentation. There were 67 sub-defects and 2,727 defect maps in test. Defect recognition rate increased from initial 62.0% to 65.8%, and detection rate was also optimized. Cascade model is used to solve problems of missing samples and uneven proportions, and defect coordinates are determined by comparing positive samples with defective samples. At the same time, by training Mask-RCNN model, defects can be directly located and defect types identified. Use lighter MobileNetv2 network to replace original backbone network DarkNet53 of Yolov3, introduce CIoU mechanism to more accurately calculate position loss. For a data set mainly composed of scratch defects, defect recognition rate is increased by 5% based on original Yolov3 model, and detection speed is increased by 23 f/s. Two aluminum die-casting defect sets are generated through three-dimensional ellipsoid model and GAN model. Defect set consists of a large number of normal castings and a small number of defective castings. Results show that three-dimensional ellipsoid model is more effective than GAN model, with mAP (mean average precision) reaching 71.02%. BX-Net network using DenseNet121 as backbone can identify defects in X-ray images of aviation castings with an accuracy of 99%.
Current research suffers from lack of data sets and single defect types, which cannot better reflect complexity of actual production, or defect types can reflect actual situation but model accuracy is not enough. This study expanded collected data set through self-developed software to improve model identification capabilities. Defect set used has 21 kinds of defects, which has many types and can better reflect actual production situation. At the same time, model is optimized to improve accuracy and efficiency of defect detection, aiming to provide a reference for defect detection of similar castings.
Researchers improved YOLACT algorithm, which can identify defects and perform semantic segmentation. There were 67 sub-defects and 2,727 defect maps in test. Defect recognition rate increased from initial 62.0% to 65.8%, and detection rate was also optimized. Cascade model is used to solve problems of missing samples and uneven proportions, and defect coordinates are determined by comparing positive samples with defective samples. At the same time, by training Mask-RCNN model, defects can be directly located and defect types identified. Use lighter MobileNetv2 network to replace original backbone network DarkNet53 of Yolov3, introduce CIoU mechanism to more accurately calculate position loss. For a data set mainly composed of scratch defects, defect recognition rate is increased by 5% based on original Yolov3 model, and detection speed is increased by 23 f/s. Two aluminum die-casting defect sets are generated through three-dimensional ellipsoid model and GAN model. Defect set consists of a large number of normal castings and a small number of defective castings. Results show that three-dimensional ellipsoid model is more effective than GAN model, with mAP (mean average precision) reaching 71.02%. BX-Net network using DenseNet121 as backbone can identify defects in X-ray images of aviation castings with an accuracy of 99%.
Current research suffers from lack of data sets and single defect types, which cannot better reflect complexity of actual production, or defect types can reflect actual situation but model accuracy is not enough. This study expanded collected data set through self-developed software to improve model identification capabilities. Defect set used has 21 kinds of defects, which has many types and can better reflect actual production situation. At the same time, model is optimized to improve accuracy and efficiency of defect detection, aiming to provide a reference for defect detection of similar castings.
Graphical results
Data set plays role of "trainer" and "detector" in deep learning detection. Lack of data sets will lead to problems such as overfitting and inaccurate detection of model. Since there are fewer defective parts in actual production, data set obtained through actual sampling alone is far from enough. Therefore, when there are few samples, geometric transformations, such as rotation and scaling, are used to expand data set to better assist model defect identification. Augment data set through rotation and scaling. Step of rotation is to set an angle starting point and end point, and give program a certain step length. Image is automatically rotated and transformed through program, as shown in Figure 1, and xml file is generated based on pre-annotation file. Scaling is divided into equal scaling and non-equal scaling, see Figure 2 and Figure 3.
Figure 1 Effect diagram before and after rotation
Figure 2 Effect diagram before and after proportional scaling of length and width
Figure 3 Effect diagram before and after specifying length and width scaling
Mosaic data enhancement method evolved from CutMix algorithm. Algorithm principles of two are relatively similar, but Mosaic uses 4 pictures for splicing, which better enhances diversity of data. At the same time, pictures with different semantics are also added to enhance robustness of model, enhance normalization layer effect, and improve target detection mAP. Principle is shown in Figure 4. Mixup is a method of linearly mixing images at a certain ratio to expand data set. Through Mixup method, linear expression between training samples can be enhanced, making decision boundaries between classes smoother, improving stability of model training and generalization ability of model, Mixup has less computing overhead. It can expand data set while also taking into account speed of model training.
Mosaic data enhancement method evolved from CutMix algorithm. Algorithm principles of two are relatively similar, but Mosaic uses 4 pictures for splicing, which better enhances diversity of data. At the same time, pictures with different semantics are also added to enhance robustness of model, enhance normalization layer effect, and improve target detection mAP. Principle is shown in Figure 4. Mixup is a method of linearly mixing images at a certain ratio to expand data set. Through Mixup method, linear expression between training samples can be enhanced, making decision boundaries between classes smoother, improving stability of model training and generalization ability of model, Mixup has less computing overhead. It can expand data set while also taking into account speed of model training.
Figure 4 Principle of Mosaic data enhancement
Figure 5 Defect pictures before Mixup
Figure 6 Defect pictures after Mixup
YOLOX is developed based on YOLOV3 model by adding special structures such as anchorless frames and decoupled heads. According to different networks, there are 6 models in total, which are nano, tiny, s, m, l, and x in order of network size. After comprehensive consideration, YOLOX-S model was selected to detect defects in die castings. Network structure of YOLOX model consists of input end (Input), backbone network (Backbone), feature fusion network (Neck), and prediction network (Prediction) using decoupling head. Basic structure of ShuffleNetv2 is composed of three structures: channel splitting, depth-separable convolution and channel shuffling. ShuffleNetv2-plus used is an improved version of ShuffleNetv2, that is, based on original model, Shuffle-Xception module is added; SE channel attention mechanism is introduced in last stage of model training. At the same time, HS (h-swish) activation function is used in last two stages to replace original ReLU activation function and used in conjunction with SE attention mechanism; finally, maximum pooling layer after initial convolution in original model is removed, and dropout mechanism is turned on.
YOLOX is developed based on YOLOV3 model by adding special structures such as anchorless frames and decoupled heads. According to different networks, there are 6 models in total, which are nano, tiny, s, m, l, and x in order of network size. After comprehensive consideration, YOLOX-S model was selected to detect defects in die castings. Network structure of YOLOX model consists of input end (Input), backbone network (Backbone), feature fusion network (Neck), and prediction network (Prediction) using decoupling head. Basic structure of ShuffleNetv2 is composed of three structures: channel splitting, depth-separable convolution and channel shuffling. ShuffleNetv2-plus used is an improved version of ShuffleNetv2, that is, based on original model, Shuffle-Xception module is added; SE channel attention mechanism is introduced in last stage of model training. At the same time, HS (h-swish) activation function is used in last two stages to replace original ReLU activation function and used in conjunction with SE attention mechanism; finally, maximum pooling layer after initial convolution in original model is removed, and dropout mechanism is turned on.
Figure 7 ShuffleNetv2 structure diagram
Figure 8 Shuffle-Xception structure diagram
Figure 9 SE attention mechanism structure diagram
Test uses Ubuntu 18.04.01 version, CPU model is Intel (R) Core (TM) i9-10980XE, GPU model is Geforce RTX 3090, quantity is 2, CUDA version is 11.3, python version is 3.8, and pytorch version is 1.10. Original model network structure Darknet53 is replaced by ShuffleNetv2-plus. Initial learning rate is 1*10-3, Epoch is set to 180, optimizer uses adam, momentum is set to 0.937, weight attenuation is set to 0, and only Mosaic data enhancement is turned on. There are 21 types of defects in data set, and there are only 2 pictures of each defect in initial data set. Independently developed a die-casting defect detection software based on YOLOX model. Through data enhancement module of software, original data set is expanded through geometric transformation operations of rotation and scaling, and image label files are automatically generated. Self-developed software can not only expand defective data set, but also skip labeling data set, thus greatly improving work efficiency. At the same time, software also has model training and defect detection functions, which can better monitor model training progress and defect identification.
Test uses Ubuntu 18.04.01 version, CPU model is Intel (R) Core (TM) i9-10980XE, GPU model is Geforce RTX 3090, quantity is 2, CUDA version is 11.3, python version is 3.8, and pytorch version is 1.10. Original model network structure Darknet53 is replaced by ShuffleNetv2-plus. Initial learning rate is 1*10-3, Epoch is set to 180, optimizer uses adam, momentum is set to 0.937, weight attenuation is set to 0, and only Mosaic data enhancement is turned on. There are 21 types of defects in data set, and there are only 2 pictures of each defect in initial data set. Independently developed a die-casting defect detection software based on YOLOX model. Through data enhancement module of software, original data set is expanded through geometric transformation operations of rotation and scaling, and image label files are automatically generated. Self-developed software can not only expand defective data set, but also skip labeling data set, thus greatly improving work efficiency. At the same time, software also has model training and defect detection functions, which can better monitor model training progress and defect identification.
Figure 10 Die casting defect detection software interface based on YOLOX model
Formula parameters | Meaning |
TP(True Positives) | Number of positive samples identified by model is actually number of positive samples. |
FP(False Positives) | Number of positive samples identified by model is actually number of negative samples. |
FN(False Negatives) | Number of negative samples identified by model is actually number of positive samples |
TN(True Negatives) | Number of negative samples identified by model is actually number of negative samples |
P(Precision) | Precision |
R(Recall) | Recall rate |
AP(Average Precision) | Average accuracy |
P(r) | Precision rate is plotted on vertical axis and recall rate is plotted on horizontal axis. |
Table 1 Evaluation indicator formula parameters
Figure 11 Comparison of results before and after improvement
Figure 12 4 types of defects that are difficult to identify
Model structure | mAP/% |
YOLOX | 86.51 |
YOLOX-Glou | 86.82 |
YOLOX-Focal Loss | 84.88 |
YOLOX-GIOU-Focal Loss | 84.88 |
ShuffleNetv2-plus-YOLOX | 84.88 |
Table 2 Comparison of test results of different model structures
In conclusion
In view of difficulties in collecting die-casting defect detection data sets, as well as high labor intensity and low efficiency of defect detection, we independently developed a die-casting defect detection software based on YOLOX model, which can not only expand data set and generate corresponding labels, but also has functions of monitoring model training and defect detection. By using ShuffleNetv2-plus to replace YOLOX's Darknet53 network structure, average detection rate of die-casting defects by improved YOLOX model increased from original 86.51% to 89.19%.
Recommended
Related
- A brief introduction to current status and development trend of die-casting aluminum alloy industry12-28
- Technical points for injection molding of transparent products.12-28
- Influence of external factors on quality of die castings in die casting production and countermeasur12-27
- Injection mold 3D design sequence and design key points summary12-27
- Effect of heat treatment on structure and mechanical properties of die-cast AlSi10MnMg shock tower12-26