A Method and Device for Weak Edge Defect Detection in Industrial Scenarios Based on MASK R-CNN

By optimizing the MASK R-CNN network structure and combining the EffcientNet backbone network and feature map pyramid network, the candidate box scale selection and loss function are improved, solving the problem of insensitivity to weak edge information of non-ideal gray-level steps in traditional methods, and realizing efficient detection of defect contours in industrial scenarios.

CN118552480BActive Publication Date: 2026-07-03TSINGHUA UNIVERSITY

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
TSINGHUA UNIVERSITY
Filing Date
2024-05-07
Publication Date
2026-07-03

AI Technical Summary

Technical Problem

Traditional image processing methods are not sensitive to weak edge information with non-ideal grayscale steps, making it difficult to fully extract defect contours in industrial scenes.

Method used

By optimizing the MASK R-CNN network structure, combining the EffcientNet backbone network, feature map pyramid network, and target activation function, an optimized MASK R-CNN model is generated. The model is then trained using an IoU-like loss function and mask scoring to improve candidate box scale selection and loss function, thereby enabling weak edge defect detection in industrial scenarios.

Benefits of technology

It achieves efficient detection of weak edge defects in industrial scenarios, improves the judgment effect of defect contours, and solves the problem that traditional methods have difficulty in completely extracting defect contours.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118552480B_ABST
    Figure CN118552480B_ABST
Patent Text Reader

Abstract

This application relates to a method and apparatus for detecting weak edge defects in industrial scenes based on MASK R-CNN. The method includes: optimizing a pre-defined MASK R-CNN network structure based on a pre-defined EffcientNet backbone network, a feature map pyramid network, and a target activation function to generate an optimized MASK R-CNN model; constructing an industrial scene defect training dataset and inputting it into the optimized MASK R-CNN model to generate mask scores corresponding to the industrial defect training dataset based on the target candidate box scale selection strategy and target mask prediction branch network corresponding to the optimized MASK R-CNN model; establishing an IoU-like loss function for the optimized MASK R-CNN model and training the optimized MASK R-CNN model using the IoU-like loss function and mask scores to generate an industrial scene defect detection model, which is then used to perform weak edge defect detection operations in industrial scenes. This solves the problems of traditional image processing methods being insensitive to weak edge information with non-ideal grayscale steps and struggling to completely extract defect contours.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of defect detection technology, and in particular to a method and device for detecting weak edge defects in industrial scenes based on MASK R-CNN. Background Technology

[0002] During the production and processing of products, defects such as bulges, scratches, bubbles, and rust often appear on the product surface due to factors such as surface materials, production processes, and the skill level of the manufacturer. These defects not only affect the appearance of the product but also lead to a decrease in mechanical properties, making the detection of product surface defects particularly important.

[0003] Product surface defects are influenced by factors such as light source and illumination method, as well as limitations in equipment shooting accuracy and angle. Under the influence of multiple factors, they often form transition edges with slow grayscale changes, i.e., weak edges. In industrial scenarios, because the grayscale changes of weak edge defects are slow, they are more difficult to detect than strong edge defects. To solve this problem, an effective method for detecting weak edge defects is needed. Currently, a commonly used solution is image processing-based defect detection technology, which mainly performs defect detection through steps such as image denoising, edge detection, and image segmentation.

[0004] However, traditional image processing methods are not sensitive to weak edge information with non-ideal grayscale steps, making it difficult to fully extract the contours of defects, which urgently needs to be addressed. Summary of the Invention

[0005] This application provides a method and apparatus for detecting weak edge defects in industrial scenes based on MASK R-CNN, in order to solve the problems that traditional image processing methods are not sensitive to weak edge information with non-ideal gray-level steps and have difficulty in completely extracting the contour of defects.

[0006] The first aspect of this application provides a method for detecting weak edge defects in industrial scenes based on MASK R-CNN, applied in the offline training stage, including the following steps: optimizing a preset MASK R-CNN network structure based on a preset EffcientNet backbone network, feature map pyramid network, and target activation function to generate a MASK R-CNN optimized model; constructing an industrial scene defect training dataset for the MASK R-CNN optimized model, inputting the industrial scene defect training dataset into the MASK R-CNN optimized model to generate a mask score corresponding to the industrial defect training dataset according to the target candidate box scale selection strategy and target mask prediction branch network corresponding to the MASK R-CNN optimized model; establishing an IoU-like loss function for the MASK R-CNN optimized model, and training the MASK R-CNN optimized model through the IoU-like loss function and the mask score to generate an industrial scene defect detection model, so as to perform weak edge defect detection operations in industrial scenes using the industrial scene defect detection model.

[0007] Optionally, in one embodiment of this application, the target candidate box scale selection strategy includes: preprocessing the industrial scene defect training dataset to obtain a standard training dataset; obtaining label data in the standard training dataset and determining the minimum and maximum column indices of the target grayscale values ​​of the label data, so as to obtain the width and height of the defect anchor box based on the minimum and maximum column indices; calculating the K centroid detection boxes with the smallest distance to non-centroid detection boxes in the region proposal network corresponding to the standard training dataset using a preset clustering algorithm and IoU loss function, where K is a positive integer; and determining the target candidate box scale of the industrial scene defect training dataset based on the defect anchor box width and height, the K centroid detection boxes, and a preset distance metric strategy.

[0008] Optionally, in one embodiment of this application, the step of generating a mask score corresponding to the industrial defect training dataset based on the target candidate box scale selection strategy and the target mask prediction branch network corresponding to the MASK R-CNN optimization model includes: obtaining a region of interest feature map and a mask prediction feature map corresponding to the industrial scene defect training dataset; performing a downsampling operation on the mask prediction feature map to generate a downsampled mask feature map corresponding to the mask prediction feature map; concatenating the region of interest feature map and the downsampled mask feature map to obtain a feature concatenation map, and inputting the feature concatenation map into the target mask prediction branch network to output the mask score corresponding to the industrial defect training dataset.

[0009] Optionally, in one embodiment of this application, the mathematical expression of the IoU-like loss function is:

