Image edge detection method, device, equipment and storage medium

Through the backbone network, edge skeleton extraction module and skeleton guidance attention mechanism training edge detection model, combined with dynamic threshold processing, the accuracy problem of edge detection in complex scenarios is solved, and efficient edge detection results are achieved.

CN120235900BActive Publication Date: 2025-08-19GOERTEK INC
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510714757.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-30
Publication Date
2025-08-19
Estimated Expiration
2045-05-30

AI Technical Summary

Technical Problem

When the prior art performs edge detection in complex scenarios, the accuracy is low, it is susceptible to noise, produces pseudo-edges or broken edges, and it relies on artificial parameter adjustment to poor generalization.

Method used

The target edge detection model is adopted based on the backbone network, edge skeleton extraction module and skeleton guidance attention mechanism training. Features are extracted through the backbone network, the edge skeleton extraction module suppresses noise and strengthens edge continuity. The skeleton guidance attention mechanism dynamically adjusts the channel and spatial weights, and combines dynamic thresholds for binary processing.

Benefits of technology

It improves the accuracy of edge detection and the ability to adapt to complex scenarios, reduces noise sensitivity and computational redundancy, and is suitable for a variety of complex quality inspection scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120235900B_ABST
    Figure CN120235900B_ABST
Patent Text Reader

Abstract

The present application discloses an image edge detection method, apparatus, device and storage medium, which relates to the field of computer vision technology, including: predicting an image to be detected based on a target edge detection model; binarizing the current edge prediction probability map according to the target dynamic threshold to obtain an edge detection result corresponding to the image to be detected. Through the above method, after obtaining the image to be detected in a target complex quality inspection scene, the image to be detected is input into the target edge detection model, features are extracted through the backbone network, noise is suppressed and edge continuity is enhanced through the edge skeleton extraction module, and the channel and spatial weights are dynamically adjusted through the skeleton-guided attention mechanism, so that the fusion process focuses on the skeleton edge area while taking into account the detailed edges of the background, and then the edge detection result is obtained through binarization processing, thereby effectively improving the accuracy of edge detection and being applicable to a variety of complex quality inspection scenes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer vision technology, and in particular to image edge detection methods, devices, equipment, and storage media. Background Art

[0002] Edge detection is a common and fundamental task in computer vision. Its goal is to accurately extract edge and contour information from images to support practical applications, such as autonomous driving environmental perception and industrial defect detection. However, in complex scenes, edge detection is greatly hindered by noise and equipment limitations. Currently, common methods for edge detection include the Canny algorithm and the Sobel operator, which rely primarily on manually designed features. This makes these methods limited in complex scenes, such as sensitivity to noise and the susceptibility to false or broken edges. Furthermore, their reliance on manual parameter tuning results in poor generalization. Consequently, these methods have low edge detection accuracy.

[0003] The above content is only used to assist in understanding the technical solution of this application and does not constitute an admission that the above content is prior art. Summary of the Invention

[0004] The main purpose of this application is to provide an image edge detection method, device, equipment and storage medium, aiming to solve the technical problem of low accuracy of edge detection in the existing technology.

[0005] To achieve the above objectives, the present application proposes an image edge detection method, which includes:

[0006] Acquire the target image to be inspected in complex quality inspection scenarios;

[0007] Predicting the image to be detected based on a target edge detection model to obtain a current edge prediction probability map; wherein the target edge detection model is trained based on a backbone network, an edge skeleton extraction module, and a skeleton-guided attention mechanism;

[0008] The current edge prediction probability map is binarized according to a target dynamic threshold value to obtain an edge detection result corresponding to the image to be detected.

[0009] In one embodiment, before the step of predicting the image to be detected based on the target edge detection model to obtain the current edge prediction probability map, the method further includes:

[0010] Obtain the initial image sample set for model training and model input parameter requirements;

[0011] Dividing the initial image sample set into data according to the first ratio to obtain a current training sample set;

[0012] Performing data enhancement on the current training sample set, and converting the format of the enhanced training sample set according to the model input parameter requirements to obtain a target training sample set;

[0013] The target edge detection model is trained according to the target training sample set, the backbone network, the edge skeleton extraction module and the skeleton-guided attention mechanism.

[0014] In one embodiment, the step of performing data enhancement on the current training sample set and converting the format of the enhanced training sample set according to the model input parameter requirements to obtain the target training sample set includes:

[0015] Randomly scaling the current training sample set, and flipping the scaled training sample set;

[0016] Perform color jitter on the flipped training sample set;

[0017] Normalizing the jittered training sample set according to the model input parameter requirements;

[0018] The processed training sample set is format-converted according to the model input parameter requirements to obtain a target training sample set.

[0019] In one embodiment, the step of training the target edge detection model according to the target training sample set, the backbone network, the edge skeleton extraction module, and the skeleton-guided attention mechanism includes:

