Citation: Lv, N.; Xiao, J.; Qiao, Y.
Object Detection Algorithm for
Surface Defects Based on a Novel
YOLOv3 Model. Processes 2022, 10,
701. https://doi.org/10.3390/
pr10040701
Academic Editor: Mohd Azlan
Hussain
Received: 5 March 2022
Accepted: 2 April 2022
Published: 5 April 2022
Publisher’s Note: MDPI stays neutral
with regard to jurisdictional claims in
published maps and institutional affil-
iations.
Copyright: © 2022 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/).
Article
Object Detection Algorithm for Surface Defects Based on a
Novel YOLOv3 Model
Ning Lv
1,2
, Jian Xiao
2
and Yujing Qiao
1,
*
1
School of Mechanical Engineering, Yangzhou Polytechnic College, Yangzhou 225009, China; ning_lv@163.com
2
School of Automation, Harbin University of Science and Technology, Harbin 150080, China;
xiaojian0451@126.com
* Correspondence: qiaoyujing@sina.com
Abstract:
The surface defects of industrial structural parts have the characteristics of a large-scale
span and many small objects, so a novel YOLOv3 model, the YOLOv3-ALL algorithm, is proposed in
this paper to solve the problem of precise defect detection. The K-means++ algorithm is combined
with the intersection-over-union (IoU) and comparison of the prior box for clustering, which improves
the clustering effect. The convolutional block attention module (CBAM) is embedded in the network,
thus improving the ability of the network to obtain key information in the image. By adding fourth-
scale prediction, the detection capability of a YOLOv3 network for small-object defects is greatly
improved. A loss function is designed, which adds the generalized intersection-over-union (GIoU)
loss combined with focal loss to solve the problems of L2 loss and class imbalance in samples.
Experiments regarding contour-defect detection for stamping parts show that the mean average
precision (mAP) of the YOLOV3-ALL algorithm reaches 75.05% in defect detection, which is 25.16%
higher than that of the YOLOv3 algorithm. The average detection time is 39 ms/sheet. This proves
that the YOLOv3-ALL algorithm has good real-time detection efficiency and high detection accuracy.
Keywords: defect detection; YOLOv3; object detection; K-means++; loss function
1. Introduction
Surface-defect detection is an important research topic in the field of machine vision
[1–3]
.
Classical methods usually adopt conventional processing algorithms or artificially designed
features and classifiers. However, in a real and complex industrial environment, surface-
defect detection often faces many challenges, such as small differences between the defect
imaging and background, low contrast, large changes in defect scale, various types of
defects, and a large amount of noise in defect images. There can also be significant interfer-
ence in defect imaging in the natural environment [
4
–
8
]. Currently, the classical methods
tend to have limited use, and it is difficult to obtain good detection results with them. With
the development of artificial intelligence technology, the research focus of surface-defect
detection based on machine vision has shifted from classical image processing and machine
learning methods to deep learning methods, which solve problems that cannot be solved
by traditional methods in many industrial contexts [
9
–
14
]. If the problem of very precise
defect-size detection is not considered, which corresponds to the task of computer vision in
defect detection, the essence of defect detection is similar to object detection. This is used
to determine what the defects are, where they are located, how many defects there are, and
how they interact.
Before 2016, object-detection algorithms based on deep learning were mainly realized
through ergodic classification tasks, such as DPM, R-CNN, etc. [
15
–
17
]. The more precisely
these algorithms are traversed, the more accurate the detector will be, but with huge time
and space costs. The YOLO algorithm reconstructs object recognition into a regression
problem, which can directly predict boundary coordinates and class probability through
image pixels. In other words, in the YOLO system, you only need to look at an image
Processes 2022, 10, 701. https://doi.org/10.3390/pr10040701 https://www.mdpi.com/journal/processes