Adaptive multi-stage non-edge pruning method and system for image edge detection

By employing an adaptive multi-stage non-edge pruning method and a streamlined edge detector, the computational complexity problem of the Transformer edge detection model on resource-constrained devices is solved, achieving a balance between accuracy and efficiency in efficient edge detection.

CN122135041APending Publication Date: 2026-06-02NANKAI UNIV

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
NANKAI UNIV
Filing Date
2026-02-26
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

Existing Transformer-based edge detection models have high computational complexity in high-resolution image processing, making them difficult to deploy on resource-constrained devices. Furthermore, existing pruning strategies cannot effectively meet the multi-scale feature requirements of edge detection tasks, resulting in edge breakage and loss of details.

Method used

An adaptive multi-stage non-edge pruning method is adopted. Through hierarchical non-edge pruning criteria and lightweight model design, edge probability maps are dynamically generated and pruning masks are accumulated. Only key image blocks are retained for calculation. Multi-scale feature fusion is performed in combination with a streamlined edge detector.

Benefits of technology

While maintaining high accuracy, it significantly reduces computational overhead, improves the model's deployment friendliness and hardware compatibility on mobile platforms, and is suitable for efficient edge detection in resource-constrained scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122135041A_ABST
    Figure CN122135041A_ABST
Patent Text Reader

Abstract

This invention belongs to the field of image processing technology. It proposes an adaptive multi-stage non-edge pruning method and system for image edge detection. In multiple stages of the Transformer encoder, edge probability maps are generated based on the features of each stage, and these maps are binarized using an adaptive threshold for each stage to obtain a pruning decision mask. The masks from each stage are accumulated along the network depth to form a consistent cumulative pruning mask, which is used to retain only key edge image patches and remove redundant non-edge regions during self-attention computation. After encoding, the multi-stage features, restored to their original length, are input into a streamlined edge detector. The final edge prediction map is generated through lightweight linear projection and multi-scale fusion. This detector uses the image encoder as its backbone, removes the original cue decoder, has a simple structure, and is highly coordinated with the pruning mechanism. It significantly reduces computational complexity while effectively maintaining edge detection accuracy, making it suitable for resource-constrained edge computing scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and specifically to an adaptive multi-stage non-edge pruning method and system for image edge detection. Background Technology

[0002] The statements in this section are merely background information related to the present invention and do not necessarily constitute prior art.

[0003] In computer vision, edge detection, as a fundamental and crucial low-level visual task, aims to extract regions from images where brightness, color, or texture changes significantly, thereby outlining object contours and scene structures. Early methods primarily relied on hand-designed differential operators, such as the classic Canny edge detector, which achieved edge responses through gradient calculation and non-maximum suppression. With the development of machine learning, statistical learning-based methods introduced multi-scale filtering and structured prediction, significantly improving the continuity and semantic consistency of edges. In recent years, deep learning technology has driven a paradigm shift in edge detection. Fully convolutional networks, through end-to-end training and multi-level feature fusion, have achieved breakthroughs on multiple benchmark datasets. In particular, the rise of the Visual Transformer, with its global self-attention mechanism, can effectively model long-distance contextual dependencies and generate more coherent and refined edge structures in complex scenes, becoming an important architectural foundation for current high-performance edge detection models.

[0004] However, Transformer-based edge detection methods face significant computational efficiency bottlenecks while pursuing high accuracy. The computational complexity of their self-attention mechanism increases quadratically with image resolution, leading to high inference latency and large memory consumption under high-resolution input, making them difficult to deploy in resource-constrained scenarios such as mobile terminals or embedded devices. Although model compression techniques such as pruning have been extensively studied, existing pruning strategies are mostly geared towards image classification tasks, which have a certain tolerance for local information loss; however, edge detection, as a pixel-level dense prediction task, is highly sensitive to spatial details, and coarse-grained or static pruning easily causes edge breakage and loss of details. Furthermore, edge detection itself relies on multi-scale collaboration between shallow details and deep semantics, requiring pruning mechanisms to have hierarchical adaptability, while existing methods lack the ability to differentiate processing for the features of different network stages. At the same time, mainstream Transformer edge detectors often employ complex decoding structures, which not only increase the computational burden but also hinder the effective integration of dynamic sparsity strategies, limiting the feasibility of efficient deployment. Summary of the Invention

[0005] To address the problem that existing edge detection models are too computationally complex to be deployed on resource-constrained devices, this invention provides an adaptive multi-stage non-edge pruning method and system for image edge detection. By using hierarchical non-edge pruning criteria and lightweight model design, it significantly reduces computational overhead while maintaining high accuracy, thus facilitating efficient edge detection on mobile platforms.

[0006] To achieve the above objectives, the present invention adopts the following technical solution: In a first aspect, the present invention provides an adaptive multi-stage non-edge pruning method for image edge detection.