[0020] Performing feature extraction on each training image in the target training sample set based on the backbone network, and extracting shallow image features from the image feature set;

[0021] Extracting skeleton information of the shallow image features based on the edge skeleton extraction module, and generating a sparse attention mask according to the extracted current skeleton information;

[0022] generating a target feature skeleton graph according to the sparse attention mask, the target learning weight, and the target learning bias;

[0023] An object edge detection model is trained based on the object feature skeleton map and the skeleton-guided attention mechanism.

[0024] In one embodiment, the skeleton-guided attention mechanism includes a skeleton-guided channel attention mechanism and a skeleton-guided spatial attention mechanism;

[0025] The step of training the target edge detection model according to the target feature skeleton graph and the skeleton-guided attention mechanism comprises:

[0026] Mapping the target feature skeleton graph to a feature space;

[0027] In the feature space, channel attention weighting is performed on each layer feature through the bottom-up path and the skeleton-guided channel attention mechanism;

[0028] In the feature space, spatial attention weighting is performed on each layer of features through a top-down path and the skeleton-guided spatial attention mechanism;

[0029] In the feature space, performing multi-scale downsampling on the target feature skeleton graph;

[0030] Match the downsampled skeleton features with the weighted features of each layer to obtain the target fusion feature map;

[0031] The target edge detection model is trained based on the target fusion feature map and the preset model training hyperparameters.

[0032] In one embodiment, the step of training the target edge detection model according to the target fusion feature map and the preset model training hyperparameters includes:

[0033] Performing spatial convolution on the target fusion feature map according to depth-wise separable convolution;

[0034] The target fusion feature map after convolution is enlarged through the target interpolation algorithm;

[0035] Train the current edge detection model based on the amplified target fusion feature map and the preset model training hyperparameters;

[0036] Determine the target joint loss function based on the cross loss function and the Dice loss function;

[0037] Calculating a loss value between a predicted value and a true value of the current edge detection model according to the target joint loss function;

[0038] The current edge detection model is verified and trained according to the current verification sample set until the loss value converges to a preset value, and the target edge detection model is determined.

[0039] In one embodiment, after the step of performing verification training on the current edge detection model according to the current verification sample set until the loss value converges to a preset value, the method further includes:

[0040] Dividing the initial image sample set according to the second ratio to obtain a current test sample set;

[0041] Testing the edge detection model after verification training according to the current test sample set;

[0042] Extract the current values of multi-dimensional test evaluation indicators from the model test results;

[0043] When the current values all meet the preset requirements, the target edge detection model is determined.

[0044] In addition, to achieve the above-mentioned purpose, the present application also proposes an image edge detection device, which includes:

[0045] The acquisition module is used to obtain the image to be inspected in a complex quality inspection scenario;

[0046] A prediction module, configured to predict the image to be detected based on a target edge detection model to obtain a current edge prediction probability map; wherein the target edge detection model is trained based on a backbone network, an edge skeleton extraction module, and a skeleton-guided attention mechanism;

[0047] The processing module is used to perform binarization processing on the current edge prediction probability map according to the target dynamic threshold value to obtain an edge detection result corresponding to the image to be detected.

[0048] In addition, to achieve the above-mentioned purpose, the present application also proposes an image edge detection device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the image edge detection method described above.

[0049] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium and stores a computer program. When the computer program is executed by a processor, the steps of the image edge detection method described above are implemented.

[0050] One or more technical solutions proposed in this application have at least the following technical effects: by obtaining an image to be detected in a target complex quality inspection scene; predicting the image to be detected based on a target edge detection model to obtain a current edge prediction probability map; wherein the target edge detection model is trained according to a backbone network, an edge skeleton extraction module, and a skeleton-guided attention mechanism; binarizing the current edge prediction probability map according to a target dynamic threshold to obtain an edge detection result corresponding to the image to be detected. Through the above method, after obtaining an image to be detected in a target complex quality inspection scene, the image to be detected is input into the target edge detection model, features are extracted through the backbone network, noise is suppressed and edge continuity is enhanced through the edge skeleton extraction module, and channel and spatial weights are dynamically adjusted through the skeleton-guided attention mechanism, so that the fusion process focuses on the skeleton edge area while taking into account the detailed edges of the background, and then the edge detection result is obtained through binarization processing, thereby effectively improving the accuracy of edge detection and being applicable to a variety of complex quality inspection scenes. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0052] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0053] Figure 1 A schematic diagram of the process flow provided for the first embodiment of the image edge detection method of the present application;

[0054] Figure 2 A schematic diagram of a process for obtaining a target dynamic threshold value provided in the first embodiment of the image edge detection method of the present application;

[0055] Figure 3 A flowchart of the second embodiment of the image edge detection method of the present application is provided;

[0056] Figure 4 A schematic diagram of feature fusion provided in Example 2 of the image edge detection method of this application;

