LabelImg: CNN-Based Surface Defect Detection
Mohsen Asghari Ilani, Yaser Mike Banad
Published: 2025/9/6
Abstract
In the journey of computer vision system development, the acquisition and utilization of annotated images play a central role, providing information about object identity, spatial extent, and viewpoint in depicted scenes. However, thermal manufacturing processes like Laser Powder Bed Fusion (LPBF) often yield surfaces with defects such as Spatter, Crack, Pinhole, and Hole due to the Balling phenomenon. Preprocessing images from LPBF, riddled with defects, presents challenges in training machine learning (ML) algorithms. Detecting defects is critical for predicting production quality and identifying crucial points in artificial or natural structures. This paper introduces a deep learning-based approach utilizing Convolutional Neural Networks (CNNs) to automatically detect and segment surface defects like cracks, spatter, holes, and pinholes on production surfaces. In contrast to traditional machine learning techniques requiring extensive processing time and manual feature crafting, deep learning proves more accurate. The proposed architecture undergoes training and testing on 14,982 labeled images annotated using the LabelImg tool. Each object in the images is manually annotated with bounding boxes and segmented masks. The trained CNN, coupled with OpenCV preprocessing techniques, achieves an impressive 99.54% accuracy on the dataset with resolutions of 1536 x 1103 pixels. Evaluation metrics for 50 true crack tests demonstrate precision, recall, and F1-score exceeding 96%, 98%, and 97%, respectively. Similarly, for 124 true pinhole tests, the metrics are 99%, 100%, and 100%, for 258 true hole tests, they are 99%, 99%, and 99%, and for 318 spatter tests, the metrics are 100%, 99%, and 100%. These results highlight the precision and effectiveness of the entire process, showcasing its potential for reliable defect detection in production surfaces.