[0010]

[0011] Where j represents the mask of the j-th candidate box; m, n represent the pixel coordinates; This represents the probability value predicted by the mask. This is the actual mask label.

[0012] The second aspect of this application provides a method for detecting weak edge defects in industrial scenes based on MASK R-CNN, applied in the online detection stage, comprising the following steps: real-time acquisition of image data of the target to be detected in the target industrial scene; inputting the image data of the target to be detected into a pre-trained industrial scene defect detection model to output the industrial scene weak edge defect detection result, wherein the industrial scene defect detection model is obtained by training a MASK R-CNN optimized model constructed by a preset industrial scene defect training dataset and combining a target candidate box scale selection strategy, a target mask prediction branch network and an IoU-like loss function with a preset EffcientNet backbone network, a feature map pyramid network and a target activation function.

[0013] A third aspect of this application provides a device for detecting weak edge defects in industrial scenes based on MASK R-CNN, applied in the offline training stage. The device includes: a modeling module for optimizing a preset MASK R-CNN network structure based on a preset EffcientNet backbone network, a feature map pyramid network, and a target activation function to generate an optimized MASK R-CNN model; a scoring module for constructing an industrial scene defect training dataset for the optimized MASK R-CNN model, inputting the industrial scene defect training dataset into the optimized MASK R-CNN model, and generating a mask score corresponding to the industrial defect training dataset based on the target candidate box scale selection strategy and target mask prediction branch network corresponding to the optimized MASK R-CNN model; and a training module for establishing an IoU-like loss function for the optimized MASK R-CNN model, training the optimized MASK R-CNN model using the IoU-like loss function and the mask score, generating an industrial scene defect detection model, and using the industrial scene defect detection model to perform weak edge defect detection operations in industrial scenes.

[0014] Optionally, in one embodiment of this application, the scoring module includes: a preprocessing unit, configured to preprocess the industrial scene defect training dataset to obtain a standard training dataset; a first acquisition unit, configured to acquire label data in the standard training dataset and determine the minimum and maximum column indices of the target grayscale values ​​of the label data, so as to obtain the width and height of the defect anchor boxes based on the minimum and maximum column indices; a calculation unit, configured to calculate the K centroid detection boxes with the smallest distance to non-centroid detection boxes in the region proposal network corresponding to the standard training dataset using a preset clustering algorithm and an IoU loss function, where K is a positive integer; and a determination unit, configured to determine the target candidate box scale of the industrial scene defect training dataset based on the defect anchor box width and height, the K centroid detection boxes, and a preset distance metric strategy.

[0015] Optionally, in one embodiment of this application, the scoring module further includes: a second acquisition unit, configured to acquire a region of interest feature map and a mask prediction feature map corresponding to the industrial scene defect training dataset; a downsampling unit, configured to perform a downsampling operation on the mask prediction feature map to generate a downsampled mask feature map corresponding to the mask prediction feature map; and a stitching unit, configured to stitch the region of interest feature map and the downsampled mask feature map to obtain a feature stitched map, and input the feature stitched map into the target mask prediction branch network to output a mask score corresponding to the industrial defect training dataset.

[0016] Optionally, in one embodiment of this application, the mathematical expression of the IoU-like loss function is:

[0017]

[0018] Where j represents the mask of the j-th candidate box; m, n represent the pixel coordinates; This represents the probability value predicted by the mask. This is the actual mask label.

[0019] The fourth aspect of this application provides a weak edge defect detection device for industrial scenes based on MASK R-CNN, applied in the online detection stage, comprising: an acquisition module for real-time acquisition of image data of the target to be detected in the target industrial scene; and a detection module for inputting the image data of the target to be detected into a pre-trained industrial scene defect detection model to output the weak edge defect detection result of the industrial scene. The industrial scene defect detection model is obtained by training a MASK R-CNN optimized model constructed by a preset industrial scene defect training dataset and combining a target candidate box scale selection strategy, a target mask prediction branch network, and an IoU-like loss function with a preset EffcientNet backbone network, a feature map pyramid network, and a target activation function.

[0020] A fifth aspect of this application provides an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the MASK R-CNN-based weak edge defect detection method for industrial scenes as described in the above embodiments.

[0021] A sixth aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described MASK R-CNN-based method for detecting weak edge defects in industrial scenarios.

[0022] Therefore, the embodiments of this application have the following beneficial effects:

[0023] The embodiments of this application optimize a pre-defined MASK R-CNN network structure based on a pre-defined EffcientNet backbone network, feature map pyramid network, and target activation function to generate an optimized MASK R-CNN model. An industrial scene defect training dataset is constructed for the optimized MASK R-CNN model. This dataset is input into the optimized MASK R-CNN model to generate mask scores corresponding to the industrial defect training dataset based on the target candidate box scale selection strategy and target mask prediction branch network corresponding to the optimized MASK R-CNN model. An IoU-like loss function is established for the optimized MASK R-CNN model, and the optimized MASK R-CNN model is trained using the IoU-like loss function and mask scores to generate an industrial scene defect detection model. This model is then used to perform weak edge defect detection in industrial scenes. This application achieves good weak edge defect contour judgment results by optimizing the Mask R-CNN network structure, improving the candidate box scale selection using a clustering algorithm strategy, and partially adjusting the Mask R-CNN loss function. This solves the problems of traditional image processing methods being insensitive to weak edge information with non-ideal gray-level steps and having difficulty in completely extracting the contours of defects.

[0024] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description

[0025] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein:

[0026] Figure 1 This is a flowchart illustrating a method for detecting weak edge defects in industrial scenes based on MASK R-CNN, applied during the offline training phase, according to an embodiment of this application.

[0027] Figure 2 This is a schematic diagram of the internal network structure of a MASK R-CNN model according to an embodiment of this application;

[0028] Figure 3 This is a schematic diagram of the head network structure of a MASK R-CNN optimization model according to an embodiment of this application;

[0029] Figure 4 This is a flowchart illustrating a method for detecting weak edge defects in industrial scenes based on MASK R-CNN, applied in the online detection stage, according to an embodiment of this application.