[0057] Figure 5 This is a schematic diagram of the module structure of the image edge detection device according to an embodiment of the present application;

[0058] Figure 6 Schematic diagram of the device structure of the hardware operating environment involved in the image edge detection method in the embodiment of the present application.

[0059] The purpose, features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0060] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, mobile phone, etc., or an electronic device capable of implementing the above functions, such as an image edge detection device. The following uses an image edge detection device as an example to illustrate this embodiment and the following embodiments.

[0061] Based on this, the embodiment of the present application provides an image edge detection method, referring to Figure 1 , Figure 1 This is a flowchart of the first embodiment of the image edge detection method of the present application.

[0062] In this embodiment, the image edge detection method includes steps S10 to S30:

[0063] Step S10: Acquire an image to be inspected in a complex quality inspection scenario.

[0064] It should be noted that complex target quality inspection scenarios can be scenarios where details cannot be accurately captured, and high-frequency noise in shallow features is still amplified, easily leading to edge breakage or redundancy. In such complex target quality inspection scenarios, conventional edge detection methods are not applicable due to their reliance on manually designed features. The image to be inspected refers to the image of the object for which edge detection is required.

[0065] Step S20, predicting the image to be detected based on the target edge detection model to obtain a current edge prediction probability map; wherein, the target edge detection model is trained according to the backbone network, the edge skeleton extraction module and the skeleton-guided attention mechanism.

[0066] It should be understood that since objects have clear but fine edge structures, they are easily affected by noise interference or device imaging quality. If a conventional network model is used directly for edge detection, problems such as low feature fusion efficiency, noise sensitivity, and computational redundancy will occur, resulting in low edge detection accuracy. To this end, this embodiment proposes a target edge detection model trained by a backbone network, an edge skeleton extraction module, and a skeleton-guided attention mechanism. A lightweight edge skeleton extraction module is used as a structural prior to improve the accuracy of edge detection.

[0067] It should be emphasized that the backbone network is used to extract shallow features of each training image in the target training sample set. The backbone network can be a ResNet50 network. The edge skeleton extraction module includes a multi-scale separable hole convolution layer group, which can extract multi-granularity skeleton information from shallow image features as a structural prior to guide the image injection into the subsequent network, suppress noise and enhance edge continuity. The generated target feature skeleton map is input into the skeleton-guided attention mechanism, which dynamically adjusts the channel and spatial weights to guide the cross-scale feature fusion of the bidirectional feature pyramid, so that the fusion process focuses on the skeleton edge area while taking into account the detailed edges of the background. Through the above-mentioned backbone network, edge skeleton extraction module and skeleton-guided attention mechanism, the target edge detection model can quickly and accurately predict the current edge prediction probability map, adapt to complex environments, and improve scene adaptation capabilities.

[0068] It can be understood that the current edge prediction probability map represents the target edge detection model's prediction of the soft probability of each edge. For example, the probability of predicting object A to be an edge is 60%, the probability of predicting object B to be an edge is 80%, the probability of predicting object C to be an edge is 99%, and so on.

[0069] Step S30 , binarizing the current edge prediction probability map according to a target dynamic threshold value to obtain an edge detection result corresponding to the image to be detected.

[0070] It should be understood that the target dynamic threshold refers to the threshold output by the dynamic threshold edge detection decoder, with reference to Figure 2 , Figure 2 A schematic diagram of the process for obtaining a target dynamic threshold is shown below: After determining the fused features, the fused features are input into the dynamic threshold edge detection decoder. Global average pooling and activation functions in the dynamic threshold edge detection decoder map the combined features to a dynamic threshold. The target dynamic threshold is adaptively generated through global feature statistics, eliminating the need for manual intervention. This effectively improves edge detection efficiency, avoids checkerboard artifacts, and reduces missed detections of weak edges. This target dynamic threshold is then used to convert the current edge prediction probability map into an edge detection result corresponding to the image to be detected using a binarization process, converting the uncertain data output by the model into deterministic data. This edge detection result includes, but is not limited to, fine edge information and overall contours.

[0071] This embodiment obtains an image to be detected in a target complex quality inspection scene; predicts the image to be detected based on a target edge detection model to obtain a current edge prediction probability map; wherein, the target edge detection model is trained according to a backbone network, an edge skeleton extraction module and a skeleton-guided attention mechanism; binarizes the current edge prediction probability map according to a target dynamic threshold to obtain an edge detection result corresponding to the image to be detected. Through the above method, after obtaining the image to be detected in a target complex quality inspection scene, the image to be detected is input into the target edge detection model, features are extracted through the backbone network, noise is suppressed and edge continuity is enhanced through the edge skeleton extraction module, and channel and spatial weights are dynamically adjusted through the skeleton-guided attention mechanism, so that the fusion process focuses on the skeleton edge area while taking into account the detailed edges of the background, and then the edge detection result is obtained through binarization processing, thereby effectively improving the accuracy of edge detection and being applicable to a variety of complex quality inspection scenes.