[0007] An adaptive multi-stage non-edge pruning method for image edge detection includes the following steps: The input image undergoes multi-stage feature extraction via an encoder. At each stage, a corresponding edge probability map is generated based on the feature representation of that stage. The edge probabilities are then adjusted according to a preset adaptive threshold for that stage. Figure 2 Value-enhanced, resulting in the binary pruning decision mask for this stage; The binary pruning decision masks generated at each stage are accumulated sequentially along the network depth direction to form a consistent cumulative pruning mask across stages. In the self-attention calculation at each stage, only the image blocks marked as retained in the cumulative pruning mask are retained to participate in key-value pair interaction, while the other image blocks are not included in the calculation. After all stages of encoding are completed, the feature sequences of each stage, which have been pruned and restored to the original number of image patches, are input into the streamlined edge detector. The final edge prediction map is generated through multi-scale feature fusion and linear projection. The streamlined edge detector uses the image encoder as the backbone network and removes its original cue decoder and mask generation module.

[0008] In one implementation of the first aspect of the present invention, the edge probability map is generated by a non-edge prediction module. The non-edge prediction module includes a linear layer and a Sigmoid activation function. The linear layer receives the feature representation of the current stage as input and outputs the edge confidence value corresponding to each image block. The Sigmoid activation function maps the edge confidence value to the interval between 0 and 1 to form an edge probability map covering all image blocks.

[0009] In one implementation of the first aspect of the present invention, the adaptive threshold takes different values ​​at different network stages, wherein the adaptive threshold of the shallow stage is smaller than the adaptive threshold of the deep stage, so that the shallow stage retains more image patches and the deep stage removes more image patches. The adaptive threshold of each stage is fixed during model training or determined as a learnable parameter.

[0010] In one implementation of the first aspect of the present invention, the cumulative pruning mask is generated in the following manner: the binary pruning decision mask of the first stage is used as the initial cumulative pruning mask; for each subsequent stage, the binary pruning decision mask of the current stage is subjected to a block-by-block logical AND operation with the cumulative pruning mask of the previous stage, and the result is used as the cumulative pruning mask of the current stage to guide the block preservation or pruning operation in the current stage and subsequent stages.

[0011] In one implementation of the first aspect of the present invention, when performing self-attention calculation at each stage, the set of retained image blocks is determined according to the cumulative pruning mask of the current stage, and the feature vectors corresponding to the retained image blocks are extracted only from the feature representation of the current stage. The feature vectors are used as queries, keys and values ​​to input the multi-head self-attention mechanism. The feature vectors corresponding to the pruned image blocks do not participate in any attention weight calculation and weighted summation operation. The output feature sequence obtained after processing by the multi-head self-attention mechanism contains only the updated features corresponding to the retained image patches. The length of the output feature sequence is equal to the number of retained image patches, and it is directly used as the input of the next stage Transformer module without interpolation, padding or dimension expansion operations.

[0012] In one implementation of the first aspect of the present invention, the operation of restoring the original number of image patches includes: for the self-attention output feature sequence of each stage, feature backfilling is performed according to the cumulative pruning mask of the next stage; for any image patch position, if it is marked as pruned in the cumulative pruning mask of the next stage, the self-attention output feature of the current stage is filled into the position; if it is marked as retained, it is left blank and filled by the output of a deeper stage in subsequent stages, finally forming a complete feature sequence consistent with the original number of image patches.

[0013] In one implementation of the first aspect of the present invention, the streamlined edge detector applies independent linear projection transformations to the complete feature sequences recovered at each stage, unifying the features of different stages to the same channel dimension, and then splices all the features after linear projection transformation in the channel dimension to form a high-dimensional feature tensor that integrates information from multiple stages, which is used as the input to generate the final edge prediction map. The final edge prediction map is obtained by processing the high-dimensional feature tensor sequentially through a linear projection layer, a normalization layer, and a pointwise activation function. The linear projection layer compresses the number of channels to 1, the normalization layer normalizes the single-channel features, and the pointwise activation function maps the normalized features to edge response values ​​between 0 and 1. The output is a single-channel edge prediction map with the same spatial resolution as the input image.

[0014] Secondly, the present invention provides an adaptive multi-stage non-edge pruning system for image edge detection.

[0015] An adaptive multi-stage non-edge pruning system for image edge detection includes: The edge probability generation unit is configured to: perform multi-stage feature extraction on the input image using an encoder; generate a corresponding edge probability map at each stage based on the feature representation of the current stage; and adjust the edge probability according to a preset adaptive threshold for that stage. Figure 2 Value-enhanced, resulting in the binary pruning decision mask for this stage; The pruning mask accumulation unit is configured to: accumulate the binary pruning decision masks generated at each stage along the network depth direction in sequence to form a consistent cumulative pruning mask across stages; and in the self-attention calculation at each stage, only the image blocks marked as retained in the cumulative pruning mask are retained to participate in key-value pair interaction, while the other image blocks are not included in the calculation. The edge prediction output unit is configured to: after completing the encoding of all stages, input the feature sequences of each stage, which have been pruned and restored to the original number of image blocks, into the streamlined edge detector, and generate the final edge prediction map through multi-scale feature fusion and linear projection. The streamlined edge detector uses the image encoder as the backbone network and removes its original cue decoder and mask generation module.

