Cost-Sensitive YOLOv5 for Detecting Surface Defects of Industrial Products
Abstract
:1. Introduction
- Therefore, a classification loss function based on a label–cost vector selection method is designed, which can equip YOLOv5 with cost sensitivity after training. The misclassification cost involved might be the labor cost of defect detection, security cost, etc., which can be specified in practice by defining the cost matrix.
- Compared with the original YOLOv5 model, CS-YOLOv5 can solve the internal cost-sensitive problem, exploiting the classification risks defined by a risk matrix in specific applications.
- Experiments on our newly constructed painting defect dataset as well as a hot-rolled steel strip defect dataset demonstrate the superiority of our approach.
2. Methodology
2.1. Cost-Sensitive Learning Modeling
- False acceptance coefficient λNP: the risk of misclassifying a target (imposter) that belongs to the negative category into the positive category or positive class (gallery).
- False rejection coefficient λPN: the risk of misclassifying a gallery to an imposter.
- Two types of misidentification coefficients λPP and λNN: that is, misclassification between classes of samples with the same nature (the positive class or negative class).
2.2. Direct-Type Cost-Sensitive Learning
2.3. CS-YOLOv5 Model and Method Analysis
2.3.1. Cost-Sensitive Gradients
2.3.2. Cost-Sensitive YOLOv5 Algorithm
Algorithm 1: Training direct-type cost-sensitive YOLOv5 |
Input: training space , validation set , minibatch size b, training epochs , learning rate lr, as well as loss weight , and model g(θ) Output: trained model g(θ*) 1: Initialize parameters randomly of the model g(θ0) 2: If the current epoch , loop: 3: If the current batch is j, loop: 4: Forward propagation: 5: Calculate the loss based on Equation (12) 6: Calculate the gradient and backpropagation, execute the SGD algorithm 7: Update parameter 8: Evaluate the model: 9: Return |
End |
3. Experiments and Results Analysis
3.1. Experimental Dataset
3.2. YOLOv5 Model Settings
3.3. Experimental Metrics
3.3.1. Classification Cost Evaluation Metric
3.3.2. Comprehensive Metrics
3.4. Risk Coefficient Experiment
3.4.1. Risk Coefficient Setting
3.4.2. Experimental Results and Analysis
3.5. Experiment of Positive Classes
3.5.1. Number Setting of Positive Classes
3.5.2. Experimental Results and Analysis
3.6. Weight Ratio Experiment
3.6.1. Settings for Weight Ratio Experiment
3.6.2. Experimental Results and Analysis
3.7. Ablations
3.8. Discussions and Comparisons
4. Conclusions
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Acknowledgments
Conflicts of Interest
References
- Qi, S.; Yang, J.; Zhong, Z. A Review on Industrial Surface Defect Detection Based on Deep Learning Technology. In Proceedings of the 3rd International Conference on Machine Learning and Machine Intelligence, Hangzhou, China, 18–20 September 2020; pp. 24–30. [Google Scholar] [CrossRef]
- Mahto, P.; Garg, P.; Seth, P.K.; Panda, J. Refining Yolov4 for Vehicle Detection. Int. J. Adv. Res. Eng. Technol. (IJARET) 2020, 11, 409–419. [Google Scholar]
- He, Y.; He, N.; Zhang, R.; Yan, K.; Yu, H. Multi-scale feature balance enhancement network for pedestrian detection. Multimed. Syst. 2022, 28, 1135–1145. [Google Scholar] [CrossRef]
- Ren, S.; He, K.; Girshick, R.; Sun, J. Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks. IEEE Trans. Pattern Anal. Mach. Intell. 2017, 39, 1137–1149. [Google Scholar] [CrossRef] [PubMed] [Green Version]
- Redmon, J.; Farhadi, A. YOLO9000: Better, Faster, Stronger. In Proceedings of the 30th IEEE Conference on Computer Vision and Pattern Recognition, Honolulu, HI, USA, 21–26 July 2017; pp. 6517–6525. [Google Scholar] [CrossRef] [Green Version]
- He, K.; Gkioxari, G.; Dollár, P.; Girshick, R. Mask R-CNN. In Proceedings of the 2017 IEEE International Conference on Computer Vision (ICCV), Venice, Italy, 22–29 October 2017; pp. 2961–2969. [Google Scholar] [CrossRef]
- Jocher, G.; Stoken, A.; Borovec, J.; NanoCode012; Chaurasia, A.; Liu, C.; Xie, T.; Abhiram, V.; Laughing; Tkianai; et al. Ul-tralytics/Yolov5: V5.0—YOLOv5-P6 1280 Models, AWS, Supervise.ly and YouTube Integrations. Zenodo 2021, 11. [Google Scholar] [CrossRef]
- Redmon, J.; Divvala, S.; Girshick, R.; Farhadi, A. You Only Look Once: Unified, Real-Time Object Detection. In Proceedings of the 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), Las Vegas, NV, USA, 27–30 June 2016; pp. 779–788. [Google Scholar] [CrossRef] [Green Version]
- Yang, G.; Feng, W.; Jin, J.; Lei, Q.; Li, X.; Gui, G.; Wang, W. Face mask recognition system with YOLOV5 based on image recognition. In Proceedings of the 2020 IEEE 6th International Conference on Computer and Communications (ICCC), Chengdu, China, 11–14 December 2020; pp. 1398–1404. [Google Scholar] [CrossRef]
- Chen, X.; Lv, J.; Fang, Y.; Du, S. Online Detection of Surface Defects Based on Improved YOLOV3. Sensors 2022, 22, 817. [Google Scholar] [CrossRef] [PubMed]
- Xu, R.; Hao, R.; Huang, B. Efficient surface defect detection using self-supervised learning strategy and segmentation network. Adv. Eng. Inform. 2022, 52, 101566. [Google Scholar] [CrossRef]
- Tabernik, D.; Šela, S.; Skvarč, J.; Skočaj, D. Segmentation-based deep-learning approach for surface-defect detection. J. Intell. Manuf. 2019, 31, 759–776. [Google Scholar] [CrossRef] [Green Version]
- Chen, Y.; Ding, Y.; Zhao, F.; Zhang, E.; Wu, Z.; Shao, L. Surface Defect Detection Methods for Industrial Products: A Review. Appl. Sci. 2021, 11, 7657. [Google Scholar] [CrossRef]
- Da, Y.; Dong, G.; Wang, B.; Liu, D.; Qian, Z. A novel approach to surface defect detection. Int. J. Eng. Sci. 2018, 133, 181–195. [Google Scholar] [CrossRef] [Green Version]
- Elkan, C. The foundations of cost-sensitive learning. In Proceedings of the 17th International Joint Conference on Artificial Intelligence, Seattle, WA, USA, 4–10 August 2001; Morgan Kaufmann Publishers Inc.: Seattle, WA, USA, 2001; Volume 2, pp. 973–978. [Google Scholar]
- Zhang, Y.; Zhou, Z.-H. Cost-Sensitive Face Recognition. IEEE Trans. Pattern Anal. Mach. Intell. 2010, 32, 1758–1769. [Google Scholar] [CrossRef]
- Frumosu, F.D.; Khan, A.R.; Schiøler, H.; Kulahci, M.; Zaki, M.; Westermann-Rasmussen, P. Cost-sensitive learning classification strategy for predicting product failures. Expert Syst. Appl. 2020, 161, 113653. [Google Scholar] [CrossRef]
- Tan, M.; Pang, R.; Le, Q.V. EfficientDet: Scalable and Efficient Object Detection. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, Seattle, WA, USA, 13–19 June 2020. [Google Scholar] [CrossRef]
- Wu, X.; Sahoo, D.; Hoi, S.C.H. Recent advances in deep learning for object detection. Neurocomputing 2020, 396, 39–64. [Google Scholar] [CrossRef] [Green Version]
- Fernandez, A.; Garcia, S.; Herrera, F.; Chawla, N.V. SMOTE for Learning from Imbalanced Data: Progress and Challenges, Marking the 15-year Anniversary. J. Artif. Intell. Res. 2018, 61, 863–905. [Google Scholar] [CrossRef]
- Zhu, X.; Yang, J.; Zhang, C.; Zhang, S. Efficient Utilization of Missing Data in Cost-Sensitive Learning. IEEE Trans. Knowl. Data Eng. 2021, 33, 2425–2436. [Google Scholar] [CrossRef]
- Fernández, A.; García, S.; Galar, M.; Prati, R.C.; Krawczyk, B.; Herrera, F. Cost-sensitive learning. In Learning from Imbalanced Data Sets; Springer: Berlin/Heidelberg, Germany, 2018; pp. 63–78. [Google Scholar] [CrossRef]
- Kukar, M.; Kononenko, I. Cost-Sensitive Learning with Neural Networks. In European Conference on Artificial Intelligence; John Wiley & Sons, Ltd.: Hoboken, NJ, USA, 1998; pp. 445–449. [Google Scholar] [CrossRef]
- Petrides, G.; Verbeke, W. Cost-sensitive ensemble learning: A unifying framework. Data Min. Knowl. Discov. 2022, 36, 1–28. [Google Scholar] [CrossRef]
- Khan, S.H.; Hayat, M.; Bennamoun, M.; Sohel, F.A.; Togneri, R. Cost-Sensitive Learning of Deep Feature Representations from Imbalanced Data. IEEE Trans. Neural Netw. Learn. Syst. 2018, 29, 3573–3587. [Google Scholar] [CrossRef] [Green Version]
- Zhou, Z.H.; Liu, X.Y. Training cost-sensitive neural networks with methods addressing the class imbalance problem. IEEE Trans. Knowl. Data Eng. 2006, 18, 63–77. [Google Scholar] [CrossRef]
- Li, T.; Cao, P.; Yuan, Y.; Fan, L.; Yang, Y.; Feris, R.; Indyk, P.; Katabi, D. Targeted Supervised Contrastive Learning for Long-Tailed Recognition. In Proceedings of the 2022 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), New Orleans, LA, USA, 18–24 June 2022; pp. 6908–6918. [Google Scholar] [CrossRef]
- Raj, V.; Magg, S.; Wermter, S. Towards Effective Classification of Imbalanced Data with Convolutional Neural Networks. In Artificial Neural Networks in Pattern Recognition; Springer: Cham, Switzerland, 2016; pp. 150–162. [Google Scholar] [CrossRef]
- Zhou, Z.-H. Cost-sensitive learning. In Modeling Decision for Artificial Intelligence: 8th International Conference; Springer: Berlin/Heidelberg, Germany, 2011; pp. 17–18. [Google Scholar] [CrossRef]
- Chung, Y.-A.; Lin, H.-T.; Yang, S.-W. Cost-aware pre-training for multiclass cost-sensitive deep learning. In Proceedings of the Twenty-Fifth International Joint Conference on Artificial Intelligence, New York, NY, USA, 9–15 July 2016; AAAI Press: New York, NY, USA, 2016; pp. 1411–1417. [Google Scholar] [CrossRef]
- Collell, G.; Prelec, D.; Patil, K.R. A simple plug-in bagging ensemble based on threshold-moving for classifying binary and multiclass imbalanced data. Neurocomputing 2018, 275, 330–340. [Google Scholar] [CrossRef] [PubMed]
- Kuo, W.; Häne, C.; Yuh, E.; Mukherjee, P.; Malik, J. Cost-Sensitive Active Learning for Intracranial Hemorrhage Detection. In Medical Image Computing and Computer Assisted Intervention—MICCAI; Springer: Berlin/Heidelberg, Germany, 2018; pp. 715–723. [Google Scholar] [CrossRef] [Green Version]
- Zhang, H.; Jiang, L.; Li, C. CS-ResNet: Cost-sensitive residual convolutional neural network for PCB cosmetic defect detection. Expert Syst. Appl. 2021, 185, 115673. [Google Scholar] [CrossRef]
- Liu, M.; Miao, L.; Zhang, D. Two-Stage Cost-Sensitive Learning for Software Defect Prediction. IEEE Trans. Reliab. 2014, 63, 676–686. [Google Scholar] [CrossRef]
- Natarajan, N.; Dhillon, I.S.; Ravikumar, P.; Tewari, A.J.J.M.L.R. Cost-Sensitive Learning with Noisy Labels. J. Mach. Learn. Res 2017, 18, 5666–5698. [Google Scholar]
- Seliya, N.; Khoshgoftaar, T.M. The use of decision trees for cost-sensitive classification: An empirical study in software quality prediction. WIREs Data Min. Knowl. Discov. 2011, 1, 448–459. [Google Scholar] [CrossRef] [Green Version]
- Wan, J.; Yang, M. Survey on Cost-sensitive Learning Method. J. Softw. 2019, 113–136. [Google Scholar] [CrossRef]
- Lu, S.; Liu, L.; Lu, Y.; Wang, P. Cost-sensitive neural network classifiers for postcode recognition. Int. J. Pattern Recognit. Artif. Intell. 2012, 26, 1263001. [Google Scholar] [CrossRef]
- Jiang, X.; Mahadevan, S. Bayesian risk-based decision method for model validation under uncertainty. Reliab. Eng. Syst. Saf. 2007, 92, 707–718. [Google Scholar] [CrossRef]
- LeCun, Y.; Bengio, Y.; Hinton, G. Deep learning. Nature 2015, 521, 436–444. [Google Scholar] [CrossRef] [PubMed]
- Song, K.; Yan, Y. A noise robust method based on completed local binary patterns for hot-rolled steel strip surface defects. Appl. Surf. Sci. 2013, 285, 858–864. [Google Scholar] [CrossRef]
- Espíndola, R.P.; Ebecken, N.F.F. On extending f-measure and g-mean metrics to multi-class problems. In Sixth International Conference on Data Mining, Text Mining and Their Business Applications; WIT Press: Ashurst Lodge, UK, 2005; Volume 35, pp. 25–34. [Google Scholar] [CrossRef]
- Liu, W.; Anguelov, D.; Erhan, D.; Szegedy, C.; Reed, S.; Fu, C.-Y.; Berg, A.C. SSD: Single Shot Multibox Detector; Springer International Publishing: Cham, Switzerland, 2016; pp. 21–37. [Google Scholar] [CrossRef] [Green Version]
- Chen, J.; Liu, Z.; Wang, H.; Nunez, A.; Han, Z. Automatic Defect Detection of Fasteners on the Catenary Support Device Using Deep Convolutional Neural Network. IEEE Trans. Instrum. Meas. 2018, 67, 257–269. [Google Scholar] [CrossRef] [Green Version]
- Redmon, J.; Farhadi, A. Yolov3: An incremental improvement. arXiv 2018, arXiv:1804.02767. [Google Scholar] [CrossRef]
- He, Y.; Song, K.; Meng, Q.; Yan, Y. An End-to-End Steel Surface Defect Detection Approach via Fusing Multiple Hierarchical Features. IEEE Trans. Instrum. Meas. 2020, 69, 1493–1504. [Google Scholar] [CrossRef]
(a): | (b): |
(c): | (d): |
Model | Group | NEU | Paint | ||
---|---|---|---|---|---|
mAP | F1 | mAP | F1 | ||
YOLOv5 | a | 0.76 | 0.74 | 0.61 | 0.63 |
b | 0.74 | 0.72 | 0.61 | 0.63 | |
c | 0.76 | 0.74 | 0.63 | 0.63 | |
d | 0.74 | 0.72 | 0.62 | 0.63 | |
CS-YOLOv5 | a | 0.75 | 0.74 | 0.63 | 0.63 |
b | 0.76 | 0.74 | 0.62 | 0.63 | |
c | 0.76 | 0.74 | 0.62 | 0.62 | |
d | 0.74 | 0.72 | 0.65 | 0.64 |
Model | Group | NEU | Paint | ||
---|---|---|---|---|---|
mAP | F1 | mAP | F1 | ||
YOLOv5 | 1 | 0.73 | 0.72 | 0.63 | 0.61 |
2 | 0.74 | 0.72 | 0.63 | 0.63 | |
3 | 0.74 | 0.73 | 0.64 | 0.65 | |
4 | 0.77 | 0.74 | — | — | |
CS-YOLOv5 | 1 | 0.75 | 0.73 | 0.61 | 0.63 |
2 | 0.75 | 0.72 | 0.64 | 0.64 | |
3 | 0.78 | 0.75 | 0.62 | 0.61 | |
4 | 0.74 | 0.71 | — | — |
Weight Ratio | NEU | Paint | ||
---|---|---|---|---|
mAP | F1 | mAP | F1 | |
0 | 0.75 | 0.73 | 0.61 | 0.63 |
0.25 | 0.74 | 0.72 | 0.61 | 0.63 |
0.5 | 0.72 | 0.70 | 0.61 | 0.64 |
0.75 | 0.76 | 0.73 | 0.63 | 0.63 |
1 | 0.68 | 0.67 | 0.59 | 0.62 |
1.25 | 0.68 | 0.66 | 0.60 | 0.61 |
1.5 | 0.68 | 0.66 | 0.59 | 0.59 |
Batch size | 64 | 128 | 230 |
cost (×10−3) | 0.48 | 0.47 | 0.47 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2023 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Liu, B.; Gao, F.; Li, Y. Cost-Sensitive YOLOv5 for Detecting Surface Defects of Industrial Products. Sensors 2023, 23, 2610. https://doi.org/10.3390/s23052610
Liu B, Gao F, Li Y. Cost-Sensitive YOLOv5 for Detecting Surface Defects of Industrial Products. Sensors. 2023; 23(5):2610. https://doi.org/10.3390/s23052610
Chicago/Turabian StyleLiu, Ben, Feng Gao, and Yan Li. 2023. "Cost-Sensitive YOLOv5 for Detecting Surface Defects of Industrial Products" Sensors 23, no. 5: 2610. https://doi.org/10.3390/s23052610
APA StyleLiu, B., Gao, F., & Li, Y. (2023). Cost-Sensitive YOLOv5 for Detecting Surface Defects of Industrial Products. Sensors, 23(5), 2610. https://doi.org/10.3390/s23052610