[0072] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above embodiment 1 can be referred to the above introduction and will not be described in detail later. Figure 3 Before step S10, steps T101 to T104 are also included:

[0073] Step T101: Obtain an initial image sample set for model training and model input parameter requirements.

[0074] It should be noted that the initial image sample set refers to a self-built image sample set used for model training. This initial image sample set contains a large number of training images with ground truth values annotated by multiple users. These ground truth values are processed into binary edge images as training labels, and the images are integrated into a loadable dataset format to facilitate subsequent data augmentation and training. Model input parameter requirements refer to the requirements for inputting the training sample set into the model training object. These model input parameter requirements include but are not limited to size requirements and format requirements.

[0075] Step T102 : dividing the initial image sample set into data according to a first ratio to obtain a current training sample set.

[0076] It can be understood that the current training sample set refers to the sample set required for model training. The current training sample set can be a part of the initial image sample set, that is, the first proportion of the initial image sample set is used as the current training sample set, and the first proportion can be 40%.

[0077] Step T103 , performing data enhancement on the current training sample set, and converting the format of the enhanced training sample set according to the model input parameter requirements to obtain a target training sample set.

[0078] It should be understood that in order to effectively increase the diversity of the current training sample set, after obtaining the current training sample set, data enhancement can be performed on the current training sample set. Such data enhancement operations include but are not limited to scaling, cropping, flipping, and color dithering, etc., to prevent overfitting and improve the robustness of the model, thereby enhancing the model's generalization ability. In order to ensure that the input image sample set meets the requirements of the model and accelerate the convergence process, the enhanced training sample set also needs to be formatted.

[0079] Furthermore, step T103 includes: randomly scaling the current training sample set and flipping the scaled training sample set; performing color jittering on the flipped training sample set; normalizing the jittered training sample set according to the model input parameter requirements; and formatting the processed training sample set according to the model input parameter requirements to obtain the target training sample set.

[0080] It is understandable that after the current training sample set is randomly scaled, a bilinear interpolation algorithm can be used to ensure the smoothness of the current training sample set during the scaling process. The training images in the scaled training sample set are then flipped according to the target flip axis, and the flipped training sample set is color-dithered, thereby effectively improving the diversity of the current training sample set. In addition, the dithered training sample set is normalized, standardized, and format-converted according to the model input parameter requirements. The format conversion result can be a tensor, ensuring that the input image sample set meets the model requirements and accelerating the convergence process.

[0081] Step T104: training a target edge detection model based on the target training sample set, the backbone network, the edge skeleton extraction module, and the skeleton-guided attention mechanism.

[0082] It can be understood that after obtaining the target training sample set, the target training sample set is input into a network composed of a backbone network, an edge skeleton extraction module, and a skeleton-guided attention mechanism to train a target edge detection model, wherein the target edge detection model refers to a model used to infer and output an edge prediction probability map corresponding to the image to be detected.

[0083] Furthermore, step T104 includes: performing feature extraction on each training image in the target training sample set based on the backbone network, and extracting shallow image features from the image feature set; performing skeleton information extraction on the shallow image features based on the edge skeleton extraction module, and generating a sparse attention mask based on the extracted current skeleton information; generating a target feature skeleton map based on the sparse attention mask, target learning weights and target learning bias; and training a target edge detection model based on the target feature skeleton map and the skeleton-guided attention mechanism.

[0084] It should be understood that after obtaining the target training sample set, the backbone network is first used to extract features from each training image in the target training sample set. At this time, the shallow image features are input into the edge skeleton extraction module, where the separable dilated convolution performs skeleton information extraction on the shallow image features. The current skeleton information extracted at this time can be multi-granular skeleton information. Multi-scale dilated convolution gradually expands the receptive field, allowing the convolution to obtain more information without increasing the number of parameters. It replaces the ordinary convolution operation with a deep separable convolution, further reducing the amount of computation, ensuring the lightweight edge skeleton extraction module, and reducing resource consumption.

[0085] It is understandable that, considering the skeleton prior's suppression of the edge information of the non-skeleton background, the main skeleton foreground and background are combined, and the current skeleton information retained by different thresholds is used to generate a sparse attention mask. This achieves the purpose of extracting key features while retaining the non-skeleton edge structure of the background. Then, the target feature skeleton image is generated by applying the sparse attention mask, specifically:

[0086] .

[0087] in, represents the target feature skeleton graph, represents the target learning weight, represents the target learning bias, denotes applying a sparse attention mask, Represents shallow image features.