[0016] Thirdly, the present invention provides a computer device, comprising: a processor and a computer-readable storage medium; A processor, adapted to execute computer programs; A computer-readable storage medium storing a computer program, which, when executed by a processor, implements the adaptive multi-stage non-edge pruning method for image edge detection according to the first aspect of the present invention.

[0017] Fourthly, the present invention provides a computer-readable storage medium storing a computer program adapted to be loaded by a processor and executed by an adaptive multi-stage non-edge pruning method for image edge detection according to the first aspect of the present invention.

[0018] Compared with the prior art, the beneficial effects of the present invention are: This invention innovatively proposes an adaptive multi-stage non-edge pruning method for image edge detection. By constructing a complete technical closed loop of "edge probability generation - mask accumulation - sparse attention - multi-scale fusion", it achieves a significant reduction in computational overhead while maintaining high-precision edge detection capabilities. At each encoding stage, an edge probability map is dynamically generated, and a binary pruning decision mask is produced accordingly, avoiding uniform or static processing of the entire image. By accumulating the masks at each stage along the network depth direction, cross-stage consistency in pruning decisions is ensured, preventing key edges from being incorrectly removed due to stage-specific misjudgments. In the self-attention calculation, only image blocks marked as edges in the accumulated mask are retained for key-value interaction, fundamentally reducing redundant computation. Finally, a streamlined edge detector with a simplified structure completes multi-scale feature fusion and prediction, preserving rich edge cues from shallow to deep layers while avoiding the additional burden brought by complex decoders. The overall process is naturally adapted to the Transformer architecture, achieving synergistic optimization of accuracy and efficiency.

[0019] This invention effectively resolves the contradiction between detail preservation and computational compression in edge detection tasks by introducing a hierarchical adaptive pruning threshold mechanism. Shallow features are rich in spatial localization information but have weak semantic discriminative ability; high-threshold pruning can easily lose fine-grained edges. Deep features have clear semantics but low spatial resolution, making them suitable for more aggressive pruning. This method sets differentiated adaptive thresholds for different network stages, allowing shallow stages to retain more candidate regions to ensure edge integrity, while deep stages focus on high-confidence semantic boundaries to eliminate redundant computation. This progressive pruning strategy, from coarse to fine and from broad to strict, not only conforms to the natural law of "local response → global integration" in edge formation but also enables the model to retain potential edge clues in the early stages and accurately extract semantic contours in the later stages. This significantly reduces the computational load in non-edge regions while maintaining robust detection capabilities for complex structures, weak texture boundaries, and occluded scenes.

[0020] The streamlined edge detector designed in this invention works in close synergy with a multi-stage pruning mechanism, significantly improving the model's deployment friendliness and hardware compatibility. Based on the SAM-ViT image encoder, this detector inherits its strong edge-awareness capabilities gained from pre-training on large-scale open-world data. Simultaneously, it completely removes the prompt decoder and mask generation module, which are geared towards segmentation tasks, from the original model, avoiding computational overhead unrelated to edge detection. The decoding part abandons traditional convolutional transpose or complex upsampling structures, employing only lightweight linear projection and channel stitching to achieve multi-scale feature fusion. This not only significantly reduces the number of parameters and memory usage but also allows the entire inference process to be expressed entirely through matrix operations, facilitating efficient execution on accelerated hardware such as GPUs and NPUs. More importantly, this concise architecture naturally supports dynamic sparsity; the pruned feature sequences can be directly input into subsequent modules without additional padding or rearrangement, ensuring that the pruning benefits are truly translated into end-to-end inference acceleration.

[0021] The multi-stage non-edge pruning mechanism implemented in this invention possesses excellent versatility and scalability, providing a new paradigm for high-precision visual perception in resource-constrained scenarios. Since the pruning decision is entirely based on the dynamically generated edge probability map during forward propagation, no additional annotation or offline analysis is required, making it applicable to any input image. Furthermore, this method does not rely on a specific backbone network and can be flexibly integrated into Vision Transformer variants of different sizes. In practical deployments, users can continuously balance accuracy and speed by adjusting the adaptive thresholds of each stage, meeting the performance constraints of different terminal devices. Moreover, because the pruning object is a non-edge region, which typically accounts for more than 90% of the image, this invention can achieve several times the computational cost reduction and memory savings with only a minimal loss of accuracy. It is particularly suitable for edge computing applications with stringent requirements for real-time performance and energy efficiency, such as drone inspections, mobile AR, and smart cameras.

[0022] Advantages of additional aspects 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

[0023] The accompanying drawings, which form part of this invention, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an improper limitation of the invention.

