Edge-aware lightweight image segmentation method, electronic device and storage medium
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-20
- Publication Date
- 2026-08-14
AI Technical Summary
针对大面积连续区域,小卷积核易将其分割为离散纹理碎片,出现分割不连续、区域破碎化问题;若盲目增大卷积核或堆叠层数,又会导致参数量与计算量暴涨,失去轻量化特性
[0045]1.在保持轻量化特性的同时实现大感受野能力。通过非对称参数平衡策略重构倒残差模块,以削减通道冗余的方式换取空间感受野的扩展,在大幅降低模型参数量与计算量的同时,有效解决了现有轻量级网络因感受野不足导致的大面积连续区域分割破碎化问题,更适配算力受限的边缘端与移动端部署。
Smart Images

Figure CN122574007A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image data processing technology, specifically to a lightweight image segmentation method with edge awareness, an electronic device, and a storage medium. Background Technology
[0002] Image segmentation is one of the core technologies in the field of image data processing. It aims to divide and locate regions of an input image at the pixel level, providing fundamental support for downstream tasks such as region analysis, quantitative analysis, and decision control. In resource-constrained mobile terminals and edge computing scenarios, lightweight segmentation networks have become a core requirement for the engineering implementation of visual tasks. However, existing methods still suffer from the following common technical shortcomings in practical applications:
[0003] First, balancing receptive field and model lightweighting is difficult. Existing lightweight networks mostly use 3×3 depthwise convolutions as the basic operator, achieving lightweighting by compressing the number of channels and network depth, but the effective receptive field is limited to local areas. For large continuous regions, small convolution kernels easily segment them into discrete texture fragments, resulting in discontinuous segmentation and region fragmentation. On the other hand, blindly increasing the number of convolution kernels or stacking layers will lead to a surge in the number of parameters and computation, losing the lightweight characteristics.
[0004] Second, edge segmentation accuracy is insufficient in complex backgrounds. Existing lightweight models mostly rely on channel or spatial attention to enhance structured features, without explicitly modeling the segmentation boundaries. In scenes with complex background textures, uneven lighting, and low contrast between foreground and background, the segmentation results generally suffer from edge blurring, boundary adhesion, and contour distortion, directly affecting the accuracy of subsequent quantitative analysis.
[0005] Third, cross-layer feature fusion suffers from feature gaps. Classic encoder-decoder architectures often employ a direct, skip-connection approach. While shallow features contain rich location and detail information, they also carry significant background noise; deep features are highly abstract but have low resolution. Direct concatenation introduces shallow noise into deep features, interfering with the distinction between foreground and background. Furthermore, simple interpolation and upsampling easily lead to loss of detail and jagged edges, making it difficult to achieve accurate alignment and efficient fusion of shallow and deep features.
[0006] The aforementioned algorithmic limitations are further amplified in engineering scenarios such as crop lesion segmentation and industrial part defect detection: the large scale differences of the regions to be segmented, the abundance of background interference, and the limited computing power of deployed equipment place higher demands on the lightweight design, edge accuracy, and multi-scale adaptability of segmentation algorithms. Therefore, how to maintain model lightweightness while simultaneously ensuring edge segmentation accuracy and multi-scale adaptability has become a pressing technical problem to be solved in this field. Summary of the Invention
[0007] The purpose of this section is to outline some aspects of the embodiments of the present invention and to briefly describe some preferred embodiments. Simplifications or omissions may be made in this section, as well as in the abstract and title of this application, to avoid obscuring the purpose of these documents; however, such simplifications or omissions should not be construed as limiting the scope of the invention.
[0008] To address the aforementioned technical problems, according to one aspect of the present invention, the present invention provides the following technical solution: a lightweight image segmentation method with edge awareness, comprising the following steps:
[0009] Obtain the target image to be processed;
[0010] The target image is input into the trained EdgeLite segmentation network for processing, and the pixel-level segmentation result of the region of interest is output.
[0011] The EdgeLite segmentation network adopts an encoder-decoder architecture;
[0012] The encoder is composed of multiple large-kernel inverse residual modules MBConv cascaded together. Each MBConv module adopts an asymmetric parameter balancing strategy, with the channel expansion factor set to 1.5 and the depth convolution kernel size set to 5×5.
[0013] Each stage of the encoder is embedded with a bidirectional coordinate attention module (DD-CA) for synchronously enhancing feature region localization and edge feature extraction.
[0014] A spatial and context module (SACM) is set between the end of the encoder and the input of the decoder to aggregate multi-scale context information through multi-branch dilated convolution.
[0015] The encoder and decoder are connected across layers via a lightweight cross-scale fusion module (LCSF) to filter shallow noise and achieve accurate alignment and fusion of shallow and deep features.
[0016] As a preferred embodiment of the edge-aware lightweight image segmentation method described in this invention, the processing flow of the large kernel inverse residual module MBConv includes:
[0017] The input feature map is first subjected to low-dimensional expansion via 1×1 convolution, with a channel expansion factor of 1.5;
[0018] Then, spatial features are extracted using 5×5 depth convolution to capture the overall morphological features of large-scale targets;
[0019] Finally, a 1×1 convolution is performed for linear projection, mapping the feature channels back to the original dimensions. No activation function is used in the projection process.
[0020] As a preferred embodiment of the edge-aware lightweight image segmentation method described in this invention, the computational complexity of the large kernel inverse residual module MBConv satisfies:
[0021]
[0022] Where H and W are the height and width of the feature map, respectively, C is the number of input channels, t is the expansion factor, and K is the kernel size.
[0023] As a preferred embodiment of the edge-aware lightweight image segmentation method described in this invention, the bidirectional coordinate attention module DD-CA adopts a dual-stream parallel structure of feature stream and edge stream, and the processing includes:
[0024] Feature Flow Branch: After the input features are extracted by the two-level cascaded MBConv module, they are encoded by one-dimensional pooling along the horizontal and vertical directions respectively through the coordinate attention mechanism to generate direction-aware attention weights. The features are then weighted element by element to obtain structured enhanced features.
[0025] Edge flow branch: After the input features are projected by 1×1 convolution, low-frequency background features are extracted by average pooling. The projected features are then compared with the low-frequency features to extract high-frequency edge features.
[0026] Then, depthwise convolution and sigmoid activation are used to generate an edge weight map, resulting in edge enhancement features;
[0027] The structured enhancement features, original projection features, and edge enhancement features are fused element by element, and the final output of the DD-CA module is obtained after ReLU activation.
[0028] As a preferred embodiment of the edge-aware lightweight image segmentation method described in this invention, the Spatial and Context Module (SACM) adopts a four-branch parallel structure, and the processing includes:
[0029] The first branch uses 1×1 convolution to preserve pixel-level local detail features;
[0030] The second branch uses a 3×3 standard convolution with an inflation rate of 1 to extract short-range contextual features.
[0031] The third branch uses a 3×3 dilated convolution with an inflation rate of 3 to extract mid-range contextual features and expand the receptive field.
[0032] The fourth branch uses global average pooling to extract global statistical features, which are then upsampled to the original size after being compressed through a 1×1 convolution.
[0033] The output features of the four branches are concatenated along the channel dimension, fused and reduced in dimensionality by 1×1 convolution, and then batch normalized. The residuals are added to the input features, and the module output is obtained by ReLU activation.
[0034] As a preferred embodiment of the edge-aware lightweight image segmentation method described in this invention, the processing procedure of the lightweight cross-scale fusion module LCSF includes:
[0035] The shallow skip features from the encoder and the deep upsampled features from the decoder are received respectively. The two features are then weighted by a channel attention filter (CAF) to suppress irrelevant noise channels.
[0036] Scale alignment is performed on the filtered shallow features: first, the resolution is adjusted by bilinear interpolation, and then nonlinear transformation is performed by depthwise separable convolution to repair interpolation distortion.
[0037] The aligned shallow features and deep features are added element by element, and then integrated by a lightweight fusion unit composed of depthwise separable convolutions to output the fused feature map.
[0038] As a preferred embodiment of the edge-aware lightweight image segmentation method described in this invention, the EdgeLite segmentation network is trained using a hybrid loss function;
[0039] The hybrid loss function is a weighted combination of DiceLoss and FocalLoss, and the total loss formula is:
[0040]
[0041] in, Used to optimize the overlap between the predicted region and the true label, thus alleviating the problem of imbalanced samples; It is used to reduce the weight of easily classified samples and strengthen the learning of difficult-to-classify samples such as segmentation edges and small targets; These are the weighting coefficients.
[0042] An electronic device includes a processor; and a memory communicatively connected to the processor, the memory storing computer-executable instructions, the processor executing the computer-executable instructions, the computer-executable instructions, when executed by the processor, implementing the steps of an edge-aware lightweight image segmentation method.
[0043] A computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement a lightweight image segmentation method with edge awareness.
[0044] Compared with the prior art, the beneficial effects of the present invention are:
[0045] 1. Achieving a large receptive field while maintaining lightweight characteristics. By reconstructing the inverse residual module through an asymmetric parameter balancing strategy, the spatial receptive field is expanded by reducing channel redundancy. This significantly reduces the number of model parameters and computational cost, while effectively solving the problem of fragmentation of large continuous regions caused by insufficient receptive field in existing lightweight networks, making it more suitable for edge and mobile deployments with limited computing power.
[0046] 2. Significantly improved edge segmentation accuracy. The bidirectional coordinate attention module explicitly models the boundary to be segmented through a dual-stream design of feature localization and edge enhancement, effectively improving the edge blurring and boundary adhesion problems that are common in existing methods in complex backgrounds and low-contrast scenes. The segmentation contour fits the actual region boundary better.
[0047] 3. Enhanced multi-scale region adaptation capability. The spatial and context module aggregates multi-granularity context information from pixel level to global through a four-branch parallel structure. It not only preserves the detailed features of small regions, but also captures the global structure of large foreground regions. This solves the inherent problem of existing methods that cannot take into account different scale regions due to a fixed receptive field, and has stable performance for segmentation objects of different scales.
[0048] 4. Higher efficiency in cross-layer feature fusion. The lightweight cross-scale fusion module alleviates the feature gap between shallow and deep layers through noise filtering, precise spatial alignment, and residual fusion, reduces the interference of shallow noise on deep features, and significantly reduces computational redundancy compared to traditional stitching fusion.
[0049] 5. High versatility and wide range of applications. This invention is a general-purpose image segmentation algorithm, not limited to specific application areas. It can be directly transferred and applied to various image segmentation scenarios requiring lightweight deployment, such as crop lesion segmentation, industrial surface defect detection, and medical image segmentation, showing great potential for engineering implementation. Attached Figure Description
[0050] To more clearly illustrate the technical solutions of the embodiments of the present invention, the present invention will be described in detail below with reference to the accompanying drawings and detailed embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. Wherein:
[0051] Figure 1 This is a flowchart of the edge-aware lightweight image segmentation method of the present invention;
[0052] Figure 2 This is a schematic diagram of the overall architecture of the EdgeLite segmentation network of the present invention;
[0053] Figure 3 This is a schematic diagram of the structure of the large-core inverted residual module MBConv of the present invention;
[0054] Figure 4 This is a schematic diagram of the bidirectional coordinate attention module DD-CA of the present invention;
[0055] Figure 5 This is a schematic diagram of the spatial and contextual module (SACM) of the present invention;
[0056] Figure 6 This is a schematic diagram of the lightweight cross-scale fusion module LCSF of the present invention;
[0057] Figure 7 Examples of maize disease images and annotations are provided for embodiments of the present invention.
[0058] Figure 8 This is a schematic diagram of the convergence curve during the model training process of the present invention;
[0059] Figure 9 This is a schematic diagram comparing the feature heatmaps of different attention modules in this invention;
[0060] Figure 10 This is a visual comparison of the image segmentation results of different models in this invention. Detailed Implementation
[0061] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
[0062] Secondly, the present invention is described in detail with reference to the schematic diagrams. When detailing the embodiments of the present invention, for ease of explanation, the cross-sectional views illustrating the device structure may be partially enlarged, not according to the usual scale. Furthermore, the schematic diagrams are merely examples and should not limit the scope of protection of the present invention. In addition, actual fabrication should include three-dimensional spatial dimensions of length, width, and depth.
[0063] To make the objectives, technical solutions, and advantages of the present invention clearer, the embodiments of the present invention will be described in further detail below with reference to the accompanying drawings.
[0064] Example 1:
[0065] This embodiment provides an edge-aware lightweight image segmentation method, and the specific implementation process is as follows:
[0066] First, the input image to be processed is obtained, and the image is preprocessed to normalize its size to a preset resolution;
[0067] The preprocessed input image is then fed into the trained EdgeLite segmentation network. After feature extraction, multi-scale context aggregation, and decoding recovery are completed layer by layer, the network outputs a pixel-level segmentation mask for the region of interest.
[0068] The EdgeLite segmentation network adopts an encoder-decoder U-shaped architecture, such as... Figure 2 As shown, the encoder includes a four-level downsampling stage, used to extract multi-dimensional features and compress spatial dimensions step by step, while the decoder has a corresponding four-level upsampling stage, used to gradually restore feature resolution and generate the final segmentation result. Each feature extraction stage at the encoder end embeds a bidirectional coordinate attention module, and a spatial and context module is set between the encoder end and the decoder input end. Corresponding layers of the encoder and decoder are connected across layers through a lightweight cross-scale fusion module.
[0069] The basic computational unit for each stage of the encoder described above is the large-core inverse residual module MBConv, such as... Figure 3 As shown, this module addresses the limitations of traditional lightweight inverse residual structures, such as limited receptive field and high channel redundancy, by employing an asymmetric parameter balancing strategy for reconstruction. Let the input feature map size be H×W, the number of channels be C, the channel expansion factor be t, and the depthwise convolution kernel size be K. Then, the total computational cost of the inverse residual module under the depthwise separable convolutional architecture can be approximately expressed as:
[0070]
[0071] In the traditional MobileNetV2 standard configuration, with an expansion factor t=6 and a kernel size K=3, substituting into the formula, we can obtain that the total computational cost is proportional to 12C+54;
[0072] This invention compresses the expansion factor to t=1.5 while increasing the depthwise convolution kernel to K=5. After substituting these values, the total computational cost is proportional to 3C+37.5. Comparison shows that although the computational cost of the depthwise convolution increases with the kernel size, the redundancy of channel computation in the upscaling and projective convolutions is reduced by approximately 75%, significantly lowering the overall computational cost of the module. Simultaneously, the spatial receptive field is effectively expanded, enabling it to overcome textural differences within the target and directly capture the overall shape and boundary relationships of large, continuous regions, alleviating the segmentation fragmentation problem caused by small convolution kernels.
[0073] The computational process of a single large-core inverted residual module MBConv consists of three steps:
[0074] The input feature map is first subjected to a 1×1 convolution to achieve a low-magnification channel upscaling of 1.5 times, followed by batch normalization (BN) and ReLU6 activation functions;
[0075] Then, spatial dimension features are extracted through 5×5 depth convolution, followed by batch normalization (BN) and ReLU6 activation functions.
[0076] Finally, a linear projection is performed through a 1×1 convolution to map the number of feature channels back to the original dimension of the input. No activation function is set during the projection stage to avoid the collapse of the feature manifold in the low-dimensional feature space and ensure the lossless transmission of feature information.
[0077] Each feature extraction stage of the encoder embeds a bidirectional coordinate attention module (DD-CA), such as Figure 4 As shown, this module adopts a dual-stream parallel structure of feature stream and edge stream, which can simultaneously realize feature localization and boundary feature enhancement of the region of interest without introducing too much computational overhead.
[0078] In the feature flow branch, the input features First, basic feature extraction is completed through two cascaded MBConv modules. Then, a coordinate attention mechanism is introduced to decompose the traditional global pooling into two independent one-dimensional pooling encoding processes in the horizontal and vertical directions.
[0079] For the c-th channel, the feature output at height h is:
[0080]
[0081] The feature output at width w is:
[0082]
[0083] The feature maps from the two orientation-aware paths are concatenated, transformed by a shared 1×1 convolution, then segmented along the channel dimension and activated by a sigmoid function to generate attention weight vectors for the horizontal and vertical directions, respectively. and Ultimately, semantically enhanced features are obtained:
[0084]
[0085] This process establishes long-distance spatial dependencies through bidirectional one-dimensional encoding, which can accurately locate the main region, and the computational cost is far lower than that of the global spatial attention mechanism.
[0086] The edge flow branch is used to explicitly extract high-frequency features of the segmentation boundary. The input features are first processed by a 1×1 convolution and a batch normalization layer to complete channel adjustment, resulting in projected features. ;
[0087] Subsequently, the projected features were smoothed using 3×3 average pooling to extract low-frequency background features. ;
[0088] By performing a difference operation between the projected features and the low-frequency smoothed features, high-frequency edge features containing only regions of abrupt gray-level changes are obtained:
[0089]
[0090] The generated high-frequency edge features are further processed by 3×3 depthwise convolution, batch normalization, and sigmoid activation function to generate an edge weight map. This is used to filter effective boundary features and suppress false gradients caused by noise. Finally, the DD-CA module fuses the structured enhancement features, original projection features, and edge enhancement features element-wise, and outputs the result after ReLU activation:
[0091]
[0092] In the formula This indicates element-wise multiplication. The fusion structure simultaneously enhances the integrity of the main body and the clarity of boundary details of the region to be divided, achieving synergistic optimization of macroscopic form and microscopic edge.
[0093] A Space and Context Module (SACM) is located between the encoder end and the decoder input end, such as... Figure 5 As shown, this module uses a four-branch parallel structure to aggregate multi-granularity context information, making up for the information loss of small targets during multi-level downsampling.
[0094] Input features are denoted as The four branches perform feature extraction at different scales: the first branch is a local branch, which uses 1×1 convolution operation to model only the pixel-level correlation between channels, retaining the finest local features and protecting the core information of tiny targets;
[0095] The second branch is the short-range context branch, which uses a standard 3×3 convolution with an inflation rate of 1 to extract the local texture of the target and the short-range edge dependency.
[0096] The third branch is the mid-range context branch, which uses a 3×3 dilated convolution with an inflation rate of 3. Without increasing the number of parameters, the effective receptive field is expanded to 7×7, which can perceive the contrast relationship between the region of interest and the surrounding healthy background. The output is denoted as .
[0097] The fourth branch is the global prior branch, which extracts image-level background prior information through global average pooling. After compressing the channel dimension through 1×1 convolution, it is restored to the original feature size through bilinear interpolation upsampling, providing global illumination and overall background constraints for segmentation.
[0098] The output features of the four branches are concatenated along the channel dimension to obtain the concatenated features. Subsequently, 1×1 convolution is used to complete the fusion dimensionality reduction and batch normalization processing to obtain the fused features. Finally, the fused features are added to the original input features using residuals, and then activated by ReLU to obtain the module output.
[0099]
[0100] The design of residual connections ensures stable gradient propagation and enables the network to adaptively retain effective information from the original input, ensuring that regions to be segmented at different scales can obtain appropriate receptive field support.
[0101] The encoder and decoder, at corresponding layers, achieve cross-layer feature connections through the Lightweight Cross-Scale Fusion Module (LCSF), such as... Figure 6 As shown, this replaces the traditional direct splicing skip connection method, alleviating the feature gap between deep and shallow features.
[0102] This module first performs channel attention filtering on the two input features, which are shallow skip features from the encoder. With deep upsampled features from the decoder ;
[0103] For any input feature F, the channel attention filter first generates channel descriptors through global average pooling, and then generates channel weight vectors through two layers of 1×1 convolution, batch normalization, and the Sigmoid activation function:
[0104]
[0105] The generated weight vector is multiplied element-wise with the original features to complete channel reweighting.
[0106]
[0107] This process can suppress background noise channels in shallow features that are irrelevant to the region to be segmented, and select effective features to participate in subsequent fusion.
[0108] After channel filtering, the module performs scale-accurate alignment on the higher-resolution shallow features: first, it adjusts the resolution of the shallow features to match that of the deep features through bilinear interpolation, and then performs a non-linear transformation through depthwise separable convolution to repair the edge blurring and spectral aliasing effects caused by the interpolation operation, achieving pixel-level spatial alignment of deep and shallow features.
[0109]
[0110] The aligned shallow and deep features are fused element-wise, replacing the traditional channel concatenation operation, which significantly reduces the computational cost of the fusion stage. The fused features are further fed into lightweight hybrid units composed of depthwise separable convolutions for feature integration, and finally output as a fused feature map.
[0111]
[0112] This fusion approach enables the network to learn the residual completion relationship between shallow details and deep features, which not only alleviates the semantic gap but also reduces the transmission of shallow noise to deep features.
[0113] The EdgeLite segmentation network is trained using a weighted combination of DiceLoss and FocalLoss loss functions to adapt to segmentation scenarios where the target proportion is low and the edges are difficult to classify.
[0114] DiceLoss directly optimizes the overlap between the predicted region and the true label, and is naturally robust to imbalanced positive and negative samples. Its expression is:
[0115]
[0116] In the formula The pixel probability predicted by the model. The actual label pixel value, To prevent smooth terms with a denominator of zero.
[0117] FocalLoss introduces a modulation factor on top of cross-entropy loss, reducing the weight of easily classified samples and forcing the model to focus on difficult-to-classify samples such as target edges and small targets. Its expression is:
[0118]
[0119] In the formula This represents the predicted probability for the corresponding category. As a class balance factor, For focusing parameters.
[0120] The total loss function is a weighted combination of the two types of losses:
[0121]
[0122] Weight coefficients during training A value of 0.5 was chosen to balance the effects of the two types of losses, achieving synergistic optimization of overall segmentation accuracy and edge detail quality. The network was trained using the Adam optimizer with an initial learning rate of 1e-4. A cosine annealing strategy was used to adjust the learning rate, and the total number of training epochs was set to 200 until the model converged.
[0123] Example 2:
[0124] This embodiment uses maize leaf lesion segmentation as an application scenario to experimentally verify the effectiveness of the above image segmentation method. An example of the dataset used in the experiment is shown below. Figure 7The images shown are maize disease images collected in a real field environment. Collected from the field test area, the images cover four common maize foliage diseases: rust, large leaf spot, gray leaf spot, and leaf spot, totaling 1200 original images. The dataset employs a hierarchical random partitioning strategy, dividing the dataset into training, validation, and test sets in an 8:1:1 ratio to ensure consistent distribution of disease samples across subsets. All images are uniformly scaled to a resolution of 512×512 pixels, and pixel-level masks are used to annotate diseased areas. The annotation results are cross-validated by two researchers to ensure accuracy. The training set employs offline data augmentation strategies, including random scaling, horizontal and vertical flipping, random rotation, Gaussian blur, and color gamut transformation, expanding the training samples to 4800 images to improve the model's generalization ability. The validation and test sets retain their original image states without any augmentation.
[0125] The convergence curve of the model training process is as follows: Figure 8 As shown, with the increase of training rounds, the training loss and validation loss decrease steadily in tandem, the average intersection-over-union ratio continues to increase, the curve tends to be stable in the later stage of training, and the difference between the training loss and validation loss is small, indicating that the model converges sufficiently and does not show obvious overfitting, and the generalization performance is good.
[0126] Feature heatmaps of different attention modules, for example Figure 9 As shown, compared with conventional attention modules such as channel attention (SE), convolutional block attention (CBAM), and coordinate attention (CA), the attention weights generated by the DD-CA proposed in this invention are more concentrated on the lesion region to be segmented, resulting in sharper edge responses and less interference from background noise. This verifies the design advantages of the dual-stream structure in region localization and edge perception.
[0127] The experiment selected three classic high-precision segmentation models—U-shaped network, DeepLabV3+, and PSPNet—as well as two mainstream lightweight real-time segmentation models—SegFormer and BiSeNetV2—for comparison. Average Intersection over Union (mIoU), precision, and recall were used as evaluation metrics for segmentation accuracy, while parameter count and floating-point operations (FLOPs) were used as evaluation metrics for lightweighting. All models were tested under the same hardware and software environment and training strategy. The experimental results are shown in the table below.
[0128]
[0129] Visualization of segmentation results from different models, for example Figure 10As shown, the method of the present invention can achieve accurate and complete pixel-level segmentation for both scattered small lesions and long strip-shaped large lesions, with clear and sharp segmentation edges and no background missegmentation or contour deformation. The comparison models all have varying degrees of edge blurring, missing segmentation of small lesions, and background missegmentation, which intuitively demonstrates the advantages of the present method in complex scenes.
[0130] Experimental results show that the method of this invention achieves an mIoU of 90.28%, which is 2.66 percentage points higher than the best-performing comparison model, DeepLabV3+. Precision and recall are also among the best of all comparison models. In terms of lightweight performance, the model of this invention has only 1.61M parameters, approximately 4.3% of DeepLabV3+, and its computational cost is far lower than that of classic high-precision models, achieving the dual benefits of significantly improved segmentation accuracy and extreme model compression. Those skilled in the art will understand that the technical solution of this invention is not limited to corn lesion segmentation; it can be directly applied to similar image segmentation tasks such as industrial surface defect detection and medical image segmentation without any creative effort, and all fall within the scope of protection of this invention.
[0131] Example 3:
[0132] This embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the edge-aware lightweight image segmentation method described in Embodiment 1. This electronic device can be any device with computing capabilities, such as a smartphone, embedded computing terminal, industrial vision inspection equipment, or agricultural plant protection airborne equipment, and can be deployed at the edge to perform real-time image segmentation tasks.
[0133] This embodiment also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the aforementioned edge-aware lightweight image segmentation method. The storage medium may include various media capable of storing program code, such as a USB flash drive, external hard drive, read-only memory, random access memory, magnetic disk, and optical disk.
[0134] Although the present invention has been described above with reference to embodiments, various modifications can be made and components can be replaced with equivalents without departing from the scope of the invention. In particular, as long as there is no structural conflict, the features in the disclosed embodiments can be combined with each other in any manner. The lack of an exhaustive description of these combinations in this specification is merely for the sake of brevity and resource conservation. Therefore, the present invention is not limited to the specific embodiments disclosed herein, but includes all technical solutions falling within the scope of the claims.
Claims
1. A lightweight image segmentation method with edge awareness, characterized in that, Includes the following steps: Obtain the target image to be processed; The target image is input into the trained EdgeLite segmentation network for processing, and the pixel-level segmentation result of the region of interest is output. The EdgeLite segmentation network adopts an encoder-decoder architecture; The encoder is composed of multiple large-kernel inverse residual modules MBConv cascaded together. Each MBConv module adopts an asymmetric parameter balancing strategy, with the channel expansion factor set to 1.5 and the depth convolution kernel size set to 5×5. Each stage of the encoder is embedded with a bidirectional coordinate attention module (DD-CA) for synchronously enhancing feature region localization and edge feature extraction. A spatial and context module (SACM) is set between the end of the encoder and the input of the decoder to aggregate multi-scale context information through multi-branch dilated convolution. The encoder and decoder are connected across layers via a lightweight cross-scale fusion module (LCSF) to filter shallow noise and achieve accurate alignment and fusion of shallow and deep features.
2. The edge-aware lightweight image segmentation method according to claim 1, characterized in that, The processing flow of the large-core inverted residual module MBConv includes: The input feature map is first subjected to low-dimensional expansion via 1×1 convolution, with a channel expansion factor of 1.5; Then, spatial features are extracted using 5×5 depth convolution to capture the overall morphological features of large-scale targets; Finally, a 1×1 convolution is performed for linear projection, mapping the feature channels back to the original dimensions. No activation function is used in the projection process.
3. The edge-aware lightweight image segmentation method according to claim 2, characterized in that, The computational complexity of the large-core inverse residual module MBConv satisfies: Where H and W are the height and width of the feature map, respectively, C is the number of input channels, t is the expansion factor, and K is the kernel size.
4. The edge-aware lightweight image segmentation method according to claim 1, characterized in that, The bidirectional coordinate attention module DD-CA adopts a dual-stream parallel structure of feature stream and edge stream, and the processing includes: Feature Flow Branch: After the input features are extracted by the two-level cascaded MBConv module, they are encoded by one-dimensional pooling along the horizontal and vertical directions respectively through the coordinate attention mechanism to generate direction-aware attention weights. The features are then weighted element by element to obtain structured enhanced features. Edge flow branch: After the input features are projected by 1×1 convolution, low-frequency background features are extracted by average pooling. The projected features are then compared with the low-frequency features to extract high-frequency edge features. Then, depthwise convolution and sigmoid activation are used to generate an edge weight map, resulting in edge enhancement features; The semantic enhancement features, original projection features, and edge enhancement features are fused element by element, and the final output of the DD-CA module is obtained after ReLU activation.
5. The edge-aware lightweight image segmentation method according to claim 1, characterized in that, The Space and Context Module (SACM) adopts a four-branch parallel structure, and the processing includes: The first branch uses 1×1 convolution to preserve pixel-level local detail features; The second branch uses a 3×3 standard convolution with an inflation rate of 1 to extract short-range contextual features. The third branch uses a 3×3 dilated convolution with an inflation rate of 3 to extract mid-range contextual features and expand the receptive field. The fourth branch uses global average pooling to extract global statistical features, which are then upsampled to the original size after being compressed through a 1×1 convolution. The output features of the four branches are concatenated along the channel dimension, fused and reduced in dimensionality by 1×1 convolution, and then batch normalized. The residuals are added to the input features, and the module output is obtained by ReLU activation.
6. The edge-aware lightweight image segmentation method according to claim 1, characterized in that, The processing steps of the Lightweight Cross-Scale Fusion Module (LCSF) include: The shallow skip features from the encoder and the deep upsampled features from the decoder are received respectively. The two features are then weighted by a channel attention filter (CAF) to suppress irrelevant noise channels. Scale alignment is performed on the filtered shallow features: first, the resolution is adjusted by bilinear interpolation, and then nonlinear transformation is performed by depthwise separable convolution to repair interpolation distortion. The aligned shallow features and deep features are added element by element, and then integrated by a lightweight fusion unit composed of depthwise separable convolutions to output the fused feature map.
7. The edge-aware lightweight image segmentation method according to claim 1, characterized in that, The EdgeLite segmentation network is trained using a hybrid loss function. The hybrid loss function is a weighted combination of DiceLoss and FocalLoss, and the total loss formula is: in, Used to optimize the overlap between the predicted region and the true label, thus alleviating the problem of imbalanced samples; It is used to reduce the weight of easily classified samples and strengthen the learning of difficult-to-classify samples such as segmentation edges and small targets; These are the weighting coefficients.
8. An electronic device, characterized in that, The method includes a processor; and a memory communicatively connected to the processor, the memory storing computer-executable instructions, the processor executing the computer-executable instructions, which, when executed by the processor, implement the steps of the edge-aware lightweight image segmentation method according to any one of claims 1 to 7.
9. A computer-readable storage medium storing computer-executable instructions, characterized in that, When executed by a processor, the computer-executable instructions implement the edge-aware lightweight image segmentation method according to any one of claims 1 to 7.