[0088] Furthermore, the skeleton-guided attention mechanism includes a skeleton-guided channel attention mechanism and a skeleton-guided spatial attention mechanism; the step of training the target edge detection model based on the target feature skeleton map and the skeleton-guided attention mechanism includes: mapping the target feature skeleton map to the feature space; in the feature space, performing channel attention weighting on each layer of features through a bottom-up path and the skeleton-guided channel attention mechanism; in the feature space, performing spatial attention weighting on each layer of features through a top-down path and the skeleton-guided spatial attention mechanism; in the feature space, performing multi-scale downsampling on the target feature skeleton map; matching the downsampled skeleton features with the weighted features of each layer to obtain a target fusion feature map; and training the target edge detection model based on the target fusion feature map and the preset model training hyperparameters.

[0089] It can be understood that after mapping the target feature skeleton graph as the prior structure information to the feature space, the feature fusion is performed in the feature space based on the attention-weighted bidirectional feature pyramid, which takes into account the background information to a certain extent, retains the small edge features, and reduces the edge breakage. For details, please refer to 4, Figure 4 This is a schematic diagram of feature fusion. Specifically, the bottom-up path and the Skeleton-Guided Channel Attention (SGCA) mechanism are used to weight channel attention on features at each layer. The top-down path and the Skeleton-Guided Spatial Attention (SGSA) mechanism are used to weight spatial attention on features at each layer. The downsampled skeleton features are then matched with the weighted features at each layer, achieving the goal of fusion through skeleton information and attention-guided features. The target edge detection model is then trained using the preset model training hyperparameters.

[0090] It should be noted that the skeleton-guided attention mechanism is added to the feature fusion in two directions. The skeleton-guided attention mechanism includes the skeleton-guided channel attention mechanism and the skeleton-guided spatial attention mechanism. Among them, the skeleton-guided channel attention mechanism pays more attention to the fusion of bottom-level and high-level information, and the skeleton-guided spatial attention mechanism pays more attention to the accurate positioning of edge positions. The bidirectional feature pyramid integrates bottom-level features and high-level features. Through the guidance of the attention mechanism, it focuses on key information, suppresses noise, improves the robustness of the model, realizes efficient cross-scale feature fusion, and enhances the feature expression of edge areas.

[0091] It should be understood that the preset model training hyperparameters refer to the hyperparameters used to train the target edge detection model. The preset model training hyperparameters can be that the size of the input feature map is 384*384, the initial learning rate is 0.001, the learner is Adam, the learning rate scheduler is Onecyclelr, and the training epochs are set to 800, and a test is performed every 100 epochs, etc.

[0092] Furthermore, the step of training the target edge detection model according to the target fusion feature map and the preset model training hyperparameters includes: performing spatial convolution on the target fusion feature map according to depthwise separable convolution; amplifying the convolved target fusion feature map through a target interpolation algorithm; training the current edge detection model according to the amplified target fusion feature map and the preset model training hyperparameters; determining the target joint loss function according to the cross loss function and the Diess loss function; calculating the loss value between the predicted value and the true value of the current edge detection model according to the target joint loss function; and performing verification training on the current edge detection model according to the current verification sample set until the loss value converges to a preset value, and determining the target edge detection model.

[0093] It should be understood that in order to preserve and enhance feature information, the target fused feature map needs to be spatially convolved using depthwise separable convolution. Similarly, to increase the size of the feature map, the convolved target fused feature map needs to be amplified using a target interpolation algorithm. This target interpolation algorithm can be a nearest neighbor interpolation algorithm. By combining the spatial convolution of the depthwise separable convolution and the amplification of the target interpolation algorithm, high-resolution details can be restored and edge smoothness can be enhanced. This ensures real-time processing speed and improves the geometric accuracy and continuity of edge prediction.

[0094] It can be understood that in order to effectively improve the accuracy of calculating the loss value between the predicted value and the true value of the current edge detection model, the target joint loss function is determined according to the cross loss function and the Dice loss function. The cross loss function can be a BCE cross entropy loss function, which is specifically expressed as:

[0095]

[0096] in, represents the target joint loss function, represents the BCE cross entropy loss function, represents the Sigmoid loss function, Represents the hyperparameter weight.

[0097] It should be noted that the current verification sample set refers to the sample set in the initial image sample set excluding the current training sample set and the current test sample set. After calculating the loss value between the predicted value and the true value of the current edge detection model, verification training is performed on the current edge detection model according to the current verification sample set until the loss value converges to the preset value.

[0098] Furthermore, after the step of verifying and training the current edge detection model according to the current verification sample set until the loss value converges to a preset value, it also includes: dividing the initial image sample set according to a second ratio to obtain a current test sample set; testing the edge detection model after verification training according to the current test sample set; extracting the current values of the multi-dimensional test evaluation indicators from the model test results; and determining the target edge detection model when the current values all meet the preset requirements.