[0030] Figure 5This is an example diagram of a MASK R-CNN-based weak edge defect detection device for industrial scenes applied in the offline training phase, according to an embodiment of this application.

[0031] Figure 6 This is an example diagram of a MASK R-CNN-based weak edge defect detection device for industrial scenarios applied in the online detection stage, according to an embodiment of this application.

[0032] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.

[0033] Among them, 10-a weak edge defect detection device for industrial scenes based on MASK R-CNN applied to the offline training stage, 20-a weak edge defect detection device for industrial scenes based on MASK R-CNN applied to the online detection stage; 101-modeling module, 102-scoring module, 103-training module; 201-acquisition module, 202-detection module; 701-memory, 702-processor, 703-communication interface. Detailed Implementation

[0034] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this application, and should not be construed as limiting this application.

[0035] The following describes a method and apparatus for detecting weak edge defects in industrial scenes based on MASK R-CNN, according to embodiments of this application, with reference to the accompanying drawings. Addressing the problems mentioned in the background section, this application provides a method for detecting weak edge defects in industrial scenes based on MASK R-CNN. In this method, a preset MASK R-CNN network structure is optimized based on a preset EffcientNet backbone network, a feature map pyramid network, and a target activation function to generate an optimized MASK R-CNN model. An industrial scene defect training dataset for the optimized MASK R-CNN model is constructed and input into the optimized MASK R-CNN model. Based on the target candidate box scale selection strategy and target mask prediction branch network corresponding to the optimized MASK R-CNN model, a mask score corresponding to the industrial defect training dataset is generated. An IoU-like loss function for the optimized MASK R-CNN model is established, and the optimized MASK R-CNN model is trained using the IoU-like loss function and the mask score to generate an industrial scene defect detection model. This industrial scene defect detection model is then used to perform weak edge defect detection operations in industrial scenes. This application optimizes the network structure of Mask R-CNN, improves the scale selection of candidate boxes using a clustering algorithm, and partially adjusts the loss function of Mask R-CNN, thereby achieving good results in judging weak edge defect contours. This solves the problems of traditional image processing methods being insensitive to weak edge information with non-ideal gray-level steps and struggling to completely extract defect contours.

[0036] Specifically, Figure 1 This is a flowchart illustrating a method for detecting weak edge defects in industrial scenes based on MASK R-CNN, applied during the offline training phase, as provided in an embodiment of this application.

[0037] like Figure 1 As shown, this MASK R-CNN-based method for detecting weak edge defects in industrial scenes includes the following steps:

[0038] In step S101, based on the preset EffcientNet backbone network, feature map pyramid network and target activation function, the preset MASK R-CNN network structure is optimized to generate the MASK R-CNN optimized model.

[0039] Those skilled in the art should understand that in deep learning and other model architectures, the backbone network is generally used for image feature extraction. For the MASK R-CNN network structure (i.e., the MASK R-CNN model), it uses ResNet101 or similar networks instead of VGG as its backbone network. Figure 2As shown; furthermore, the region proposal network in the MASK R-CNN model is used to generate candidate boxes for contour recognition, which can be further subdivided into an anchor box generation module and an anchor box head module; the head network of the MASK R-CNN model can be used for prediction, including the following three branches:

[0040] 1. Classification branch, used to predict instance class;

[0041] 2. Detection box regression branch, used to further regress the difference between the proposed boxes and the true detection boxes;

[0042] 3. Mask prediction branch, used for target segmentation.

[0043] Therefore, the embodiments of this application can first optimize the MASK R-CNN model from the three parts of the backbone network, neck network and head network to construct an optimized MASK R-CNN model. The specific process is as follows:

[0044] 1. Backbone network selection:

[0045] In actual implementation, the choice of backbone network in the MASK R-CNN model is crucial to the final detection and segmentation performance. A better backbone network can improve the accuracy and efficiency of the model, while a poor backbone network may lead to inaccurate detection and segmentation results or slow speed. If only the feature map is extracted from the last convolutional layer of the backbone network, since the feature map obtains high-level semantic information, its positional accuracy is relatively coarse. Therefore, it is more suitable for detecting large objects, but the accuracy will drop significantly when detecting small objects.

[0046] Given the characteristics of industrial scenarios, such as a small total number of defects and high processing speed requirements, the embodiments of this application comprehensively consider model lightweighting and feature extraction capabilities when selecting the backbone network. The embodiments of this application can conduct a series of experiments on network architectures such as MobileNetV3, EffcientNet, and ConvNext, and compare the experimental results to select EffcientNet as the backbone network to optimize the MASK R-CNN model.

[0047] 2. Neck network optimization:

[0048] It should be noted that since there are many methods for achieving feature fusion at different scales, and feature fusion from different scales is important for segmentation tasks, compared with other feature fusion networks, FPN (Feature Pyramid Networks) as the neck network can perform feature fusion at different scales simply and efficiently, enhancing object detection capabilities, especially improving the performance of small object detection.

[0049] Furthermore, since commonly used training datasets are generally classification task datasets, rather than datasets specifically designed for weak edge segmentation tasks, training all layers is not practically meaningful. Therefore, the EffcientNet-FPN network is appropriately simplified. From the nine trainable parameters of the EffcientNet network's feature extraction stage, layers 2, 4, and 6 are selected as inputs to the FPN network. The output feature map scales of layers 2, 4, and 6 are 56×56, 14×14, and 7×7, respectively. The output channels of the lateral connections between EffcientNet and FPN can be uniformly set to the same constant of 256.

[0050] 3. Replace the activation function of the head network:

[0051] Understandably, the activation function determines the output of a neuron and has a significant impact on both model training and performance. This application's embodiments selected several widely used activation functions in various deep learning fields for testing, such as ReLU, LeakyReLU, SELU, Silu, Mish, and GELU. Test results show that ReLU achieves relatively good performance on datasets with smaller amounts of data. Therefore, this application's embodiments can select the ReLU activation function as the activation function for the head network of a traditional Mask R-CNN model.

