Industrial product surface defect detection method based on deep learning
By improving the structure of the YOLOX network model, the problems of insufficient feature extraction capabilities and poor generalization in industrial surface defect detection are solved, the detection accuracy and computing efficiency are improved, and they are suitable for mobile terminals and embedded devices.
Patent Information
- Application Number
- CN202211138132.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-19
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2042-09-19
AI Technical Summary
In the detection of industrial surface defects, existing deep learning methods have problems such as insufficient network feature extraction capabilities, many redundant pre-selected boxes, high computing costs and poor generalization.
The optimized YOLOX deep learning network model is adopted, including the Focus module, the basic convolution module, the deformable convolution module, the CSPLayer layer, the main body residual cycle block structure and the coordinate attention mechanism module. By improving the structure of the backbone network and the detection head, the accuracy of feature extraction and classification is improved.
It improves the computing speed, detection accuracy and generalization capabilities of the network, and can better learn long-distance spatial position relationships, and is suitable for mobile terminals and embedded devices.
Smart Images

Figure CN115511812B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of machine vision image processing, and in particular to a method for detecting surface defects of industrial products based on deep learning. Background Art
[0002] As a key product of the steel industry, strip steel has become an essential raw material for industries such as automotive, machinery manufacturing, chemical equipment, and aerospace. Over the past decade or so, rapid advancements in strip steel production technology have significantly improved strip steel's quality characteristics, including thickness, width, and shape. However, with the booming development of high-tech industries like aerospace, automotive, and precision machinery, higher standards for strip steel product quality are being placed on the strip steel surface. However, due to factors such as raw materials, production technology, processes, and environmental conditions, surface defects such as impurities, spots, and scratches are inevitable on the strip steel surface, severely impacting production efficiency and product quality. Therefore, effective strip steel surface defect detection is a key step in ensuring high-quality strip steel production and a crucial component of industrial production. Rigorous strip steel production inspection is essential for improving strip steel quality. Furthermore, effectively controlling strip steel surface defects not only reduces economic losses from scrap but also improves product quality, thereby enhancing the market competitiveness of steel companies and promoting high-quality development in related industries. Strip defect detection technology based on machine vision is one of the key methods to solve the above problems. Research on automatic defect detection algorithm based on strip surface image has very important practical value for improving strip quality. It can not only improve the automation level and production efficiency of strip products, but also greatly reduce the labor intensity and labor cost of quality inspectors. The application prospects are very broad.
[0003] In recent years, deep learning has achieved remarkable results in image classification, object detection, and object tracking. The paper (J. Redmon, S. Divvala, R. Girshic, and A. Farhadi, “You Only Look Once: Unified, Real-Time Object Detection,” 2016 IEEE Conference on Computer Vision and Pattern Recognition, pp. 779-788, June 2016) proposed an end-to-end object detection algorithm, YOLOv1, which unifies the object detection problem into a regression problem. The paper (J. Redmon and A. Farhadi, “YOLO9000: Better, Faster, Stronger,” 2017 IEEE Conference on Computer Vision and Pattern Recognition, pp. 6517-6525, July 2017) proposed YOLO9000, which improves on v1 in terms of recall and localization capabilities. YOLOv3, proposed in the paper (J. Redmon and A. Farhadi, “YOLOv3: An incremental improvement,” 2018, arXiv:1804.02767.), draws on the residual concept of ResNet, further improving both speed and accuracy. The paper (X. Kou, S. Liu, K. Cheng, and Y. Qian, “Development of a YOLO-V3-based model for detecting defects on steel strip steel surface,” Measurement, vol. 182, Sep. 2021, Art. no. 109454.) applied the YOLOv3 algorithm to the NEU-DET dataset, achieving a mean average prediction accuracy (MAP) of 72.2%, demonstrating the applicability of YOLOv3 for steel strip surface defect detection.
[0004] However, in actual industrial scenarios, existing surface defect detection methods still have shortcomings. On the one hand, the backbone network of the YOLO series is difficult to continue to improve and achieve better results in industrial surface defect feature extraction; on the other hand, the limitations of the anchor box detector will cause the network to produce a large number of redundant pre-selected boxes, resulting in high computational costs and poor network generalization.
[0005] Therefore, in order to improve the accuracy and generalization of the algorithm in industrial surface defect detection, the present invention improves on the basis of YOLOX according to its characteristics. Summary of the Invention
[0006] The purpose of the present invention is to provide a method for detecting surface defects of industrial products based on deep learning, which improves the calculation speed, detection accuracy and generalization ability of the network model.
[0007] The present invention provides a method for detecting surface defects of industrial products based on deep learning, comprising the following steps:
[0008] Step S1: photographing on an industrial production line to collect original images of the surface of industrial products;
[0009] Step S2: Label the defect categories of the original images of the industrial product surface to obtain an industrial product surface defect dataset:
[0010] Step S3: using a defect image in the industrial product surface defect dataset as input and performing data enhancement on the input image;
[0011] Step S4: Use the optimized YOLOX deep learning network model to build an industrial product surface defect detection model, where the optimized YOLOX deep learning network model includes a Focus module, a basic convolution module, a deformable convolution module, a CSPLayer layer, a main residual loop block structure, a coordinate attention mechanism module, and a YOLOXHead module;
[0012] The CSPLayer layer performs a feature extraction operation on the network by nesting a small residual block in a large residual block; wherein the large residual block is a basic convolution module with a 1×1 convolution kernel size, and the small residual block is a continuous basic convolution module with a 1×1 convolution kernel size and an enhanced deformable feature extraction block; the enhanced deformable feature extraction module includes: first, using a basic convolution module with a 1×1 convolution kernel size and a basic convolution module with a 3×3 convolution kernel size to extract features in sequence, secondly, using a deformable convolution module with a 3×3 convolution kernel size and a basic convolution module with a 3×3 convolution kernel size to extract features in sequence, and thirdly, using a residual edge to extract features. The backbone feature extraction network performs a cyclic main feature extraction operation on the small residual block. After the cycle is completed, the features extracted by the small residual block and the large residual block are superimposed on the information;
[0013] The YOLOXHead module uses the basic convolution module to process the channel of the input feature layer and then splits it. On one side, a pair of basic convolution modules with a convolution kernel size of 3×3 are used to extract features for classification tasks. On the other side, an enhanced deformable feature convolution module is introduced, which uses a deformable convolution module with a convolution kernel size of 3×3 and a basic convolution module with a convolution kernel size of 3×3 to extract features. After channel adjustment, the features are split for regression tasks and target tasks.
[0014] The constructed network model performs the following steps:
[0015] Extract features of different scales through the backbone feature extraction network CSPDarknet;
[0016] Through the neck network, the features are deeply fused and extracted to enhance the expression of features at different scales;
[0017] Generate an industrial product surface defect detection model using the YOLOXHead based on the anchor-free detector as the detection head;
[0018] Step S5: training network model
[0019] The data-augmented industrial product surface defect dataset obtained in step S3 is divided into a training set, a test set, and a validation set, and the network model is trained using the divided dataset to generate a trained industrial product surface defect detection model; a loss function is used in the training process of the industrial product surface defect detection model, and the weights in the loss function are updated using an optimizer until the training is completed, and a weight file of the network model after the training is completed is saved;
[0020] Step S6: Load the weight file obtained after training, and use the network model trained in step S5 to perform surface defect detection on the industrial product image, generate prediction results and display the defect type and defect location.
[0021] The Focus module is used to segment the input defect image. It obtains a pixel value for every other pixel in the image, splits the image into four feature layers through interval sampling, and stacks these four feature layers in the channel dimension.
[0022] Basic convolutional modules, including convolution, batch normalization, and activation functions;
[0023] Deformable convolution module, including deformable convolution, batch normalization and activation function;
[0024] The main residual recurrent block structure consists of a basic convolution module with a 3×3 convolution kernel size and a CSPLayer layer;
[0025] The coordinate attention mechanism module performs residual processing on the input feature layer, splits it into horizontal and vertical average pooling operations, stacks and integrates the information, transforms the channels using convolution operations, and then splits the feature layer using batch normalization and nonlinear activation operations. It then adjusts the channels in the horizontal and vertical directions, and integrates the information output after using the sigmoid activation function.
[0026] The constructed network model performs the following steps:
[0027] The input image is segmented by the Focus module, divided into 4 feature layers, and then stacked in the channel dimension. Then, a basic convolution module with a 3×3 convolution kernel size is used for preliminary feature extraction. The output result first enters the main residual cycle block 1 for 1 feature extraction, and the size of the feature layer is compressed to obtain a 56×56×128 feature layer. Secondly, it enters the main residual cycle block 2 for 3 cyclic feature extractions, and the size of the feature layer is compressed to obtain a 28×28×256 feature layer P1. Again, it enters the main residual cycle block 3 for 3 cyclic feature extractions, and the size of the feature layer is compressed to obtain a 14×14×512 feature layer P2. Finally, it enters the main residual cycle block 4 for 1 feature extraction. After passing through the basic convolution module, it first passes through the coordinate attention mechanism module, and then enters the CSPLayer layer. After compressing the size of the feature layer, a 7×7×1024 feature layer P3 is obtained. At this point, the feature extraction in the backbone feature extraction network is completed;
[0028] Then, the feature layer P3 extracted from the backbone feature extraction network is subjected to channel adjustment and then an upsampling operation is performed, and then the feature layer P2 extracted from the backbone feature extraction network is stacked, and a CSPLayer feature extraction operation is performed to obtain a new feature layer C2; the feature layer C2 is subjected to channel adjustment, and then the feature layer P1 extracted from the backbone feature extraction network is stacked, and a CSPLayer feature extraction operation is performed to obtain a new feature layer C3; the feature layer C3 is downsampled, and the feature layer C2 is stacked and a CSPLayer feature extraction operation is performed to obtain a new feature layer C4; the feature layer C4 is downsampled, and the feature layer P3 is stacked and a CSPLayer feature extraction operation is performed to obtain a new feature layer C5. At this point, the deep fusion feature extraction in the neck network is completed;
[0029] The basic convolution module is used to process the channels of the input feature layers C3, C4, and C5 respectively, and then split. On one side, a pair of basic convolution modules with a 3×3 convolution kernel size are used to extract features, and then a classification operation is performed. On the other side, the enhanced deformable feature convolution module is used, which uses a deformable convolution module with a 3×3 convolution kernel size and a basic convolution module with a 3×3 convolution kernel size to extract features, and then performs regression and target operations.
[0030] The loss function used in the training process of the industrial product surface defect detection model is:
[0031] Loss=λL reg +L cls +L obj
[0032] Among them, L reg represents the regression loss, L cls represents the classification loss, L obj Represents the target loss, λ is the weight, and the optimizer is used to update the weight until the training is completed. The weight file of the network model after the training is completed is saved.
[0033] The advantages of the present invention are:
[0034] 1. By modifying the small residual block inside CSPLayer, the enhanced deformable feature extraction module of the present invention adds a pair of 3×3 convolution modules to address the problem of insufficient original residual feature extraction capability. The deformable convolution can perform pixel offset, which expands the network's receptive field and strengthens the connection between the network's feature information of irregular industrial surface defect targets, enabling the network to better learn long-distance spatial position relationships, enhance its sampling capability of feature maps, and to a certain extent retain the integrity of feature information, thereby improving the network's ability to extract defect features.
[0035] 2. By modifying the small feature map feature extraction part of the last layer of the backbone network, the present invention introduces a coordinate attention mechanism, which effectively improves the classification accuracy and enhances the generalization ability of the network.
[0036] 3. By modifying the regression convolution part in YOLOXHead, the present invention uses an enhanced deformation feature convolution module for the regression convolution part in the head part, which not only improves the network's ability to capture feature space position information, but also enables more comprehensive information learning for irregularly distributed defects. It also improves accuracy while reducing the number of model parameters, enabling the present invention to be transplanted and applied to mobile terminals or embedded devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1It is a flow chart of the industrial product surface defect detection method based on deep learning of the present invention;
[0038] Figure 2 Schematic diagram of the deformable convolution module provided by the present invention;
[0039] Figure 3 This is a schematic diagram of the basic convolution module provided by the present invention;
[0040] Figure 4 It is a schematic diagram of the CSPLayer structure provided by the present invention;
[0041] Figure 5 Schematic diagram of the enhanced deformation feature convolution module provided by the present invention;
[0042] Figure 6 Schematic diagram of the enhanced deformation feature extraction module provided by the present invention;
[0043] Figure 7 is a schematic diagram of a YOLOXHead implemented in the present invention;
[0044] Figure 8 It is a schematic diagram of the structure of the defect detection network CSPDarknet implemented in the present invention;
[0045] Figure 9 It is a schematic diagram of the Focus structure in the network model structure implemented by the present invention.
[0046] Figure 10 It is a partial schematic diagram of the coordinate attention mechanism in the network model structure implemented by the present invention. DETAILED DESCRIPTION
[0047] In order to more clearly understand the above-mentioned objects, features and advantages of the present invention, the present invention is described in detail below with reference to the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present invention and the features therein can be combined with each other without conflict.
[0048] The following description sets forth numerous specific details to facilitate a thorough understanding of the present invention. The embodiments described are merely some, not all, of the present invention. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without inventive effort are intended to fall within the scope of protection of the present invention.
[0049] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present invention. The terms used in the specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention.
[0050] The terms "first," "second," and "third," etc., in the specification and claims of the present invention and the accompanying drawings are used to distinguish between different items, not to describe a specific order. Furthermore, the terms "comprise," "comprising," and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus comprising a series of steps or elements is not limited to the listed steps or elements but may optionally include steps or elements not listed, or may optionally include other steps or elements inherent to the process, method, product, or apparatus.
[0051] Please refer to Figures 1 to 10 As shown, one of the preferred embodiments of the present invention is a method for detecting surface defects of industrial products based on deep learning, comprising the following steps:
[0052] Step S1: photographing on an industrial production line to collect original images of the surface of industrial products;
[0053] Step S2: annotate the original image of the industrial product surface with defects to obtain an industrial product surface defect dataset:
[0054] Use labelImg software to annotate images of industrial product surface defects. The annotation information includes the x and y coordinates of the upper left and lower right corners and the defect category name. A labeling file containing the annotation information is obtained. The labeling file format is XML. The labeling file and defect images are divided according to the defect category name to obtain an industrial product surface defect dataset.
[0055] Step S3: using defect images in the industrial product surface defect dataset as input, and applying three different data enhancement methods to the input images, including random angle rotation, random vertical flipping, and mosaic enhancement;
[0056] Step S4: Build a network model
[0057] The optimized YOLOX deep learning network model is used as the industrial product surface defect detection model. The YOLOX deep learning network model includes the following basic modules:
[0058] Focus module, such as Figure 9 As shown in the figure, the input defect image is segmented, and a pixel value is obtained for every other pixel in the image. The image is split into four feature layers through this interval sampling method. These four feature layers are stacked in the channel dimension and the results are output to the basic convolution module;
[0059] Basic convolution modules, such as Figure 3 As shown, it includes convolution, batch normalization and activation function (Silu);
[0060] Deformable convolution modules, such as Figure 2 As shown, it includes deformable convolution, batch normalization and activation function (Silu);
[0061] CSPLayer layer, such as Figure 4 As shown in the figure, the network is subjected to feature extraction by nesting the small residual block in the large residual block; wherein the large residual block is a basic convolution module with a 1×1 convolution kernel size, and the small residual block is a continuous basic convolution module with a 1×1 convolution kernel size and an enhanced deformable feature extraction block; the enhanced deformable feature extraction module includes: first, using a basic convolution module with a 1×1 convolution kernel size and a basic convolution module with a 3×3 convolution kernel size to extract features in sequence, secondly, using a deformable convolution module with a 3×3 convolution kernel size and a basic convolution module with a 3×3 convolution kernel size to extract features in sequence, and thirdly, using a residual edge to extract features, and the backbone feature extraction network performs a cyclic main feature extraction operation on the small residual block. After the cycle is completed, the features extracted by the small residual block and the large residual block are superimposed on the information;
[0062] The main residual recurrent block structure consists of a basic convolution module with a 3×3 convolution kernel size and a CSPLayer layer;
[0063] Coordinate attention mechanism module, such as Figure 10 As shown in the figure, the input feature layer is processed by residual, split into average pooling operations in the horizontal and vertical directions, and stacked to integrate information. The channel is transformed using convolution operation, and the feature layer is split using batch normalization and nonlinear activation operations. The channels are then adjusted in the horizontal and vertical directions, and the sigmoid activation function is used to integrate the information output.
[0064] YOLOXHead module, such as Figure 7 As shown in the figure, the basic convolution module is used to process the channel of the input feature layer, and then split it. On one side, a pair of basic convolution modules with a convolution kernel size of 3×3 are used to extract features for classification tasks. On the other side, the enhanced deformable feature convolution module is introduced, and a deformable convolution module with a convolution kernel size of 3×3 and a basic convolution module with a convolution kernel size of 3×3 are used to extract features. After channel adjustment, the layers are split for regression tasks and target tasks.
[0065] like Figure 8 As shown, the constructed network model performs the following steps:
[0066] Step S4-1: Extract features of different scales through the backbone feature extraction network CSPDarknet, specifically:
[0067] The input image is segmented by the Focus module, divided into 4 feature layers, and then stacked in the channel dimension. Then, a basic convolution module with a 3×3 convolution kernel size is used for preliminary feature extraction. The output result first enters the main residual cycle block 1 for 1 feature extraction, and the size of the feature layer is compressed to obtain a 56×56×128 feature layer. Secondly, it enters the main residual cycle block 2 for 3 cyclic feature extractions, and the size of the feature layer is compressed to obtain a 28×28×256 feature layer P1. Again, it enters the main residual cycle block 3 for 3 cyclic feature extractions, and the size of the feature layer is compressed to obtain a 14×14×512 feature layer P2. Finally, it enters the main residual cycle block 4 for 1 feature extraction. After passing through the basic convolution module, it first passes through the coordinate attention mechanism module, and then enters the CSPLayer layer. After compressing the size of the feature layer, a 7×7×1024 feature layer P3 is obtained. At this point, the feature extraction in the backbone feature extraction network is completed;
[0068] Step S4-2: Deeply fuse the features through the neck network to extract features and enhance the expression of features at different scales. Specifically:
[0069] First, the feature layer P3 extracted from the backbone feature extraction network is adjusted for channels and then upsampled. This is then stacked with the feature layer P2 extracted from the backbone feature extraction network, and a CSPLayer feature extraction operation is performed to obtain a new feature layer C2.
[0070] Secondly, the feature layer C2 is channel-adjusted, and then stacked with the feature layer P1 extracted from the backbone feature extraction network, and a CSPLayer feature extraction operation is performed to obtain a new feature layer C3;
[0071] Next, perform a downsampling operation on the feature layer C3, stack it with the feature layer C2, and perform a CSPLayer feature extraction operation to obtain a new feature layer C4;
[0072] Finally, the feature layer C4 is downsampled, stacked with the feature layer P3, and subjected to a CSPLayer feature extraction operation to obtain the new feature layer C5. At this point, the deep fusion feature extraction in the neck network is completed.
[0073] Step S4-3: Generate an industrial product surface defect detection model using the YOLOXHead based on the anchor-free detector as the detection head, specifically:
[0074] First, the basic convolution module is used to process the channels of the input feature layers C3, C4, and C5 respectively, and then split. On one side, a pair of basic convolution modules with a 3×3 convolution kernel size are used to extract features, and then a classification operation is performed. On the other side, the enhanced deformable feature convolution module is used, which uses a deformable convolution module with a 3×3 convolution kernel size and a basic convolution module with a 3×3 convolution kernel size to extract features, and then performs regression and target operations.
[0075] Step S5: training the network model, including the following steps:
[0076] Step S5-1, dividing the data-enhanced industrial product surface defect dataset obtained in step S3 into a training set, a test set, and a validation set in a ratio of 8:1:1;
[0077] Step S5-2: using the divided data set to train the network model to generate a trained industrial product surface defect detection model;
[0078] The loss function used in the training process of the industrial product surface defect detection model is:
[0079] Loss=λL reg +L cls +L obj
[0080] Among them, L reg represents the regression loss, L cls represents the classification loss, L obj represents the target loss, λ is the weight, the default value is 5.0, and the weight is updated using the Adam optimizer until the training is completed. The weight file of the network model after training is saved;
[0081] The image input size is 224×224, and the Adam optimizer is used with a learning rate of 0.0005, a momentum of 0.937, a weight decay of 0, a learning rate descent method of cosine, and a batch size of 32. Training is done on a single GPU.
[0082] Step S6: Load the weight file obtained after training, and use the network model trained in step S5 to perform surface defect detection on the industrial product image, generate prediction results and display the defect type and defect location.
[0083] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above and that the invention can be implemented in other specific forms without departing from the spirit or essential features of the invention. Therefore, the embodiments should be regarded as exemplary and non-restrictive from any point of view, and the scope of the invention is defined by the appended claims rather than the above description, and it is intended that all changes that fall within the meaning and scope of the equivalents of the claims be encompassed within the present invention. Any figure marks in the claims should not be regarded as limiting the claims to which they relate. Furthermore, it is clear that the word "comprising" does not exclude other units or, and the singular does not exclude the plural. Multiple units or devices stated in a system claim may also be implemented by one unit or device through software or hardware. Words such as first, second, etc. are used to indicate names and do not indicate any particular order.
[0084] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not limiting. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention.
Claims
1. A method for detecting surface defects of industrial products based on deep learning, characterized in that The steps include: Step S1: photographing on an industrial assembly line to collect original images of the surface of industrial products; Step S2: Label the original image of the industrial product surface by defect category to obtain an industrial product surface defect dataset: Step S3: using a defect image in the industrial product surface defect dataset as input and performing data enhancement on the input image; Step S4: Use the optimized YOLOX deep learning network model to build an industrial product surface defect detection model, where the optimized YOLOX deep learning network model includes a Focus module, a basic convolution module, a deformable convolution module, a CSPLayer layer, a main residual loop block structure, a coordinate attention mechanism module, and a YOLOXHead module; The CSPLayer layer performs a feature extraction operation on the network by nesting a small residual block in a large residual block; wherein the large residual block is a basic convolution module with a 1×1 convolution kernel size, and the small residual block is a continuous basic convolution module with a 1×1 convolution kernel size and an enhanced deformation feature extraction module; the enhanced deformation feature extraction module includes: first, using a basic convolution module with a 1×1 convolution kernel size and a basic convolution module with a 3×3 convolution kernel size to extract features in sequence, secondly, using a deformable convolution module with a 3×3 convolution kernel size and a basic convolution module with a 3×3 convolution kernel size to extract features in sequence, and thirdly, using a residual edge to extract features. The backbone feature extraction network performs a cyclic main feature extraction operation on the small residual block. After the cycle is completed, the features extracted by the small residual block and the large residual block are superimposed on the information; The YOLOXHead module uses the basic convolution module to process the channel of the input feature layer and then splits it. On one side, a pair of basic convolution modules with a convolution kernel size of 3×3 are used to extract features for classification tasks. On the other side, an enhanced deformable feature convolution module is introduced, which uses a deformable convolution module with a convolution kernel size of 3×3 and a basic convolution module with a convolution kernel size of 3×3 to extract features. After channel adjustment, the features are split for regression tasks and target tasks. The constructed network model performs the following steps: Extract features of different scales through the backbone feature extraction network CSPDarknet; Through the neck network, the features are deeply fused and extracted to enhance the expression of features at different scales; Generate an industrial product surface defect detection model using the YOLOXHead based on the anchor-free detector as the detection head; Step S5: training the network model The data-augmented industrial product surface defect dataset obtained in step S3 is divided into a training set, a test set, and a validation set, and the network model is trained using the divided dataset to generate a trained industrial product surface defect detection model; a loss function is used in the training process of the industrial product surface defect detection model, and the weights in the loss function are updated using an optimizer until the training is completed, and a weight file of the network model after the training is completed is saved; Step S6: Load the weight file obtained after training, and use the network model trained in step S5 to perform surface defect detection on the industrial product image, generate prediction results and display the defect type and defect location.
2. The method for detecting surface defects of industrial products based on deep learning according to claim 1, characterized in that: The Focus module is used to segment the input defect image. It obtains a pixel value for every other pixel in the image, splits the image into four feature layers through interval sampling, and stacks these four feature layers in the channel dimension. Basic convolutional modules, including convolution, batch normalization, and activation functions; Deformable convolution module, including deformable convolution, batch normalization and activation function; The main residual recurrent block structure consists of a basic convolution module with a 3×3 convolution kernel size and a CSPLayer layer; The coordinate attention mechanism module performs residual processing on the input feature layer, splits it into average pooling operations in the horizontal and vertical directions, stacks them to integrate information, uses convolution operations to transform channels, and then uses batch normalization and nonlinear activation operations to split the feature layer. It then adjusts the channels in the horizontal and vertical directions, and integrates the information output after using the sigmoid activation function.
3. The method for detecting surface defects of industrial products based on deep learning according to any one of claims 1 or 2, characterized in that The constructed network model performs the following steps: The input image is segmented by the Focus module, divided into 4 feature layers, and then stacked in the channel dimension. Then, a basic convolution module with a 3×3 convolution kernel size is used for preliminary feature extraction. The output result first enters the main residual cycle block 1 for 1 feature extraction, and the size of the feature layer is compressed to obtain a 56×56×128 feature layer. Secondly, it enters the main residual cycle block 2 for 3 cyclic feature extractions, and the size of the feature layer is compressed to obtain a 28×28×256 feature layer P1. Again, it enters the main residual cycle block 3 for 3 cyclic feature extractions, and the size of the feature layer is compressed to obtain a 14×14×512 feature layer P2. Finally, it enters the main residual cycle block 4 for 1 feature extraction. After passing through the basic convolution module, it first passes through the coordinate attention mechanism module, and then enters the CSPLayer layer. After compressing the size of the feature layer, a 7×7×1024 feature layer P3 is obtained. At this point, the feature extraction in the backbone feature extraction network is completed; Then, the feature layer P3 extracted from the backbone feature extraction network is adjusted for channels and then up-sampled, and then stacked with the feature layer P2 extracted from the backbone feature extraction network, and a CSPLayer feature extraction operation is performed to obtain a new feature layer C2; Adjust the channels of feature layer C2, stack it with feature layer P1 extracted from the backbone feature extraction network, and perform a CSPLayer feature extraction operation to obtain a new feature layer C3; Downsample the feature layer C3, stack it with the feature layer C2, and perform a CSPLayer feature extraction operation to obtain a new feature layer C4; The feature layer C4 is downsampled, stacked with the feature layer P3, and subjected to a CSPLayer feature extraction operation to obtain a new feature layer C5. At this point, the deep fusion feature extraction in the neck network is completed. The basic convolution module is used to process the channels of the input feature layers C3, C4, and C5 respectively, and then split. On one side, a pair of basic convolution modules with a 3×3 convolution kernel size are used to extract features, and then a classification operation is performed. On the other side, the enhanced deformable feature convolution module is used, which uses a deformable convolution module with a 3×3 convolution kernel size and a basic convolution module with a 3×3 convolution kernel size to extract features, and then performs regression and target operations. The loss function used in the training process of the industrial product surface defect detection model is: Loss=λL reg +L cls +L obj Among them, L reg represents the regression loss, L cls represents the classification loss, L obj Represents the target loss, λ is the weight, and the optimizer is used to update the weight until the training is completed. The weight file of the network model after the training is completed is saved.
Citation Information
Patent Citations
Convolutional-neural-network learning method of multi-scale progressive accumulation
CN108875906A
Industrial product defect detection method based on deep learning
CN110570396A