[0099] It is understandable that the current test sample set refers to the sample set required for model testing. The current test sample set can also be a part of the initial image sample set, that is, the second proportion of the initial image sample set is used as the current training sample set, and the second proportion can be 30%. After testing the edge detection model after verification training based on the current test sample set, it is determined whether the current values of the multi-dimensional test evaluation indicators all meet the preset requirements. If so, it indicates that the test is qualified. On the contrary, if any one does not meet the preset requirements, it indicates that the test is unqualified, and iterative training is required. Among them, the multi-dimensional test evaluation indicators include but are not limited to IoU, F1, precision, and recall.

[0100] This embodiment obtains an initial image sample set and model input parameter requirements for model training; divides the initial image sample set according to a first ratio to obtain a current training sample set; performs data enhancement on the current training sample set, and converts the format of the enhanced training sample set according to the model input parameter requirements to obtain a target training sample set; and trains a target edge detection model based on the target training sample set, a backbone network, an edge skeleton extraction module, and a skeleton-guided attention mechanism. Through the above method, after obtaining the current training sample, the current training sample set is data enhanced to improve the diversity of the current training sample set, and then the enhanced training sample set is converted into a target training sample set according to the model input parameter requirements to ensure that the input image sample set meets the model requirements and accelerates the convergence process. The target training sample set is then input into a network architecture composed of a backbone network, an edge skeleton extraction module, and a skeleton-guided attention mechanism for model training to obtain a target edge detection model, thereby effectively improving the accuracy of the trained target edge detection model and further effectively improving the accuracy of edge detection.

[0101] This application also provides an image edge detection device, please refer to Figure 5 , the image edge detection device comprises:

[0102] The acquisition module 10 is used to acquire the image to be inspected in a complex quality inspection scenario.

[0103] The prediction module 20 is used to predict the image to be detected based on the target edge detection model to obtain a current edge prediction probability map; wherein, the target edge detection model is trained according to the backbone network, the edge skeleton extraction module and the skeleton-guided attention mechanism.

[0104] The processing module 30 is configured to perform binarization processing on the current edge prediction probability map according to a target dynamic threshold value to obtain an edge detection result corresponding to the image to be detected.

[0105] This embodiment obtains an image to be detected in a target complex quality inspection scene; predicts the image to be detected based on a target edge detection model to obtain a current edge prediction probability map; wherein, the target edge detection model is trained according to a backbone network, an edge skeleton extraction module and a skeleton-guided attention mechanism; binarizes the current edge prediction probability map according to a target dynamic threshold to obtain an edge detection result corresponding to the image to be detected. Through the above method, after obtaining the image to be detected in a target complex quality inspection scene, the image to be detected is input into the target edge detection model, features are extracted through the backbone network, noise is suppressed and edge continuity is enhanced through the edge skeleton extraction module, and channel and spatial weights are dynamically adjusted through the skeleton-guided attention mechanism, so that the fusion process focuses on the skeleton edge area while taking into account the detailed edges of the background, and then the edge detection result is obtained through binarization processing, thereby effectively improving the accuracy of edge detection and being applicable to a variety of complex quality inspection scenes.

[0106] The image edge detection device provided in this application utilizes the image edge detection method of the aforementioned embodiment, thereby resolving the technical issue of low edge detection accuracy in the prior art. Compared to the prior art, the image edge detection device provided in this application achieves the same beneficial effects as the image edge detection method provided in the aforementioned embodiment. Other technical features of the image edge detection device are the same as those disclosed in the aforementioned embodiment and are not further detailed here.

[0107] In one embodiment, the prediction module 20 is further used to obtain an initial image sample set and model input parameter requirements for model training; perform data division on the initial image sample set according to a first ratio to obtain a current training sample set; perform data enhancement on the current training sample set, and perform format conversion on the enhanced training sample set according to the model input parameter requirements to obtain a target training sample set; and train a target edge detection model based on the target training sample set, the backbone network, the edge skeleton extraction module, and the skeleton-guided attention mechanism.

[0108] In one embodiment, the prediction module 20 is further used to randomly scale the current training sample set and flip the scaled training sample set; perform color jittering on the flipped training sample set; normalize the jittered training sample set according to the model input parameter requirements; and perform format conversion on the processed training sample set according to the model input parameter requirements to obtain a target training sample set.

[0109] In one embodiment, the prediction module 20 is further used to perform feature extraction on each training image in the target training sample set based on the backbone network, and extract shallow image features from the image feature set; extract skeleton information of the shallow image features based on the edge skeleton extraction module, and generate a sparse attention mask based on the extracted current skeleton information; generate a target feature skeleton map based on the sparse attention mask, target learning weights and target learning bias; and train a target edge detection model based on the target feature skeleton map and the skeleton-guided attention mechanism.

[0110] In one embodiment, the prediction module 20 is further used to map the target feature skeleton map to a feature space; in the feature space, channel attention weighting is performed on each layer of features through a bottom-up path and the skeleton-guided channel attention mechanism; in the feature space, spatial attention weighting is performed on each layer of features through a top-down path and the skeleton-guided spatial attention mechanism; in the feature space, multi-scale downsampling is performed on the target feature skeleton map; the downsampled skeleton features are matched with the weighted features of each layer to obtain a target fusion feature map; and a target edge detection model is trained based on the target fusion feature map and the preset model training hyperparameters.