[0052] Therefore, the embodiments of this application select suitable backbone network, feature fusion network, and head network activation functions that are more suitable for weak edge defect detection through a large number of experiments. The selected backbone network, feature fusion network, and head network activation functions are used to optimize the MASK R-CNN model to generate an optimized MASK R-CNN model, thereby greatly improving the feature extraction capability of defects and providing reliable technical support for the realization of weak edge defect detection in industrial scenarios.

[0053] In step S102, an industrial scene defect training dataset is constructed for the MASK R-CNN optimization model. The industrial scene defect training dataset is input into the MASK R-CNN optimization model to generate a mask score corresponding to the industrial defect training dataset based on the target candidate box scale selection strategy and target mask prediction branch network corresponding to the MASK R-CNN optimization model.

[0054] After generating the MASK R-CNN optimized model, the embodiments of this application further require constructing an industrial scene defect training dataset for the MASK R-CNN optimized model, and inputting the industrial scene defect training dataset into the MASK R-CNN optimized model, so as to process the industrial scene defect training dataset accordingly through the candidate box scale selection strategy of the MASK R-CNN optimized model and the newly introduced mask prediction branch network, thereby improving the training performance of the MASK R-CNN optimized model by obtaining the mask score corresponding to the industrial defect training dataset.

[0055] Optionally, in one embodiment of this application, the target candidate box scale selection strategy includes: preprocessing the industrial scene defect training dataset to obtain a standard training dataset; obtaining label data in the standard training dataset and determining the minimum and maximum column indices of the target grayscale values ​​of the label data, so as to obtain the width and height of the defect anchor box based on the minimum and maximum column indices; using a preset clustering algorithm and IoU loss function to calculate the K centroid detection boxes with the smallest distance to the non-centroid detection boxes in the region proposal network corresponding to the standard training dataset, where K is a positive integer; and determining the target candidate box scale of the industrial scene defect training dataset based on the defect anchor box width and height, the K centroid detection boxes, and a preset distance metric strategy.

[0056] In the actual implementation, the MASK R-CNN model can use a region proposal network to filter candidate boxes. The generation of candidate boxes depends on the setting of anchor boxes. Manually set anchor boxes may deviate significantly from the center scale of anchor boxes in a specific dataset, which will slow down the convergence speed of the MASK R-CNN model and reduce its generalization performance.

[0057] To achieve better contour recognition results, embodiments of this application can use the K-means++ clustering algorithm to perform anchor frame center clustering on the industrial scene defect training dataset. This method can automatically determine the anchor frame scale and aspect ratio based on the size and shape of the objects or defects in the industrial scene defect training dataset, thereby enabling the anchor frame to better adapt to the target object and effectively improving the performance of defect detection and localization.

[0058] Specifically, the process of obtaining the anchor frame width and height of the defect in the embodiments of this application is as follows:

[0059] 1. Before performing anchor box center clustering, the embodiments of this application need to preprocess the original image (i.e., the industrial scene defect training dataset) to obtain the standard training dataset and obtain the label data (i.e., label images) in the standard training dataset.

[0060] 2. Since the input training image data and label images are preprocessed to specific width and height (i.e. the width and height of the image data in the standard training dataset) and then fed into the MASK R-CNN optimization model for training, the actual objects to be clustered should be the anchor box scale corresponding to the standard training dataset when the MASK R-CNN optimization model is trained, rather than the scale of defects in the original industrial scene defect training dataset.

[0061] Specifically, in order to obtain the anchor frame scale of the defect, the embodiments of this application need to use the same preprocessing method as in the MASKR-CNN model to scale the width and height of the label image to between 800 and 1333. Since the background pixel value in the label image is 0 and the defect pixel value is 255, the anchor frame height of the defect can be obtained by determining the minimum and maximum row indices of the gray values ​​of 255 (i.e., the target gray values) in the label image. Similarly, the anchor frame width of the defect can be obtained by determining the minimum and maximum column indices of the gray values ​​of 255 in the label image.

[0062] It should be noted that in traditional K-means++ clustering, Euclidean distance is typically used as the distance metric. However, for target detection tasks such as defect detection, the shape and size of the bounding boxes are more critical to the prediction results. Therefore, embodiments of this application may use IoU loss as a metric to measure the similarity between bounding boxes.

[0063] In actual implementation, the embodiments of this application construct an imaginary detection box based on the width and height of the data points. The detection box is divided into two categories: centroid detection boxes and non-centroid detection boxes. The centroid detection boxes are the data centers of K-means++ clustering. The embodiments of this application need to use the K-means++ algorithm to iteratively obtain the K centroid detection boxes with the smallest distance from the non-centroid detection boxes, where K is a positive integer.

[0064] In the embodiments of this application, it can be assumed that the two types of detection boxes coincide at the top left corner in space. Then, the IoU value between them can be obtained by calculating the ratio between the intersection area and the union area of ​​the two detection boxes, as shown in the following formula:

[0065]

[0066] Among them, c i Let i represent the i-th cluster center, where i∈K, min represents taking the minimum value, and max represents taking the maximum value.

[0067] When K centroids are set, each non-centroid will calculate K IoU values ​​with the K centroids. Therefore, in the embodiments of this application, the non-centroid samples need to be assigned to the centroid cluster with the minimum IoU distance, as shown in the following formula, in order to perform the next iteration.

[0068] D(x) = 1 – IoU(x,c i )

[0069] Where D represents the cross-union distance between the two detection boxes.

[0070] Therefore, the MASK R-CNN optimization model in this application embodiment can use IoU loss as a metric to measure the similarity between bounding boxes; in addition, the embodiment of this application is based on anchor box center clustering operation of K-means++, which enables the region proposal network to obtain anchor boxes that are more in line with the defect dataset of industrial scenarios, thereby improving the model convergence speed and model segmentation effect.