[0024] Figure 1 A flowchart illustrating an adaptive multi-stage non-edge pruning method for image edge detection provided as an exemplary embodiment of the present invention; Figure 2 A schematic diagram of the network framework of an adaptive multi-stage non-edge pruning method provided as an exemplary embodiment of the present invention; Figure 3 A comparison of experimental effect diagrams of the present invention and effect diagrams of related methods is provided for an exemplary embodiment of the present invention; Figure 4 A schematic diagram of an adaptive multi-stage non-edge pruning system for image edge detection provided as an exemplary embodiment of the present invention; Figure 5 A schematic diagram of a computer device provided for an exemplary embodiment of the present invention. Detailed Implementation

[0025] The present invention will be further described below with reference to the accompanying drawings and embodiments.

[0026] It should be noted that the following detailed descriptions are exemplary and intended to provide further illustration of the invention. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.

[0027] Edge detection, a fundamental task in computer vision, aims to extract object boundaries and other salient structural contours by identifying regions of abrupt changes in brightness, texture, or color features in an image. Its output provides crucial structural cues for downstream visual tasks such as image segmentation, object detection, general object candidate region generation, and weakly supervised learning. Therefore, improving the accuracy and robustness of edge detection is of great significance for enhancing the overall understanding and analytical capabilities of visual systems. Traditional edge detection methods have evolved from those based on manually designed differential operators (such as the Canny detector proposed in "A computational approach to edge detection" published at TPAMI in 2009) to those combining statistical learning (such as the gPb method in "Contour detection and hierarchical imagesegmentation" published by Pablo Arbelaez at TPAMI in 2010). With breakthroughs in deep learning technology, fully convolutional networks (such as HED proposed by Saining Xie in "Holistically-nested edge detection" published at ICCV in 2015, and the RCF method in "Richer Convolutional Features for Edge Detection" published by Yun Liu at TPAMI in 2017) have significantly improved edge detection performance through end-to-end learning and multi-scale feature fusion. In recent years, the emergence of visual transformers has further propelled the development of this field. Their global self-attention mechanism can effectively model long-range dependencies, overcoming the limitations of convolutional neural networks in receptive field. Detection methods based on Transformers or hybrid methods with convolutional neural networks achieve clearer and more coherent edge responses in scenes with complex structures, diverse textures, and occlusions by fusing local features with global context, and have achieved leading results on multiple public datasets.

[0028] However, Transformer-based edge detection models often incur high computational costs and inference latency when processing high-resolution images, limiting their practical deployment in resource-constrained environments such as mobile terminals and embedded systems. Therefore, building lightweight Transformer edge detection models while maintaining detection accuracy has become a critical issue. Pruning methods in model compression techniques are often used to improve model efficiency, and related technologies in this field have evolved from static coarse-grained strategies (such as weight pruning, quantization, and low-rank decomposition) to dynamic fine-grained methods (such as image patch pruning and early exit). However, existing image patch pruning research mainly focuses on image classification tasks, which have a certain tolerance for local image patch loss. Edge detection, as a pixel-level dense prediction task, needs to retain rich spatial detail information. Directly adopting a uniform pruning strategy easily leads to edge structure fragmentation and detail loss. Therefore, how to construct an image patch importance evaluation criterion suitable for edge detection has become a primary challenge. Furthermore, the edge detection task itself relies on the effective fusion of multi-level features. Shallow features capture detailed textures and local intensity changes, while deep features integrate high-level information for semantic boundary discrimination; both are indispensable for generating complete and accurate edge maps. This characteristic necessitates that pruning strategies possess hierarchical adaptability, leading to the crucial question of how to design differentiated pruning mechanisms that can balance the contributions of features at different levels. Meanwhile, existing Transformer-based edge detectors often rely on complex decoder designs (such as deep convolutional networks or multi-layer linear modules), which not only increase computational burden and memory consumption, but their complex information flow also hinders the effective integration of dynamic pruning strategies and increases the complexity of actual system deployment. Therefore, constructing a simple, pruning-friendly, and high-accuracy edge detector architecture has become another significant challenge in achieving efficient and practical implementation.

[0029] In view of the problems existing in the current solution, this implementation proposes an adaptive multi-stage non-edge pruning method for image edge detection. Through hierarchical non-edge pruning criteria and lightweight model design, it significantly reduces computational overhead while maintaining high accuracy, thus facilitating efficient edge detection on mobile platforms. Figure 1 The diagram illustrates the processing flow of the adaptive non-edge pruning mechanism of this invention in a single Transformer stage. Input features first enter the Attention Block and are simultaneously fed into the Non-edge Prediction module. This module generates an edge map using a lightweight linear layer and a sigmoid function. Subsequently, the system modifies the edge probability of each image patch with the adaptive threshold of the current stage. Comparison: If greater than or equal to If a block is selected, it is marked as "Set 1" (retained); otherwise, it is marked as "Set 0" (pruned), thus forming a binary decision mask. This mask is used to guide subsequent attention calculations, retaining only image blocks from "Set 1" for key-value interactions, achieving sparsity. In the diagram, "Pruning?" indicates the decision node for enabling pruning, and "×N" indicates that this structure is reused in multiple stages. The diagram below uses 9 image blocks as an example, with the original blocks on the left and the corresponding edge response map on the right, intuitively demonstrating the effect of suppressing non-edge regions and preserving edge regions. The entire process realizes content-aware dynamic pruning, providing a foundation for multi-stage progressive optimization.