[0111] In one embodiment, the prediction module 20 is also used to perform spatial convolution on the target fusion feature map according to depthwise separable convolution; amplify the convolved target fusion feature map through a target interpolation algorithm; train the current edge detection model based on the amplified target fusion feature map and the preset model training hyperparameters; determine the target joint loss function based on the cross loss function and the Diess loss function; calculate the loss value between the predicted value and the true value of the current edge detection model based on the target joint loss function; perform verification training on the current edge detection model based on the current verification sample set until the loss value converges to a preset value, and determine the target edge detection model.

[0112] In one embodiment, the prediction module 20 is further used to divide the data of the initial image sample set according to the second ratio to obtain the current test sample set; test the edge detection model after verification training according to the current test sample set; extract the current value of the multi-dimensional test evaluation index from the model test results; and determine the target edge detection model when the current values all meet the preset requirements.

[0113] The present application provides an image edge detection device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the image edge detection method in the above-mentioned embodiment 1.

[0114] Reference below Figure 6 , which shows a schematic diagram of the structure of an image edge detection device suitable for implementing the embodiments of the present application. The image edge detection device in the embodiments of the present application may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), in-vehicle terminals (such as in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 6 The image edge detection device shown is merely an example and should not limit the functions and scope of use of the embodiments of the present application.

[0115] like Figure 6 As shown, the image edge detection device may include a processing device 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes based on programs stored in a ROM (Read Only Memory) 1002 or programs loaded from a storage device 1003 into a RAM (Random Access Memory) 1004. RAM 1004 also stores various programs and data required for the operation of the image edge detection device. Processing device 1001, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to I / O interface 1006: input devices 1007, such as a touchscreen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output devices 1008, such as a liquid crystal display (LCD), speaker, vibrator, etc.; storage device 1003, such as a magnetic tape or hard disk; and communication device 1009. The communication device 1009 can allow the image edge detection device to communicate with other devices wirelessly or by wire to exchange data. Although the figure shows an image edge detection device with various systems, it should be understood that it is not required to implement or have all of the systems shown. More or fewer systems can be implemented or provided instead.

[0116] In particular, according to the embodiments disclosed herein, the processes described above with reference to the flowcharts can be implemented as computer software programs. The computer programs contain program code for executing the methods shown in the flowcharts. In such embodiments, the computer programs can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from ROM 1002. When the computer programs are executed by processing device 1001, the above-described functions defined in the methods of the embodiments disclosed herein are performed.

[0117] The image edge detection device provided in this application utilizes the image edge detection method of the aforementioned embodiment, thereby resolving the technical issue of low edge detection accuracy in the prior art. Compared to the prior art, the image edge detection device provided in this application achieves the same beneficial effects as the image edge detection method provided in the aforementioned embodiment. The other technical features of this image edge detection device are the same as those disclosed in the aforementioned embodiment, and are not further elaborated upon here.

[0118] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any one or more embodiments or examples in a suitable manner.

[0119] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.

[0120] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer program) stored thereon, wherein the computer-readable program instructions are used to execute the image edge detection method in the above embodiment.

[0121] The computer-readable storage medium provided herein may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems, or devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to, an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including, but not limited to, wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.

[0122] The computer-readable storage medium may be included in the image edge detection device; or may exist independently without being assembled into the image edge detection device.

[0123] Computer program code for performing the operations of the present application may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0124] The flow charts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems and methods according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented by a dedicated hardware-based system that performs the specified function or operation, or can be implemented by a combination of dedicated hardware and computer instructions.

[0125] The modules described in the embodiments of the present application may be implemented in software or hardware, wherein the name of a module does not necessarily limit the unit itself.

[0126] The computer-readable storage medium provided in this application stores computer-readable program instructions (i.e., a computer program) for executing the aforementioned image edge detection method. This computer-readable storage medium can address the low accuracy of edge detection in existing technologies. Compared to existing technologies, the beneficial effects of the computer-readable storage medium provided in this application are similar to those of the image edge detection method provided in the aforementioned embodiments and are not further elaborated here.

[0127] The above description is only part of the embodiments of the present application and does not limit the patent scope of the present application. All equivalent structural transformations made by using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect application in other related technical fields are included in the patent protection scope of the present application.

Claims