[0071] Optionally, in one embodiment of this application, generating a mask score corresponding to the industrial defect training dataset based on the target candidate box scale selection strategy and the target mask prediction branch network of the MASK R-CNN optimization model includes: obtaining the region of interest feature map and the mask prediction feature map corresponding to the industrial scene defect training dataset; performing a downsampling operation on the mask prediction feature map to generate a downsampled mask feature map corresponding to the mask prediction feature map; concatenating the region of interest feature map and the downsampled mask feature map to obtain a feature concatenation map, and inputting the feature concatenation map into the target mask prediction branch network to output the mask score corresponding to the industrial defect training dataset.

[0072] It should be noted that the traditional MASK R-CNN model uses classification confidence in the region proposal network to filter candidate boxes and then performs the final segmentation on the selected candidate boxes. However, using classification confidence to determine the screening process for the segmentation task can easily lead to situations where the classification is good but the segmentation effect is poor.

[0073] Therefore, embodiments of this application decouple the segmentation score and the classification score by introducing a new branch (i.e., the mask prediction branch network) to learn the relationship between the predicted mask and the actual target mask, and generate a mask quality score for each candidate target box.

[0074] As one possible approach, the embodiments of this application first obtain the region of interest feature map and mask prediction feature map corresponding to the industrial scene defect training dataset. Since the FPN network used in the embodiments of this application has 256 output channels and the mask prediction branch has 2 channels to predict the positive and negative class probabilities, but the embodiments of this application only care about the probability of the positive sample channel, the embodiments of this application can select only the second channel to be concatenated with the region of interest feature map, so the number of convolutional layer channels of the mask score prediction branch (i.e. the mask prediction branch network) becomes 257.

[0075] Since the resolution of the mask prediction feature map is 28×28, while the resolution of the region of interest feature map is 14×14, the mask prediction feature map needs to be downsampled by 1 / 2 before concatenation. This can be achieved by using max pooling with a stride of 2.

[0076] Furthermore, embodiments of this application can stitch together the feature map of the region of interest and the downsampled mask feature map to obtain a feature stitched image, which is then fed into the feature extraction network of the mask score prediction branch. This network consists of four convolutional layers with 3×3 kernels and a uniform 50 channels instead of 256 to reduce computational parameters. The first three convolutional layers of this feature extraction network have a stride of 1, and the last convolutional layer has a stride of 2. After passing through a convolutional layer with a stride of 2, the resolution of the feature map is halved. For example, with a feature map of 50 channels and a resolution of 14×14, reducing the resolution of the feature map to 7×7 can reduce the number of parameters in the classification network of the mask score prediction branch by 73.5%. In addition, the mask score prediction branch uses the ReLU activation function, the classification network consists of two fully connected layers, and a sigmoid function is added after the last fully connected layer to control the predicted score value range between [0,1].

[0077] It should be noted that the label of the loss function used in the embodiments of this application is the ratio between the mask area in the true label contained in the region of interest and the mask area in the true label, such as... Figure 3 As shown, the upper limit of the evaluation for mask prediction depends on the mask area in the real labels contained in the region of interest. The embodiments of this application can be tested using the commonly used L1 loss function and L2 loss function for regression.

[0078] Therefore, the embodiments of this application, by adding a prediction branch for mask prediction, ensure that the MASK R-CNN optimization model not only needs to accurately predict the mask category during training, but also needs to control the accuracy of the mask score prediction, thereby decoupling the classification prediction and the segmentation effect prediction, and realizing the calibration function of the mask segmentation effect.

[0079] During the inference phase, mask prediction can be performed on the first n detection boxes, which can be obtained through classification confidence. In this embodiment, the first n detection boxes are still selected through classification confidence, and the mask is predicted based on them. After passing through the mask score prediction branch, a mask score is generated. The mask score is corrected by multiplying the score by the classification confidence. Since there is only one defective object in the image analyzed in this embodiment, the final mask result is the mask with the highest score.

[0080] In step S103, an IoU-like loss function for the MASK R-CNN optimization model is established, and the MASK R-CNN optimization model is trained using the IoU-like loss function and mask scoring to generate an industrial scene defect detection model, which is then used to perform weak edge defect detection operations in the industrial scene.

[0081] Furthermore, embodiments of this application can also design suitable loss functions to achieve efficient training of the MASK R-CNN optimization model, generate an industrial scene defect detection model, and thus utilize the industrial scene defect detection model to perform real-time and reliable industrial scene weak edge defect detection operations.

[0082] Optionally, in one embodiment of this application, the mathematical expression for the IoU-like loss function is:

[0083]

[0084] Where j represents the mask of the j-th candidate box; m, n represent the pixel coordinates; This represents the probability value predicted by the mask. This is the actual mask label.

[0085] Understandably, traditional MASK R-CNN models use pixel-level binary cross-entropy loss functions for their mask prediction branches, treating the segmentation task as a pixel-level classification task to calculate the loss between the predicted result and the ground truth. However, embodiments of this application can use Jaccard distance with a threshold as an evaluation metric, and these embodiments treat the segmentation task as a mask regression task. This means the evaluation systems for the training and inference phases are inconsistent, potentially leading to a significant discrepancy between the training results and the expected performance. To bridge this gap, embodiments of this application can design an IoU-like loss function, a regression loss function, to calculate the loss between the predicted result and the ground truth label in the mask prediction branch.

[0086]

[0087] Where represents the mask of the j-th candidate box, and m, n represent the pixel coordinates. This represents the probability value of the mask prediction, and its value ranges from [0,1]. This represents the actual mask label, and its value is either 0 or 1.

[0088] In actual execution, the result of mask prediction may not be within the range of [0,1]. Therefore, the embodiments of this application can apply a sigmoid value to the mask prediction result to ensure that the probability value of mask prediction is within the range of [0,1].

[0089] Furthermore, as a possible approach, before calculating the intersection-union ratio (IUU) between the mask prediction result and the label mask, the mask prediction result can usually be binarized by setting a threshold to control the degree of boundary compression of the predicted defect mask. However, although a suitable degree of compression can improve prediction accuracy, during training, since the thresholding operation is a non-differentiable operation, backpropagation is not possible, making it difficult to process the predicted probability value to 0 or 1 through the threshold. Therefore, embodiments of this application can construct the following function to replace the threshold setting:

