Defect detection optimization methods, devices, computer equipment and storage media
By annotating and performing morphological dilation on sample images, combined with training of multi-layer convolutional neural networks, the target mask image is optimized, solving the problems of blurred defect boundaries and excessively large areas in existing semantic segmentation methods, and achieving accurate quantification of defect detection.
Patent Information
- Application Number
- CN202511374441.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-25
- Publication Date
- 2025-12-02
- Estimated Expiration
- 2045-09-25
AI Technical Summary
Existing deep learning-based semantic segmentation methods for industrial surface defect detection suffer from problems such as insufficient segmentation precision, blurred defect boundaries, and defect areas that are larger than the actual contours.
By annotating the defect contours of the sample images and performing mask transformation, an initial mask image is obtained. Then, based on morphological operations, the initial mask image is dilated to simulate the situation where the target semantic segmentation model predicts a larger area. The model is trained by combining multiple sample images and the corresponding initial mask image and dilated image. Feature extraction and binary classification are performed using a multi-layer convolutional neural network. Finally, the target mask image is optimized by tensor dot product processing.
Without changing the target semantic segmentation model, the segmentation results are improved, the over-segmented defect boundaries are shrunk to the real physical boundaries, the defect area is accurately quantified, and the optimized defect feature area is not greater than the area predicted by the original model.
Smart Images