[0030] This invention designs an adaptive non-edge pruning method. This method first extracts feature representations of the input image using a Transformer encoder and calculates the corresponding edge probability map at this layer to quantify the confidence that each spatial location belongs to an edge region. The edge probability map is generated through a lightweight projection layer and activation function, ensuring the model can capture multi-scale edge responses from low-level texture to high-level semantics. After obtaining the edge probability map, an adaptive threshold decision mechanism is used to generate a binary pruning mask. Through threshold decision, regions with edge probabilities below a threshold are marked as "non-edge" regions and pruned in subsequent attention calculations; simultaneously, key edge regions with probabilities above the threshold are retained to participate in subsequent feature propagation and fusion. This data-dependent pruning strategy can significantly reduce computational complexity while maintaining sensitivity and integrity to the image edge structure. Specifically, it includes: This invention models edge detection as a pixel-level dense classification task, whose output includes edge pixels rich in structural information and non-edge pixels lacking contour details. Unlike image classification tasks, which are robust to label pruning, edge detection is extremely sensitive to spatial details; incorrect pruning can easily lead to contour breaks and blurred boundaries. Therefore, this invention proposes a targeted strategy that focuses on the dominant and unevenly distributed non-edge labels in the image, achieving a significant improvement in computational efficiency while maintaining the accuracy of key edges. The network model is a streamlined edge detection Transformer model based on an adaptive multi-stage pruning mechanism. The feature extraction part can be the Vision Transformer (ViT) architecture mentioned in Alexey Dosovitskiy's paper "Animage is worth 16x16 words: Transformers for image recognition at scale," or the Image Encoder ViT architecture mentioned in Alexander Kirillov's paper "SegmentAnything," or other basic network architectures.

[0031] For ViT, such as Figure 2 As shown, a non-edge prediction module is added to certain layers of ViT. This module consists of lightweight linear layers and activation functions. Its function is to dynamically calculate the probability that each label belongs to an edge based on the features of each Transformer stage, thereby generating a binary decision mask to guide label pruning and achieving efficient filtering and removal of redundant non-edge regions. For the ... Stage, Input Features via linear layer After processing with the Sigmoid activation function, the edge probability vectors of each image patch are obtained. : (1); Through phased adaptive thresholds The marginal probabilities are binarized to generate a decision mask. ,in Represents edge image patches, This represents a non-edge image patch. To maintain consistency across stages, the mask is updated cumulatively along the network depth: (2); In Transformer attention calculation, to completely avoid interference from residuals after pruning, only the mask is retained. Corresponding index The markers participate in the calculation, where This represents the set of image patches preserved by the mask. Let... Indicates by mask The defined projection operator then yields the pruned feature sequence. for: (3); in, Given the current number of image patches, then utilize... Calculate multi-head self-attention output After encoding is completed, in order to adapt to the decoder input, the feature sequence needs to be restored to the original length N, which is achieved by layer-by-layer feature backfilling.

[0032] (4); This method achieves efficient pruning of non-edge regions in the Transformer architecture through hierarchical edge probability estimation and dynamic masking mechanism, which maintains the integrity of the edge structure and significantly reduces the computational burden.

[0033] This invention constructs a multi-stage progressive pruning optimization mechanism. To adapt to the multi-scale feature perception requirements of edge detection tasks, this method utilizes edge prediction information output from different network layers (shallow and deep) to form hierarchical supervision. Specifically, in each pruning stage, a pruning mask is dynamically generated based on the preliminary edge prediction map generated by the current layer. This mask guides the next stage in filtering and focusing on candidate labels during attention computation. Through this inter-stage progressive optimization, the model can progressively refine edge structures from coarse to fine: the shallow stage focuses on preserving a broad range of edge responses, while the deep stage focuses on refining semantic boundaries. This mechanism ensures the adaptability of the pruning process at multi-scale feature levels and effectively avoids edge breakage and detail loss caused by over-pruning.

[0034] More specifically, Transformer-based edge detection models rely on multi-scale features with different characteristics: shallow features can capture precise localization information even with semantic ambiguity, while deep features provide clear semantic information at the expense of localization accuracy. This inherent characteristic necessitates effective cross-layer integration. Therefore, this invention introduces an adaptive multi-stage pruning strategy, which dynamically evaluates and adjusts the pruning intensity at different Transformer stages based on the intrinsic characteristics of the features (especially their predicted edge maps). In the shallow layers of the network, spatial details in the feature maps are crucial for accurate edge localization. Although the edge prediction maps at this stage may be noisy and have low confidence, premature pruning will lose valuable localization cues. Therefore, this invention employs a low pruning threshold in the shallow stages, implementing a conservative pruning strategy to fully preserve spatial details. In the deep stages, features contain rich high-level semantic information, and their edge predictions are generally clearer and have higher confidence, primarily serving semantic contour recognition. Based on this, the present invention sets a higher pruning threshold at deeper levels, thereby enabling the removal of markers identified as non-edges more broadly and reliably, significantly improving computational efficiency. This threshold design allows the pruning strategy to adapt to the hierarchical evolution of features: carefully preserving details at shallow levels and actively eliminating redundancy at deeper levels, thereby achieving an optimal balance between maintaining edge detection accuracy and computational efficiency.