[0090]

[0091] Where β is a positive number greater than zero, the larger the value, the closer the function is to the step function, and in actual experiments it can be 10000; α is the set threshold, the value range is [0,1), which is used to control the defect boundary range of the mask prediction. The larger the value, the smaller the boundary range of the prediction mask, and vice versa; when β=1 and α=0, the above formula becomes the sigmoid function.

[0092] Therefore, the embodiments of this application mainly involve two operations: a sigmoid function operation and a step function-like operation. This not only ensures that the predicted mask value is between [0,1], but also allows for manual control over the degree of mask prediction compression.

[0093] The method for detecting weak edge defects in industrial scenes based on Mask R-CNN proposed in this application, applied to the offline training stage, optimizes the preset Mask R-CNN network structure based on the preset EffcientNet backbone network, feature map pyramid network, and target activation function to generate an optimized Mask R-CNN model. It constructs an industrial scene defect training dataset for the optimized Mask R-CNN model and inputs it into the optimized model. Based on the target candidate box scale selection strategy and target mask prediction branch network corresponding to the optimized Mask R-CNN model, it generates mask scores corresponding to the industrial defect training dataset. It establishes an IoU-like loss function for the optimized Mask R-CNN model and trains the optimized Mask R-CNN model using the IoU-like loss function and mask scores to generate an industrial scene defect detection model. This model is then used to perform weak edge defect detection operations in industrial scenes. This application achieves good weak edge defect contour judgment results by optimizing the Mask R-CNN network structure, improving the candidate box scale selection using a clustering algorithm strategy, and partially adjusting the Mask R-CNN loss function.

[0094] Figure 4This is a flowchart illustrating a method for detecting weak edge defects in industrial scenes based on MASK R-CNN, applied in the online detection stage, as provided in an embodiment of this application.

[0095] like Figure 4 As shown, this MASK R-CNN-based method for detecting weak edge defects in industrial scenes includes the following steps:

[0096] In step S401, image data of the target to be detected in the target industrial scene is acquired in real time.

[0097] In step S402, the target image data to be detected is input into a pre-trained industrial scene defect detection model to output the weak edge defect detection result of the industrial scene. The industrial scene defect detection model is obtained by using a preset industrial scene defect training dataset and combining a target candidate box scale selection strategy, a target mask prediction branch network and an IoU-like loss function to train a preset EffcientNet backbone network, a feature map pyramid network and a target activation function to construct a MASKR-CNN optimized model.

[0098] The method for detecting weak edge defects in industrial scenes based on Mask R-CNN, proposed in this application for online detection, involves real-time acquisition of target image data in the target industrial scene. This data is then input into a pre-trained industrial scene defect detection model to output the detection results. The industrial scene defect detection model is trained using a pre-set industrial scene defect training dataset, combined with a target candidate box scale selection strategy, a target mask prediction branch network, and an IoU-like loss function. This model is constructed by training a pre-set EffcientNet backbone network, a feature map pyramid network, and a target activation function to an optimized Mask R-CNN model. This application optimizes the Mask R-CNN network structure, improves the candidate box scale selection using a clustering algorithm, and partially adjusts the Mask R-CNN loss function, thereby achieving good weak edge defect contour judgment results.

[0099] Secondly, with reference to the accompanying drawings, a weak edge defect detection device for industrial scenes based on MASK R-CNN is described according to an embodiment of this application.

[0100] Figure 5 This is a block diagram of a MASK R-CNN-based weak edge defect detection device for industrial scenarios applied in the offline training phase according to an embodiment of this application.

[0101] like Figure 5As shown, the industrial scene weak edge defect detection device 10 based on MASK R-CNN includes: a modeling module 101, a scoring module 102, and a training module 103.

[0102] The modeling module 101 is used to optimize the preset MASK R-CNN network structure based on the preset EffcientNet backbone network, feature map pyramid network and target activation function to generate the MASK R-CNN optimized model.

[0103] The scoring module 102 is used to construct the industrial scene defect training dataset for the MASK R-CNN optimization model. The industrial scene defect training dataset is input into the MASK R-CNN optimization model to generate the mask score corresponding to the industrial defect training dataset according to the target candidate box scale selection strategy and target mask prediction branch network of the MASK R-CNN optimization model.

[0104] Training module 103 is used to establish an IoU-like loss function for the MASK R-CNN optimization model, and to train the MASK R-CNN optimization model through the IoU-like loss function and mask scoring to generate an industrial scene defect detection model, so as to perform weak edge defect detection operation in the industrial scene.

[0105] Optionally, in one embodiment of this application, the scoring module 102 includes: a preprocessing unit, a first acquisition unit, a calculation unit, and a determination unit.

[0106] The preprocessing unit is used to preprocess the industrial scenario defect training dataset to obtain a standard training dataset.

[0107] The first acquisition unit is used to acquire label data from the standard training dataset and determine the minimum and maximum column indices of the target grayscale values ​​of the label data, so as to obtain the width and height of the defect anchor box based on the minimum and maximum column indices.

[0108] The computation unit is used to calculate the K centroid detection boxes with the smallest distance to non-centroid detection boxes in the region proposal network corresponding to the standard training dataset using a preset clustering algorithm and IoU loss function, where K is a positive integer.

[0109] The determination unit is used to determine the scale of the target candidate boxes in the industrial scene defect training dataset based on the width and height of the defect anchor box, K centroid detection boxes and a preset distance metric strategy.

[0110] Optionally, in one embodiment of this application, the scoring module 102 further includes: a second acquisition unit, a downsampling unit, and a splicing unit.

[0111] The second acquisition unit is used to acquire the region of interest feature map and mask prediction feature map corresponding to the industrial scene defect training dataset.

[0112] The downsampling unit is used to perform downsampling operations on the mask prediction feature map to generate a downsampled mask feature map corresponding to the mask prediction feature map.