1. A method for detecting image edges, characterized in that: The method comprises: Acquire the target image to be inspected in complex quality inspection scenarios; Predicting the image to be detected based on a target edge detection model to obtain a current edge prediction probability map; wherein the target edge detection model is trained based on a backbone network, an edge skeleton extraction module, and a skeleton-guided attention mechanism; Binarizing the current edge prediction probability map according to a target dynamic threshold to obtain an edge detection result corresponding to the image to be detected; wherein the target dynamic threshold refers to a dynamic threshold obtained by mapping the fusion features through global average pooling and activation function in a dynamic threshold edge detection decoder; Before the step of predicting the image to be detected based on the target edge detection model to obtain a current edge prediction probability map, the method further includes: Perform feature extraction on each training image in the target training sample set based on the backbone network, and extract shallow image features from the image feature set; Extracting skeleton information of the shallow image features based on the edge skeleton extraction module, and generating a sparse attention mask according to the extracted current skeleton information; generating a target feature skeleton graph according to the sparse attention mask, the target learning weight, and the target learning bias; An object edge detection model is trained based on the object feature skeleton map and the skeleton-guided attention mechanism.

2. The method according to claim 1, wherein Before the step of extracting features from each training image in the target training sample set based on the backbone network and extracting shallow image features from the image feature set, the method further includes: Obtain the initial image sample set for model training and model input parameter requirements; Dividing the initial image sample set into data according to the first ratio to obtain a current training sample set; Data enhancement is performed on the current training sample set, and format conversion is performed on the enhanced training sample set according to the model input parameter requirements to obtain a target training sample set.

3. The method according to claim 2, wherein The step of performing data enhancement on the current training sample set and converting the format of the enhanced training sample set according to the model input parameter requirements to obtain a target training sample set includes: Randomly scaling the current training sample set, and flipping the scaled training sample set; Perform color jitter on the flipped training sample set; Normalizing the jittered training sample set according to the model input parameter requirements; The processed training sample set is format-converted according to the model input parameter requirements to obtain a target training sample set.

4. The method according to claim 1, wherein The skeleton-guided attention mechanism includes a skeleton-guided channel attention mechanism and a skeleton-guided spatial attention mechanism; The step of training the target edge detection model according to the target feature skeleton graph and the skeleton-guided attention mechanism comprises: Mapping the target feature skeleton graph to a feature space; In the feature space, channel attention weighting is performed on each layer feature through the bottom-up path and the skeleton-guided channel attention mechanism; In the feature space, spatial attention weighting is performed on each layer of features through a top-down path and the skeleton-guided spatial attention mechanism; In the feature space, performing multi-scale downsampling on the target feature skeleton graph; Match the downsampled skeleton features with the weighted features of each layer to obtain the target fusion feature map; The target edge detection model is trained based on the target fusion feature map and the preset model training hyperparameters.

5. The method according to claim 4, wherein The step of training the target edge detection model according to the target fusion feature map and the preset model training hyperparameters includes: Performing spatial convolution on the target fusion feature map according to depth-wise separable convolution; The target fusion feature map after convolution is enlarged through the target interpolation algorithm; Train the current edge detection model based on the amplified target fusion feature map and the preset model training hyperparameters; Determine the target joint loss function based on the cross loss function and the Dice loss function; Calculating a loss value between a predicted value and a true value of the current edge detection model according to the target joint loss function; The current edge detection model is verified and trained according to the current verification sample set until the loss value converges to a preset value, and the target edge detection model is determined.

6. The method according to claim 5, wherein After the step of performing verification training on the current edge detection model according to the current verification sample set until the loss value converges to a preset value, the method further includes: Dividing the initial image sample set according to the second ratio to obtain a current test sample set; Testing the edge detection model after verification training according to the current test sample set; Extract the current values of multi-dimensional test evaluation indicators from the model test results; When the current values all meet the preset requirements, the target edge detection model is determined.

7. An image edge detection device, characterized in that: The device comprises: The acquisition module is used to obtain the image to be inspected in a complex quality inspection scenario; A prediction module, configured to predict the image to be detected based on a target edge detection model to obtain a current edge prediction probability map; wherein the target edge detection model is trained based on a backbone network, an edge skeleton extraction module, and a skeleton-guided attention mechanism; a processing module, configured to binarize the current edge prediction probability map according to a target dynamic threshold to obtain an edge detection result corresponding to the image to be detected; wherein the target dynamic threshold refers to a dynamic threshold obtained by mapping the fusion features through global average pooling and activation function in a dynamic threshold edge detection decoder; The prediction module is also used to extract features from each training image in the target training sample set based on the backbone network, and extract shallow image features from the image feature set; extract skeleton information from the shallow image features based on the edge skeleton extraction module, and generate a sparse attention mask based on the extracted current skeleton information; generate a target feature skeleton map based on the sparse attention mask, target learning weights and target learning bias; and train a target edge detection model based on the target feature skeleton map and the skeleton-guided attention mechanism.

8. An image edge detection device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the image edge detection method according to any one of claims 1 to 6.

9. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the image edge detection method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Remote sensing target detection method, terminal equipment and storage medium

    CN117911835A

  • Ship target detection method, device and equipment and storage medium

    CN119559374A