[0035] This invention designs a manifold edge detector architecture (SViT-SED). To improve the pruning friendliness and deployment efficiency of the overall architecture, this invention further proposes a simple edge detection model. The decoder of this model abandons the traditional complex multi-layer convolutional network or transposed convolutional network design, and instead adopts a linear projection layer combined with a lightweight feature aggregation module, aiming to overcome the limitations of existing hybrid decoders that are complex in structure, difficult to compress, and difficult to deploy. During the forward propagation of the Transformer, the pruning mask guides the attention calculation to focus on the key image patches that are preserved, while the pruned image patches do not participate in or greatly reduce their interaction calculations with other image patches, thereby achieving efficient sparsity processing at the feature level. This design is highly synergistic with the aforementioned multi-stage pruning mechanism, and while ensuring high-precision edge localization, it significantly improves the inference efficiency of the model in resource-constrained environments such as mobile devices and embedded systems.

[0036] More specifically, the Manifold Edge Detector Architecture (SViT-SED) uses SAM-ViT as the backbone encoder, leveraging its robust boundary representation capabilities obtained through large-scale pre-training on open-world data. To adapt to edge detection tasks and incorporate pruning processes, this design discards the complex cue-conditional mask decoder in the original model, retaining only its image encoder as the feature extraction backbone, thus constructing a boundary-sensitive and structurally streamlined Transformer encoder.

[0037] In the decoding section, the streamlined edge detector abandons the traditional multi-level convolutional decoding design and adopts a lightweight multi-scale fusion mechanism. Specifically, it recovers the complete length feature sequence from each pruning stage. First, through a dedicated, learnable linear projection layer... Perform channel alignment: (5); Subsequently, the projection features of all stages are stitched together along the channel dimension to achieve multi-scale information fusion: (6); Finally, by combining a linear projection layer with layer normalization and a pointwise activation function, the final edge prediction output is generated: (7); in, and For learnable projection parameters, This is the activation function.

[0038] This streamlined design not only significantly reduces the structural complexity and computational overhead of the model, but also works in close coordination with the aforementioned adaptive multi-stage pruning mechanism to improve the feasibility of deploying the model in resource-constrained scenarios such as mobile devices while maintaining detection accuracy.

[0039] Figure 3 This document presents a comparative example of edge detection using the method of this invention and existing technologies. From left to right, the first column shows the original input image; the second column shows the ground truth image of the edge annotations; the third column shows the detection results based on the RCF method from the 2019 publication *Richer Convolutional Features for Edge Detection* in *TPAMI*; the fourth column shows the detection results based on the EDTER method from the 2022 CVPR conference publication *EDTER: Edge Detection With Transformer*; the fifth column shows the detection results using the SViT-SED architecture of this invention before pruning; and the sixth column shows the SViT-SED detection results after adaptive multi-stage pruning according to this invention. The illustrations provide a clear comparison of the differences in performance among the various methods in terms of edge integrity, detail preservation, and noise suppression. Figure 3 As shown, by comparing the detection results of the method of this invention with those of existing methods, it can be seen that the streamlined edge detector proposed in this invention can generate clearer and more coherent edge responses. Further comparison of the results in the fifth column (before pruning) and the sixth column (after pruning) shows that the model after pruning by this invention basically maintains the integrity of the edge structure, demonstrating the effective balance between accuracy and efficiency achieved by this invention.

[0040] Figure 4 An adaptive multi-stage non-edge pruning system for image edge detection is shown, comprising: The edge probability generation unit 401 is configured to: perform multi-stage feature extraction on the input image through an encoder; generate a corresponding edge probability map based on the feature representation of the current stage at each stage; and adjust the edge probability according to a preset adaptive threshold for that stage. Figure 2 Value-enhanced, resulting in the binary pruning decision mask for this stage; The pruning mask accumulation unit 402 is configured to: accumulate the binary pruning decision masks generated at each stage along the network depth direction in sequence to form a consistent cumulative pruning mask across stages; and in the self-attention calculation at each stage, only the image blocks marked as retained in the cumulative pruning mask are retained to participate in key-value pair interaction, while the other image blocks are not included in the calculation. The edge prediction output unit 403 is configured to: after completing the encoding of all stages, input the feature sequences of each stage, which have been pruned and restored to the original number of image blocks, into the streamlined edge detector, and generate the final edge prediction map through multi-scale feature fusion and linear projection. The streamlined edge detector uses the image encoder as the backbone network and removes its original cue decoder and mask generation module.