[0113] The stitching unit is used to stitch together the feature map of the region of interest and the downsampled mask feature map to obtain a feature stitched map. The feature stitched map is then input into the target mask prediction branch network to output the mask score corresponding to the industrial defect training dataset.

[0114] Optionally, in one embodiment of this application, the mathematical expression for the IoU-like loss function is:

[0115]

[0116] Where j represents the mask of the j-th candidate box; m, n represent the pixel coordinates; This represents the probability value predicted by the mask. This is the actual mask label.

[0117] The industrial scene weak edge defect detection device based on MASK R-CNN proposed in the embodiment of this application for offline training includes a modeling module for optimizing a preset MASK R-CNN network structure based on a preset EffcientNet backbone network, feature map pyramid network, and target activation function to generate a MASK R-CNN optimized model; a scoring module for constructing an industrial scene defect training dataset for the MASK R-CNN optimized model, inputting the industrial scene defect training dataset into the MASK R-CNN optimized model, and generating a mask score corresponding to the industrial defect training dataset according to the target candidate box scale selection strategy and target mask prediction branch network corresponding to the MASK R-CNN optimized model; and a training module for establishing an IoU-like loss function for the MASK R-CNN optimized model, and training the MASK R-CNN optimized model through the IoU-like loss function and mask score to generate an industrial scene defect detection model, which is then used to perform industrial scene weak edge defect detection operations. This application optimizes the network structure of Mask R-CNN, improves the scale selection of candidate boxes using a clustering algorithm, and partially adjusts the loss function of Mask R-CNN, thereby achieving good results in judging weak edge defect contours.

[0118] Figure 6 This is a block diagram of a MASK R-CNN-based weak edge defect detection device for industrial scenarios applied in the online pre-stage according to an embodiment of this application.

[0119] like Figure 6 As shown, the MASK R-CNN-based industrial scene weak edge defect detection device 20 applied in the online detection stage includes: a data acquisition module 201 and a detection module 202.

[0120] Among them, the acquisition module 201 is used to acquire image data of the target to be detected in the target industrial scene in real time.

[0121] The detection module 202 is used to input the target image data to be detected into a pre-trained industrial scene defect detection model to output the weak edge defect detection result of the industrial scene. The industrial scene defect detection model is obtained by using a preset industrial scene defect training dataset and combining a target candidate box scale selection strategy, a target mask prediction branch network and an IoU-like loss function to train a preset EffcientNet backbone network, a feature map pyramid network and a target activation function to construct a MASK R-CNN optimized model.

[0122] It should be noted that the foregoing explanation of the embodiment of the weak edge defect detection method for industrial scenes based on MASK R-CNN also applies to the weak edge defect detection device for industrial scenes based on MASK R-CNN in this embodiment, and will not be repeated here.

[0123] The industrial scene weak edge defect detection device based on MASK R-CNN proposed in the embodiment of this application for online detection includes an acquisition module for real-time acquisition of target image data to be detected in the target industrial scene; and a detection module for inputting the target image data to be detected into a pre-trained industrial scene defect detection model to output the industrial scene weak edge defect detection result. The industrial scene defect detection model is obtained by training a MASK R-CNN optimized model constructed from a pre-set industrial scene defect training dataset using a target candidate box scale selection strategy, a target mask prediction branch network, and an IoU-like loss function. This application achieves good weak edge defect contour judgment results by optimizing the network structure of Mask R-CNN, improving the scale selection of candidate boxes using a clustering algorithm strategy, and partially adjusting the loss function of Mask R-CNN.

[0124] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device may include:

[0125] The memory 701, the processor 702, and the computer program stored on the memory 701 and executable on the processor 702.

[0126] When the processor 702 executes the program, it implements the weak edge defect detection method for industrial scenes based on MASK R-CNN provided in the above embodiments.

[0127] Furthermore, electronic devices also include:

[0128] Communication interface 703 is used for communication between memory 701 and processor 702.

[0129] The memory 701 is used to store computer programs that can run on the processor 702.

[0130] The memory 701 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.

[0131] If the memory 701, processor 702, and communication interface 703 are implemented independently, then the communication interface 703, memory 701, and processor 702 can be interconnected via a bus to complete communication between them. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of representation, Figure 7 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0132] Optionally, in a specific implementation, if the memory 701, processor 702, and communication interface 703 are integrated on a single chip, then the memory 701, processor 702, and communication interface 703 can communicate with each other through an internal interface.

[0133] The processor 702 may be a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application.

[0134] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described MASK R-CNN-based method for detecting weak edge defects in industrial scenarios.

[0135] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.

[0136] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "N" means at least two, such as two, three, etc., unless otherwise explicitly specified.

[0137] Any process or method described in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or N executable instructions for implementing custom logic functions or processes, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as should be understood by those skilled in the art to which embodiments of this application pertain.

[0138] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Alternatively, the computer-readable medium may be paper or other suitable media on which the program can be printed, since the program can be obtained electronically by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in a computer memory.

[0139] It should be understood that the various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, the N steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. If implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0140] Those skilled in the art will understand that all or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, the program includes one or a combination of the steps of the method embodiments.

[0141] Furthermore, the functional units in the various embodiments of this application can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.

[0142] The storage medium mentioned above can be a read-only memory, a disk, or an optical disk, etc. Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of this application.

Claims