Figure CN120877287B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of visual inspection technology, and in particular to an optimized method, apparatus, computer equipment, and storage medium for defect detection. Background Technology
[0002] In industrial surface defect detection applications, semantic segmentation methods based on deep learning are quite common. However, due to the limited receptive field of convolutional blocks and the downsampling-upsampling structural characteristics, the prediction confidence of defect edge pixels exhibits a gradual distribution, forcing the model to incorrectly include low-confidence transition areas into the defect region. Moreover, mainstream loss functions (such as Dice Loss and BCE) optimize by maximizing region overlap, causing the model to tend to predict larger areas to avoid penalties for missed detections. Therefore, existing semantic segmentation methods based on deep learning suffer from problems such as insufficiently refined segmentation results, blurred defect boundaries, and areas larger than the actual contours. Summary of the Invention
[0003] This invention aims to at least solve one of the technical problems existing in the prior art. To this end, this invention proposes a defect detection optimization method, apparatus, computer equipment, and storage medium, which can improve the segmentation results of existing semantic segmentation models and ensure that the area of the optimized defect features is not greater than the area of the defect features predicted by the existing semantic segmentation models.
[0004] In a first aspect, embodiments of the present invention provide a defect detection optimization method, comprising:
[0005] Acquire a target image, a target mask image, and a training set of defect images containing multiple sample images, wherein the target mask image is an image obtained by defect segmentation of the target image based on a target semantic segmentation model;
[0006] The defect contours of the multiple sample images are labeled and masked to obtain the corresponding initial mask images;
[0007] The initial mask image is dilated based on morphological operations to obtain a dilated mask image.
[0008] Based on the multiple sample images and the corresponding initial mask image and dilated mask image, a segmentation optimization model is trained to obtain the model.
[0009] The target mask image is optimized based on the segmentation optimization model and the target image, and the optimized mask image is then multiplied by tensor multiplication with the target mask image to obtain the optimized mask image.
[0010] According to some embodiments of the present invention, the step of training a segmentation optimization model based on the multiple sample images and the corresponding initial mask image and the dilated mask image to obtain a segmentation optimization model includes:
[0011] Based on the first convolutional block, feature extraction is performed on each of the sample images to obtain a first feature map;
[0012] Based on the second convolutional block, feature extraction is performed on the first feature map and the dilated mask image to obtain the second feature map;
[0013] Based on the third convolutional block, feature extraction is performed on the second feature map and the initial mask image to obtain the third feature map;
[0014] The third feature map is binary-classified based on the fourth convolutional block to complete model training and obtain a segmentation optimization model.
[0015] According to some embodiments of the present invention, the first convolutional block comprises a convolutional neural network layer a, where a ∈ [4, 8]. The step of extracting features from each sample image based on the first convolutional block to obtain a first feature map includes:
[0016] For each sample image, features are extracted using a layer of convolutional neural network to obtain the first feature map.
[0017] According to some embodiments of the present invention, the second convolutional block comprises b layers of convolutional neural networks, b ∈ [6, 10]. The step of extracting features from the first feature map and the dilated mask image based on the second convolutional block to obtain the second feature map includes:
[0018] After dilating the dilated mask image based on morphological operations, a tensor dot product is performed with the first feature map, and features are extracted through a b-layer convolutional neural network to obtain the second feature map.
[0019] According to some embodiments of the present invention, the third convolutional block comprises a c-layer convolutional neural network, c ∈ [4, 8], and the feature extraction based on the third convolutional block on the second feature map and the initial mask image to obtain the third feature map includes:
[0020] The initial mask image and the second feature map are concatenated and then processed by a c-layer convolutional neural network to extract features, resulting in the third feature map.
[0021] According to some embodiments of the present invention, the step of annotating the defect contours of the plurality of sample images and performing mask transformation to obtain the corresponding initial mask image includes:
[0022] The defect contours of the multiple sample images are labeled, and the labeled sample images are binarized to obtain the corresponding initial mask images, wherein the value 1 in the initial mask image is used to represent defect features, and the value 0 is used to represent background features.
[0023] According to some embodiments of the present invention, the dilation process of the initial mask image based on morphological operations to obtain a dilated mask image includes:
[0024] Based on morphological operations, the defect features in the initial mask image are dilated by k pixels to obtain an inflated mask image, k∈(0,4).
[0025] Secondly, embodiments of the present invention provide a defect detection optimization device, comprising:
[0026] The image acquisition module is used to acquire the target image, the target mask image, and a defect image training set containing multiple sample images. The target mask image is an image obtained by defect segmentation of the target image based on the target semantic segmentation model.
[0027] The annotation and conversion module is used to annotate the defect contours of the multiple sample images and perform mask conversion to obtain the corresponding initial mask image;
[0028] The mask dilation module is used to dilate the initial mask image based on morphological operations to obtain an inflated mask image.
[0029] The model training module is used to train the model based on the multiple sample images and the corresponding initial mask image and the dilated mask image to obtain a segmentation optimization model.
[0030] The image optimization module is used to optimize the target mask image based on the segmentation optimization model and the target image, and to perform tensor dot product processing on the optimized mask image and the target mask image to obtain the optimized mask image.
[0031] Thirdly, embodiments of the present invention provide a computer device, including a processor and a memory, wherein the memory stores a computer program, and the processor runs the computer program to implement the above-mentioned defect detection optimization method.
[0032] Fourthly, embodiments of the present invention provide a storage medium storing a computer program that, when run, implements the defect detection optimization method described above.
[0033] The embodiments of the present invention have at least the following beneficial effects:
[0034] This invention provides an initial mask image by annotating the defect contours of sample images and performing mask transformation. Then, based on morphological operations, the initial mask image is dilated to simulate a larger area predicted by the target semantic segmentation model. Furthermore, the model is trained using multiple sample images and their corresponding initial and dilated mask images. The target mask image is then optimized based on the trained segmentation optimization model and the target image. Without modifying the target semantic segmentation model, the over-segmented defect boundaries in the target mask image are shrunk to their true physical boundaries, improving the segmentation results and facilitating accurate quantification of the defect area. Performing tensor dot product processing between the first-optimized mask image and the target mask image ensures that the area of the defect features in the second-optimized mask image is not greater than the area of the defect features predicted by the target semantic segmentation model.
[0035] Additional aspects and advantages of the invention 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 the invention. Attached Figure Description
[0036] The above and / or additional aspects and advantages of the present invention will become apparent and readily understood from the description of the embodiments taken in conjunction with the following drawings, in which:
[0037] Figure 1 This is a flowchart illustrating the steps of the defect detection optimization method according to an embodiment of the present invention.
[0038] Figure 2 This is a schematic diagram of the defect detection optimization device according to an embodiment of the present invention;
[0039] Figure 3 This is a schematic block diagram of a computer device according to an embodiment of the present invention. Detailed Implementation
[0040] Embodiments of the present invention 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 are only used to explain the present invention, and should not be construed as limiting the present invention.
[0041] In the description of this invention, "several" means one or more, "multiple" means two or more, "greater than," "less than," "exceeding," etc. are understood to exclude the stated number, and "above," "below," "within," etc. are understood to include the stated number. If "first," "second," etc. are used in the description, they are only for the purpose of distinguishing technical features and should not be construed as indicating or implying relative importance or implicitly indicating the number of indicated technical features or the order of the indicated technical features.
[0042] Please refer to Figure 1 This embodiment discloses a defect detection optimization method, including steps S100 to S500. It should be noted that the numbering of the steps in this embodiment is only for ease of review and understanding, and not to limit the execution order of the steps. The details of each step are described below:
[0043] S100. Obtain the target image, the target mask image, and a training set of defect images containing multiple sample images. The target mask image is an image obtained by performing defect segmentation on the target image based on the target semantic segmentation model.
[0044] For example, the target image is an image of the product to be inspected, captured during industrial surface defect detection. This image contains defect features. To identify these defect features, related technologies use a target semantic segmentation model to segment the target image, resulting in a target mask image. This mask image is a binary image where a value of 1 represents a defect feature and a value of 0 represents background features. The target semantic segmentation model can be any existing semantic segmentation model. As mentioned above, existing models suffer from limitations such as insufficient segmentation precision, blurred defect boundaries, and areas larger than the actual contours. Therefore, optimization of the target mask image is necessary.
[0045] The defect image training set can utilize the training set of the target semantic segmentation model, eliminating the need for additional defect image dataset collection and reducing training costs. Furthermore, collecting defect images from various industrial scenarios as the training set enriches the morphological samples of defects, improves the model's generalization performance and robustness, and allows for rapid adaptation to other scenarios, reducing the cost of repeated training for single scenarios. Let the sample images be denoted as I, and the training set as R, then I ∈ R. H×W Where H and W represent the height and width of the sample image, respectively. The target image is denoted as I. raw By segmenting the target image using a target semantic segmentation model, a target mask image M can be obtained. seg The relationship between the target image and the target mask image is: M seg =Seg(I raw ), where Seg(•) refers to any semantic segmentation model based on deep learning.
[0046] S200. Mark the defect contours of multiple sample images and perform mask transformation to obtain the corresponding initial mask image;
[0047] For example, an image defect annotation tool is used to accurately annotate the actual defect contours of each sample image in the defect image training set, and the annotated sample images are converted into mask images, i.e., mask conversion is performed to obtain the corresponding initial mask image. Accurate annotation of the defect contours of the sample images can provide prior knowledge for defect recognition. Step S200 includes:
[0048] The defect contours of multiple sample images are labeled, and the labeled sample images are binarized to obtain the corresponding initial mask images. In the initial mask images, the value 1 is used to represent defect features, and the value 0 is used to represent background features.
[0049] By converting the labeled sample image into a mask image through binarization, the contour features of the defect can be preserved while reducing the interference of other background features on defect recognition.
[0050] S300. Dilate the initial mask image based on morphological operations to obtain a dilated mask image;
[0051] For example, morphological operations are a widely used technique in image processing and machine vision. Dilation is a fundamental morphological operation, which expands the boundary of a specified object in an image outward to fill holes, connect neighboring elements, or increase the size of the target. Existing models have the problem of incorrectly including low-confidence transition regions into defect regions, i.e., "enlarging defects." Considering this performance characteristic of existing models, this embodiment performs dilation processing on the defect features in the initial mask image to give the defect features a wider defect contour, simulating the phenomenon of existing models enlarging defects. This method is simple and efficient, and does not require additional collection of such poorly segmented images as training datasets. Step S300 includes:
[0052] Based on morphological operations, the defect features in the initial mask image are dilated by k pixels to obtain an inflated mask image, k∈(0,4).
[0053] For example, let the initial mask image be denoted as M. init Since the initial mask image is a binary image, it has the following relationship: M init ∈{0,1} H×W H and W represent the height and width of the image, respectively. When performing dilation, the formula can be used: M dilate =Dil(M initThe function is to process the pixel size by using Dil(), where Dil() represents the dilation operation and only applies to pixels with a value of 1. k represents the size of the pixel to be dilated, and k ∈ (0, 4), meaning that the value of k is 1, 2, or 3.
[0054] S400. Based on multiple sample images and the corresponding initial mask image and dilated mask image, the model is trained to obtain the segmentation optimization model;
[0055] For example, in this embodiment, the sample image, the initial mask image, and the dilated mask image are used to form the training set for the segmentation optimization model for model training. The model can learn from the differences between different images, enabling it to better identify the true contours of defect features. Step S400 includes:
[0056] S410. Based on the first convolutional block, feature extraction is performed on each sample image to obtain the first feature map;
[0057] S420. Based on the second convolutional block, feature extraction is performed on the first feature map and the dilated mask image to obtain the second feature map;
[0058] S430. Based on the third convolutional block, feature extraction is performed on the second feature map and the initial mask image to obtain the third feature map;
[0059] S440. Based on the fourth convolutional block, perform binary classification on the third feature map to complete the model training and obtain the segmentation optimization model.
[0060] For example, the first convolutional block can extract features from each sample image to learn basic features in the sample image, such as edges and textures. The first convolutional block contains a layers of convolutional neural networks, where a ∈ [4, 8]. Therefore, step S410 includes: extracting features from each sample image through the a-layer convolutional neural network to obtain a first feature map. The first feature map is denoted as I. general , then I general =ConvBlock a (I), where ConvBlock a The first convolutional block is a feature extractor with an 'a'-layer convolutional neural network structure, where I is the sample image. In a specific application example, 'a' is set to 4, meaning that features are extracted from each sample image through a 4-layer convolutional neural network to obtain the first feature map.
[0061] Feature extraction is performed on the first feature map and the dilated mask image based on the second convolutional block. The dilated mask image allows the model to focus more on the defect feature itself and its surrounding pixels, rather than the entire image, thus improving the model's learning performance on various defect features. The second convolutional block contains b layers of convolutional neural networks, where b ∈ [6, 10]. Therefore, step S420 includes: dilating the dilated mask image based on morphological operations, performing a tensor dot product with the first feature map, and then extracting features through the b layers of convolutional neural networks to obtain the second feature map. Dilating the dilated mask image further expands the pixel range of the defect feature because the dilated mask image is a binary image, and it remains a binary image after dilation. Performing a tensor dot product with the first feature map yields the second feature map. The dilated mask image can be used to mask non-defect locations in the second feature map, i.e., set the values to 0. This allows the model to focus more on the defect feature itself and its surrounding pixels. The relationship of the second feature map can be expressed as: I local Represented as the second feature map, ConvBloack b The second convolutional block is used to represent a feature extractor with a b-layer convolutional neural network structure, where n represents the pixel size that needs to be dilated in the current step. This represents the tensor dot product operation. In a specific application example, the value of b is 8, meaning that after dilating the dilated mask image based on morphological operations, a tensor dot product is performed with the first feature map, and then the second feature map is obtained by extracting features through an 8-layer convolutional neural network.
[0062] The third convolutional block contains c layers of convolutional neural networks, where c ∈ [4, 8]. Therefore, step S430 includes: concatenating the initial mask image and the second feature map, and then extracting features through the c-layer convolutional neural network to obtain the third feature map. The relationship of the third feature map is: I edge =ConvBlock c (Concat(M) init I local ), where I edge Represented as the third feature map, ConvBlock c Represented as the third convolutional block, it is a feature extractor with a c-layer convolutional neural network structure, used to learn fused features, helping the model better learn and find defect boundary contours. Concat() is a tensor concatenation operation. In a specific application example, c is set to 4, meaning the initial mask image and the second feature map are concatenated and then processed through a 4-layer convolutional neural network to extract features, resulting in the third feature map. Concatenating and fusing the initial mask image and the second feature map before continuing feature extraction allows the model to have a better learning effect on defect contours and boundary features, thus predicting the true boundary more accurately.
[0063] The fourth convolutional block is a binary classification convolutional neural network. Based on this fourth convolutional block, the third feature map is classified binaryly, enabling accurate differentiation of defect features in the third feature map and yielding an optimized mask image. The optimized mask image is expressed as: M refine =Conv2(I edge M refine M is represented as the optimized mask image output by the segmentation optimization model. refine ∈{0,1} H×W The value 0 represents background features, the value 1 represents defect features, and Conv2 (•) represents the fourth convolutional block.
[0064] By using multiple sample images from the defect image training set, along with the corresponding initial mask image and dilation mask image, and after a preset number of training rounds, a trained segmentation optimization model can be obtained.
[0065] S500: Optimize the target mask image based on the segmentation optimization model and the target image, and perform tensor dot product processing on the optimized mask image and the target mask image to obtain the optimized mask image.
[0066] For example, the target image I raw and target mask image M seg Inputting the trained segmentation optimization model into forward inference yields a refined, first-order optimized mask image, denoted as M. refine To avoid the situation where the pixel size of the defect contour in the optimized mask image is larger than that in the target mask image (i.e., the defect boundary is more blurred), a tensor dot product is performed between the first-optimized mask image and the target mask image to obtain a second-optimized mask image, denoted as M. final In this process, both the primary optimized mask image and the target mask image are binary images. They undergo tensor multiplication (element-wise multiplication), retaining only pixels with a value of 1 in both images. This ensures that the pixel size of the defect features in the secondary optimized mask image is no larger than that in the target mask image, guaranteeing that the refined result will not be worse than the prediction performance of the target semantic segmentation model. The relationship between the secondary optimized mask images is as follows: .
[0067] This embodiment obtains an initial mask image by annotating the defect contours of the sample images and performing mask transformation. Then, it performs dilation processing on the initial mask image based on morphological operations, which can simulate the situation where the target semantic segmentation model predicts a larger area. The model is trained based on multiple sample images and the corresponding initial mask image and dilated image. Then, the target mask image is optimized based on the trained segmentation optimization model and the target image. Without modifying the target semantic segmentation model, the over-segmented defect boundaries in the target mask image are shrunk to the real physical boundaries, improving the segmentation results and thus facilitating the accurate quantification of the defect area. Performing tensor dot product processing on the first-optimized mask image and the target mask image can ensure that the area of the defect features in the second-optimized mask image is not greater than the area of the defect features predicted by the target semantic segmentation model.
[0068] Please refer to Figure 2 This embodiment also provides a defect detection optimization device, including:
[0069] The image acquisition module 110 is used to acquire the target image, the target mask image, and a defect image training set containing multiple sample images. The target mask image is an image obtained by defect segmentation of the target image based on the target semantic segmentation model.
[0070] The annotation and conversion module 120 is used to annotate the defect contours of multiple sample images and perform mask conversion to obtain the corresponding initial mask image;
[0071] The mask dilation module 130 is used to dilate the initial mask image based on morphological operations to obtain an inflated mask image.
[0072] The model training module 140 is used to train the model based on multiple sample images and the corresponding initial mask image and dilated mask image to obtain a segmentation optimization model.
[0073] The image optimization module 150 is used to optimize the target mask image based on the segmentation optimization model and the target image, and to perform tensor dot product processing on the optimized mask image and the target mask image to obtain the optimized mask image.
[0074] The inventive concept of this defect detection optimization device embodiment is the same as that of the defect detection optimization method embodiment described above. Content not covered in this defect detection optimization device embodiment can be referred to in the aforementioned defect detection optimization method embodiment, and will not be repeated here. This embodiment obtains an initial mask image by annotating the defect contours of sample images and performing mask transformation. Then, based on morphological operations, the initial mask image is dilated, which can simulate the situation where the target semantic segmentation model predicts a larger area. Furthermore, the model is trained based on multiple sample images and their corresponding initial mask images and dilated images. Then, based on the trained segmentation optimization model and the target image, the target mask image is optimized. Without modifying the target semantic segmentation model, the over-segmented defect boundaries in the target mask image are shrunk to the true physical boundaries, improving the segmentation results and facilitating accurate quantification of the defect area. Performing tensor dot product processing between the first-optimized mask image and the target mask image ensures that the area of the defect features in the second-optimized mask image is not greater than the area of the defect features predicted by the target semantic segmentation model.
[0075] Please refer to Figure 3 This embodiment also provides a computer device, including a processor 210 and a memory 220. The memory 220 stores a computer program, and the processor 210 runs the computer program to implement the above-mentioned defect detection optimization method. The specific content of the defect detection optimization method is as described above and will not be repeated here. In this embodiment, by annotating the defect contours of the sample images and performing mask transformation, an initial mask image is obtained. Then, based on morphological operations, the initial mask image is dilated, which can simulate the situation where the target semantic segmentation model predicts a larger area. The model is trained based on multiple sample images and the corresponding initial mask image and dilated image. Then, based on the trained segmentation optimization model and the target image, the target mask image is optimized. Without modifying the target semantic segmentation model, the over-segmented defect boundaries in the target mask image are shrunk to the real physical boundaries, improving the segmentation results. This is conducive to the accurate quantification of the defect area. By performing tensor dot product processing on the first-optimized mask image and the target mask image, it can be ensured that the area of the defect features in the second-optimized mask image is not greater than the area of the defect features predicted by the target semantic segmentation model.
[0076] This embodiment also provides a storage medium storing a computer program. When the computer program is run, it implements the defect detection optimization method described above. The specific content of the defect detection optimization method is as described above and will not be repeated here. This embodiment obtains an initial mask image by annotating the defect contours of sample images and performing mask transformation. Then, based on morphological operations, the initial mask image is dilated to simulate the situation where the target semantic segmentation model predicts a larger area. Furthermore, the model is trained based on multiple sample images and their corresponding initial mask images and dilated images. Then, based on the trained segmentation optimization model and the target image, the target mask image is optimized. Without modifying the target semantic segmentation model, the over-segmented defect boundaries in the target mask image are shrunk to the true physical boundaries, improving the segmentation results and facilitating accurate quantification of the defect area. Performing tensor dot product processing between the first-optimized mask image and the target mask image ensures that the area of the defect features in the second-optimized mask image is not greater than the area of the defect features predicted by the target semantic segmentation model.
[0077] The embodiments of the present invention have been described in detail above with reference to the accompanying drawings. However, the present invention is not limited to the above embodiments. Within the scope of knowledge possessed by those skilled in the art, various changes can be made without departing from the spirit of the present invention.
Claims
1. A defect detection optimization method, characterized in that, include: Acquire a target image, a target mask image, and a training set of defect images containing multiple sample images, wherein the target mask image is an image obtained by defect segmentation of the target image based on a target semantic segmentation model; The defect contours of the multiple sample images are labeled and masked to obtain the corresponding initial mask images; The initial mask image is dilated based on morphological operations to obtain a dilated mask image. Based on the multiple sample images and the corresponding initial mask image and dilated mask image, a segmentation optimization model is trained to obtain the model. The target image and the target mask image are input into the trained segmentation optimization model for forward inference, and the optimized mask image is multiplied by tensor with the target mask image to obtain the optimized mask image. The step of training a segmentation optimization model based on the multiple sample images and the corresponding initial mask image and dilated mask image includes: Based on the first convolutional block, feature extraction is performed on each of the sample images to obtain a first feature map; Based on the second convolutional block, feature extraction is performed on the first feature map and the dilated mask image to obtain the second feature map; Based on the third convolutional block, feature extraction is performed on the second feature map and the initial mask image to obtain the third feature map; The third feature map is subjected to binary classification based on the fourth convolutional block to complete model training and obtain a segmentation optimization model.
2. The defect detection optimization method according to claim 1, characterized in that, The first convolutional block contains a convolutional neural network layers, where a ∈ [4, 8]. The step of extracting features from each sample image based on the first convolutional block to obtain a first feature map includes: For each of the sample images, features are extracted using a layer of convolutional neural network to obtain the first feature map.
3. The defect detection optimization method according to claim 1, characterized in that, The second convolutional block contains b layers of convolutional neural networks, b∈[6,10]. The step of extracting features from the first feature map and the dilated mask image based on the second convolutional block to obtain the second feature map includes: After dilating the dilated mask image based on morphological operations, a tensor dot product is performed with the first feature map, and features are extracted through a b-layer convolutional neural network to obtain the second feature map.
4. The defect detection optimization method according to claim 2 or 3, characterized in that, The third convolutional block contains c layers of convolutional neural networks, where c ∈ [4, 8]. The process of extracting features from the second feature map and the initial mask image based on the third convolutional block to obtain the third feature map includes: The initial mask image and the second feature map are concatenated and then processed by a c-layer convolutional neural network to extract features, resulting in the third feature map.
5. The defect detection optimization method according to claim 1, characterized in that, The step of annotating the defect contours of the multiple sample images and performing mask transformation to obtain the corresponding initial mask image includes: The defect contours of the multiple sample images are labeled, and the labeled sample images are binarized to obtain the corresponding initial mask images, wherein the value 1 in the initial mask image is used to represent defect features, and the value 0 is used to represent background features.
6. The defect detection optimization method according to claim 5, characterized in that, The process of dilating the initial mask image based on morphological operations to obtain a dilated mask image includes: Based on morphological operations, the defect features in the initial mask image are dilated by k pixels to obtain an inflated mask image, k∈(0,4).
7. A defect detection optimization device, characterized in that, include: The image acquisition module is used to acquire the target image, the target mask image, and a defect image training set containing multiple sample images. The target mask image is an image obtained by defect segmentation of the target image based on the target semantic segmentation model. The annotation and conversion module is used to annotate the defect contours of the multiple sample images and perform mask conversion to obtain the corresponding initial mask image; The mask dilation module is used to dilate the initial mask image based on morphological operations to obtain an inflated mask image. The model training module is used to train the model based on the multiple sample images and the corresponding initial mask image and the dilated mask image to obtain a segmentation optimization model. The image optimization module is used to input the target image and the target mask image into the trained segmentation optimization model for forward inference, and to perform tensor dot multiplication between the optimized first-order mask image and the target mask image to obtain the optimized second-order mask image. The step of training a segmentation optimization model based on the multiple sample images and the corresponding initial mask image and dilated mask image includes: Based on the first convolutional block, feature extraction is performed on each of the sample images to obtain a first feature map; Based on the second convolutional block, feature extraction is performed on the first feature map and the dilated mask image to obtain the second feature map; Based on the third convolutional block, feature extraction is performed on the second feature map and the initial mask image to obtain the third feature map; The third feature map is subjected to binary classification based on the fourth convolutional block to complete model training and obtain a segmentation optimization model.
8. A computer device, comprising a processor and a memory, wherein the memory stores a computer program, characterized in that, When the processor runs the computer program, it is used to implement the defect detection optimization method as described in any one of claims 1 to 6.
9. A storage medium storing a computer program, characterized in that, When the computer program is run, it implements the defect detection optimization method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Image processing method and device and computer readable storage medium
CN111783779A
Surface defect detection method, device and equipment of photovoltaic module and storage medium
CN118014971A