[0041] It is understood that the aforementioned units can be individually or entirely merged into one or more other units, or some of the units can be further divided into multiple functionally smaller units. This achieves the same operation without affecting the technical effects of the embodiments of the present invention. The aforementioned units are based on logical functional division. In practical applications, the function of one unit can be implemented by multiple units, or the function of multiple units can be implemented by one unit. In other embodiments of the present invention, the system may also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented collaboratively by multiple units.

[0042] According to another embodiment of the present invention, the system of this embodiment can be constructed by running a computer program (including program code) capable of performing the steps involved in the corresponding method of the present invention on a general-purpose computing device, such as a computer, which includes processing elements and storage elements such as a central processing unit (CPU), random access memory (RAM), and read-only memory (ROM). The computer program can be recorded on, for example, a computer-readable recording medium, loaded into the aforementioned computing device through the computer-readable recording medium, and run therein.

[0043] Figure 5 A computer device is shown, which includes a processor 501, a communication interface 502, and a computer-readable storage medium 503. The processor 501, communication interface 502, and computer-readable storage medium 503 can be connected via a bus or other means.

[0044] The communication interface 502 is used to receive and send data. The computer-readable storage medium 503 can be stored in the memory of the electronic device. The computer-readable storage medium 503 is used to store computer programs, which include program instructions. The processor 501 is used to execute the program instructions stored in the computer-readable storage medium 503.

[0045] The processor 501 is the computing and control core of the electronic device. It is suitable for implementing one or more instructions, specifically for loading and executing one or more instructions to achieve the corresponding method flow or corresponding function.

[0046] Processor 501 is configured to perform the following procedure: The input image undergoes multi-stage feature extraction via an encoder. At each stage, a corresponding edge probability map is generated based on the feature representation of that stage. The edge probabilities are then adjusted according to a preset adaptive threshold for that stage. Figure 2 Value-enhanced, resulting in the binary pruning decision mask for this stage; The binary pruning decision masks generated at each stage are accumulated sequentially along the network depth direction to form a consistent cumulative pruning mask across stages. In the self-attention calculation at each stage, only the image blocks marked as retained in the cumulative pruning mask are retained to participate in key-value pair interaction, while the other image blocks are not included in the calculation. After all stages of encoding are completed, the feature sequences of each stage, which have been pruned and restored to the original number of image patches, are input into the streamlined edge detector. The final edge prediction map is generated through multi-scale feature fusion and linear projection. The streamlined edge detector uses the image encoder as the backbone network and removes its original cue decoder and mask generation module.

[0047] This invention also provides a computer-readable storage medium, which is a memory device in an electronic device for storing programs and data. It is understood that the computer-readable storage medium here may include both built-in storage media in the electronic device and extended storage media supported by the electronic device. The computer-readable storage medium provides storage space for storing the processing system of the electronic device.

[0048] Furthermore, this storage space also contains one or more instructions suitable for loading and execution by the processor. These instructions can be one or more computer programs (including program code). It should be noted that the computer-readable storage medium here can be a high-speed RAM memory; alternatively, it can also be at least one computer-readable storage medium located remotely from the aforementioned processor.

[0049] In one embodiment, the computer-readable storage medium stores one or more instructions; the processor loads and executes the one or more instructions stored in the computer-readable storage medium to perform the following process: The input image undergoes multi-stage feature extraction via an encoder. At each stage, a corresponding edge probability map is generated based on the feature representation of that stage. The edge probabilities are then adjusted according to a preset adaptive threshold for that stage. Figure 2 Value-enhanced, resulting in the binary pruning decision mask for this stage; The binary pruning decision masks generated at each stage are accumulated sequentially along the network depth direction to form a consistent cumulative pruning mask across stages. In the self-attention calculation at each stage, only the image blocks marked as retained in the cumulative pruning mask are retained to participate in key-value pair interaction, while the other image blocks are not included in the calculation. After all stages of encoding are completed, the feature sequences of each stage, which have been pruned and restored to the original number of image patches, are input into the streamlined edge detector. The final edge prediction map is generated through multi-scale feature fusion and linear projection. The streamlined edge detector uses the image encoder as the backbone network and removes its original cue decoder and mask generation module.

[0050] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed in this invention can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can implement the described functions using different methods for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0051] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the flow or function according to the embodiments of the present invention is generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in or transmitted through a computer-readable storage medium. The computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic cable, digital cable) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data processing device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive), etc.

[0052] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. An adaptive multi-stage non-edge pruning method for image edge detection, characterized in that, Includes the following processes: The input image is subjected to multi-stage feature extraction by an encoder. At each stage, a corresponding edge probability map is generated based on the feature representation of the current stage. The edge probability map is then binarized according to the preset adaptive threshold of the stage to obtain the binary pruning decision mask of that stage. The binary pruning decision masks generated at each stage are accumulated sequentially along the network depth direction to form a consistent cumulative pruning mask across stages. In the self-attention calculation at each stage, only the image blocks marked as retained in the cumulative pruning mask are retained to participate in key-value pair interaction, while the other image blocks are not included in the calculation. After all stages of encoding are completed, the feature sequences of each stage, which have been pruned and restored to the original number of image blocks, are input into the streamlined edge detector. The final edge prediction map is generated through multi-scale feature fusion and linear projection. The streamlined edge detector uses the image encoder as the backbone network and removes its original cue decoder and mask generation module.