1. A method for detecting weak edge defects in industrial scenes based on MASK R-CNN, applied in the offline training stage, characterized in that, Includes the following steps: Based on the pre-defined EffcientNet backbone network, feature map pyramid network, and target activation function, the pre-defined MASK R-CNN network structure is optimized to generate an optimized MASK R-CNN model. Construct an industrial scene defect training dataset for the MASK R-CNN optimization model, input the industrial scene defect training dataset into the MASK R-CNN optimization model, and generate a mask score corresponding to the industrial scene defect training dataset according to the target candidate box scale selection strategy and target mask prediction branch network corresponding to the MASK R-CNN optimization model. Establish an IoU-like loss function for the MASK R-CNN optimization model, and train the MASK R-CNN optimization model using the IoU-like loss function and the mask score to generate an industrial scene defect detection model, so as to perform weak edge defect detection operation in the industrial scene using the industrial scene defect detection model; The step of generating the mask score corresponding to the industrial defect training dataset based on the target candidate box scale selection strategy and the target mask prediction branch network corresponding to the MASK R-CNN optimization model includes: Obtain the region of interest feature map and mask prediction feature map corresponding to the industrial scene defect training dataset; The mask prediction feature map is downsampled to generate a downsampled mask feature map corresponding to the mask prediction feature map; The feature map of the region of interest and the downsampled mask feature map are concatenated to obtain a feature concatenation map, and the feature concatenation map is input into the target mask prediction branch network to output the mask score corresponding to the industrial defect training dataset; The mathematical expression for the IoU-like loss function is: in, Indicates the first Candidate box mask; Indicates the pixel coordinate position; This represents the probability value predicted by the mask. This is the actual mask label.

2. The method according to claim 1, characterized in that, The target candidate box scale selection strategy includes: The industrial scenario defect training dataset is preprocessed to obtain a standard training dataset; Obtain the label data from the standard training dataset, and determine the minimum and maximum column indices of the target grayscale values ​​of the label data, so as to obtain the width and height of the defect anchor box based on the minimum and maximum column indices; Using a pre-defined clustering algorithm and IoU loss function, the region proposal network corresponding to the standard training dataset is calculated to have the smallest distance between itself and the non-centroid detection boxes. K One centroid detection frame, among which... K It is a positive integer; Based on the width and height of the defective anchor frame, the K Using a centroid detection box and a preset distance metric strategy, the target candidate box scale of the industrial scene defect training dataset is determined.

3. A method for detecting weak edge defects in industrial scenes based on MASK R-CNN, comprising the method for detecting weak edge defects in industrial scenes based on MASK R-CNN as described in any one of claims 1-2, applied in the offline training stage, and applied in the online detection stage, characterized in that, Includes the following steps: Real-time acquisition of image data of the target to be detected in the target industrial scene; The target image data to be detected is input into a pre-trained industrial scene defect detection model to output the weak edge defect detection result of the industrial scene. The industrial scene defect detection model is obtained by using a preset industrial scene defect training dataset and combining a target candidate box scale selection strategy, a target mask prediction branch network and an IoU-like loss function to train a preset EffcientNet backbone network, a feature map pyramid network and a target activation function to construct a MASK R-CNN optimized model.

4. A device for detecting weak edge defects in industrial scenes based on MASK R-CNN, applied in the offline training stage, for implementing the method for detecting weak edge defects in industrial scenes based on MASK R-CNN applied in the offline training stage as described in any one of claims 1-2, characterized in that, include: The modeling module is used to optimize the preset MASK R-CNN network structure based on the preset EffcientNet backbone network, feature map pyramid network and target activation function to generate the optimized MASK R-CNN model. The scoring module is used to construct the industrial scene defect training dataset of the MASK R-CNN optimization model, input the industrial scene defect training dataset into the MASK R-CNN optimization model, and generate the mask score corresponding to the industrial defect training dataset according to the target candidate box scale selection strategy and target mask prediction branch network corresponding to the MASK R-CNN optimization model. The training module is used to establish the IoU-like loss function of the MASK R-CNN optimization model, and to train the MASK R-CNN optimization model through the IoU-like loss function and the mask score to generate an industrial scene defect detection model, so as to perform industrial scene weak edge defect detection operation using the industrial scene defect detection model; The scoring module further includes: The second acquisition unit is used to acquire the region of interest feature map and mask prediction feature map corresponding to the industrial scene defect training dataset; The downsampling unit is used to perform a downsampling operation on the mask prediction feature map to generate a downsampled mask feature map corresponding to the mask prediction feature map. The splicing unit is used to splice the feature map of the region of interest and the downsampled mask feature map to obtain a feature splicing map, and input the feature splicing map into the target mask prediction branch network to output the mask score corresponding to the industrial defect training dataset; The mathematical expression for the IoU-like loss function is: in, Indicates the first Candidate box mask; Indicates the pixel coordinate position; This represents the probability value predicted by the mask. This is the actual mask label.

5. The apparatus according to claim 4, characterized in that, The scoring module includes: The preprocessing unit is used to preprocess the industrial scenario defect training dataset to obtain a standard training dataset. The first acquisition unit is used to acquire the label data in the standard training dataset and determine the minimum column index and the maximum column index of the target gray value of the label data, so as to obtain the width and height of the defect anchor box according to the minimum column index and the maximum column index; The computational unit is used to calculate, using a preset clustering algorithm and IoU loss function, the region proposal network corresponding to the standard training dataset with the smallest distance to non-centroid detection boxes. K One centroid detection frame, among which... K It is a positive integer; The determining unit is used to determine the width and height of the defective anchor frame, and the... K Using a centroid detection box and a preset distance metric strategy, the target candidate box scale of the industrial scene defect training dataset is determined.

6. A weak edge defect detection device for industrial scenes based on MASK R-CNN, applied in the online detection stage, for implementing the weak edge defect detection method for industrial scenes based on MASK R-CNN applied in the online detection stage as described in claim 3, characterized in that, include: The acquisition module is used to acquire image data of the target to be detected in the target industrial scene in real time; The detection module is used to input the image data of the target to be detected into a pre-trained industrial scene defect detection model to output the weak edge defect detection result of the industrial scene. The industrial scene defect detection model is obtained by using a preset industrial scene defect training dataset and combining a target candidate box scale selection strategy, a target mask prediction branch network and an IoU-like loss function to train a preset MASK R-CNN optimized model constructed from the EffcientNet backbone network, feature map pyramid network and target activation function.

7. An electronic device, characterized in that, include: The memory, the processor, and the computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the MASK R-CNN-based weak edge defect detection method for industrial scenes as described in any one of claims 1-2 or 3.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that, The program is executed by the processor to implement the MASK R-CNN-based weak edge defect detection method for industrial scenes as described in any one of claims 1-2 or 3.