2. The adaptive multi-stage non-edge pruning method for image edge detection as described in claim 1, characterized in that, The edge probability map is generated by the non-edge prediction module, which includes a linear layer and a sigmoid activation function. The linear layer receives the feature representation of the current stage as input and outputs the edge confidence value corresponding to each image patch. The sigmoid activation function maps the edge confidence value to the interval between 0 and 1 to form an edge probability map covering all image patches.

3. The adaptive multi-stage non-edge pruning method for image edge detection as described in claim 1, characterized in that, The adaptive threshold takes different values ​​at different network stages, with the adaptive threshold at the shallow stage being smaller than that at the deep stage. This allows the shallow stage to retain more image patches while the deep stage to remove more image patches. The adaptive threshold at each stage is fixed during model training or determined as a learnable parameter.

4. The adaptive multi-stage non-edge pruning method for image edge detection as described in claim 1, characterized in that, The cumulative pruning mask is generated in the following way: the binary pruning decision mask of the first stage is used as the initial cumulative pruning mask; for each subsequent stage, the binary pruning decision mask of the current stage is subjected to a block-by-block logical AND operation with the cumulative pruning mask of the previous stage, and the result is used as the cumulative pruning mask of the current stage to guide the block preservation or pruning operation in the current stage and subsequent stages.

5. The adaptive multi-stage non-edge pruning method for image edge detection as described in claim 1, characterized in that, When performing self-attention calculation at each stage, the set of image blocks to be retained is determined based on the cumulative pruning mask of the current stage. The feature vectors corresponding to the retained image blocks are extracted only from the feature representation of the current stage. The feature vectors are used as queries, keys and values ​​to input into the multi-head self-attention mechanism. The feature vectors corresponding to the pruned image blocks do not participate in any attention weight calculation or weighted summation operation. The output feature sequence obtained after processing by the multi-head self-attention mechanism contains only the updated features corresponding to the retained image patches. The length of the output feature sequence is equal to the number of retained image patches, and it is directly used as the input of the next stage Transformer module without interpolation, padding or dimension expansion operations.

6. The adaptive multi-stage non-edge pruning method for image edge detection as described in claim 1, characterized in that, The operation to restore the original number of image patches includes: for the self-attention output feature sequence of each stage, feature backfilling is performed according to the cumulative pruning mask of the next stage; for any image patch position, if it is marked as pruned in the cumulative pruning mask of the next stage, the self-attention output feature of the current stage is filled into the position; if it is marked as retained, it is left blank and filled by the output of deeper stages in subsequent stages, finally forming a complete feature sequence consistent with the original number of image patches.

7. The adaptive multi-stage non-edge pruning method for image edge detection as described in claim 1, characterized in that, The streamlined edge detector applies independent linear projection transformations to the complete feature sequences recovered at each stage, unifying the features of different stages to the same channel dimension. Then, all the features after linear projection transformation are concatenated in the channel dimension to form a high-dimensional feature tensor that integrates information from multiple stages, which serves as the input for generating the final edge prediction map. The final edge prediction map is obtained by sequentially processing the high-dimensional feature tensor with a linear projection layer, a normalization layer, and a pointwise activation function. The linear projection layer compresses the number of channels to 1, the normalization layer normalizes the single-channel features, and the pointwise activation function maps the normalized features to edge response values ​​between 0 and 1. The output is a single-channel edge prediction map with the same spatial resolution as the input image.

8. An adaptive multi-stage non-edge pruning system for image edge detection, characterized in that, include: The edge probability generation unit is configured to: perform multi-stage feature extraction on the input image through an encoder, generate a corresponding edge probability map based on the feature representation of the current stage at each stage, and binarize the edge probability map according to the preset adaptive threshold of the stage to obtain the binary pruning decision mask of the stage. The pruning mask accumulation unit is configured to: accumulate the binary pruning decision masks generated at each stage along the network depth direction to form a consistent cumulative pruning mask across stages; and in the self-attention calculation at each stage, only the image blocks marked as retained in the cumulative pruning mask are retained to participate in key-value pair interaction, while the remaining image blocks are not included in the calculation. The edge prediction output unit is configured to: after completing the encoding of all stages, input the feature sequences of each stage, which have been pruned and restored to the original number of image blocks, into the streamlined edge detector, and generate the final edge prediction map through multi-scale feature fusion and linear projection. The streamlined edge detector uses the image encoder as the backbone network and removes its original cue decoder and mask generation module.

9. A computer device, characterized in that, include: Processor and computer-readable storage media; A processor, adapted to execute computer programs; A computer-readable storage medium storing a computer program that, when executed by the processor, implements the adaptive multi-stage non-edge pruning method for image edge detection as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program adapted to be loaded by a processor and executed as described in any one of claims 1 to 7: an adaptive multi-stage non-edge pruning method for image edge detection.