Urban streetscape real-time instance segmentation method based on lightweight attention

By introducing focused linear attention modules and deep convolutions into real-time instance segmentation of urban street scenes, the real-time and accuracy problems of traditional models in environments with limited computing resources are solved, and efficient real-time instance segmentation in autonomous driving systems is achieved.

CN118644672AActive Publication Date: 2024-09-13HANGZHOU DIANZI UNIV

Patent Information

Application Number
CN202410768062.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-14
Publication Date
2024-09-13
Estimated Expiration
2044-06-14

AI Technical Summary

Technical Problem

Existing real-time instance segmentation technology for urban street scenes is difficult to meet the real-time and accuracy requirements in autonomous driving systems and smart city environments with limited computing resources. Traditional convolutional neural networks and Transformer models perform poorly in this scenario.

Method used

A real-time instance segmentation method for urban street scenes based on lightweight attention is adopted, which is integrated with the focused linear attention module, adjusts the feature directions of queries and keys through a mapping function, and is combined with a deep convolution module to reduce computational complexity and improve the model's performance on instance segmentation targets. Focus ability.

Benefits of technology

While maintaining representation capabilities, it significantly reduces the computational complexity of the attention mechanism, enabling efficient real-time instance segmentation on edge devices such as autonomous driving, balancing performance and speed, and is suitable for resource-constrained environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118644672A
    Figure CN118644672A
Patent Text Reader

Abstract

The invention discloses an urban street scene real-time instance segmentation method based on lightweight attention. The method comprises the following steps: step 1, reading an urban street scene data set and carrying out preprocessing and data enhancement; 2, taking the image processed in the step 1 as input, performing feature extraction through a backbone network, and outputting a feature map; step 3, inputting the feature map into a focusing linear attention module with a focusing function to further extract features so as to focus the features on a target instance; step 4, fusing the feature map extracted by the focusing attention module and the feature maps of different sizes extracted by the backbone network; and step 5, obtaining a detection branch and a mask branch based on the decoupling head, respectively inputting the fused features into the detection branch and the mask branch to obtain a detection result and a segmentation mask, and finally synthesizing the detection result and the segmentation mask to obtain an instance segmentation result of the target. Compared with a traditional pure convolutional neural network and a Transform model, the performance and the speed are effectively balanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image instance segmentation, and in particular to a real-time instance segmentation method for urban street scenes based on lightweight attention. Background Art

[0002] Image segmentation technology is crucial to the development of autonomous driving and smart cities. By integrating advanced perception, decision-making and execution technologies, autonomous driving systems enable vehicles to adapt to various complex traffic environments in real time and accurately identify and separate various objects in the city (such as vehicles, pedestrians, etc.). This technology not only improves the environmental perception ability of autonomous driving vehicles, but also plays an important role in the intelligent monitoring and traffic management of smart cities. By identifying objects such as pedestrians and vehicles, it improves the accuracy and response speed of monitoring, optimizes traffic flow management, and reduces traffic congestion. However, the existing urban street scene instance segmentation technology faces many challenges. For example, the complexity of the urban environment, the computing performance of the equipment, and other issues have put forward higher requirements on the accuracy, efficiency, and robustness of the algorithm.

[0003] Traditional instance segmentation usually adopts a two-stage approach: first detect the target bounding box, and then perform pixel-level segmentation within the box. Although models such as Mask R-CNN are highly accurate, they are slow. To improve real-time performance, some works reduce the number of network layers and parameters, but this will significantly reduce segmentation accuracy. In recent years, the success of the Transformer architecture in visual tasks has introduced the attention mechanism into the instance segmentation task. This is because the Transformer relies on the self-attention mechanism, which requires pairwise comparisons of all elements in the input sequence, which in the image means that each pixel must interact with all other pixels in the image, resulting in a significant increase in the amount of computation. Some methods use the attention mechanism to replace the convolution operation for instance segmentation, and use a learnable query to directly predict the object category and mask in a single-stage approach. For example, Mask2Former relies on a complex decoder layer and pixel decoder, and its mask attention may limit the receptive field of the query, affecting efficiency. Although Mask2Former has shown good performance, the model requires large computational resources when performing instance segmentation, and cannot meet the needs of real-time instance segmentation applications in urban street scenes.

[0004] Therefore, in urban street scene scenarios such as autonomous driving systems and smart cities, the computing resources of most devices are limited, and more efficient model design is needed to ensure real-time instance segmentation of images in embedded or resource-constrained environments. Summary of the invention

[0005] The present invention aims at the challenges of low accuracy and inability to meet real-time requirements in real-time instance segmentation in urban street scenes of traditional convolutional neural networks and Transformer architecture models, and proposes a real-time instance segmentation method for urban street scenes based on lightweight attention. Compared with traditional pure convolutional neural networks and simple Transformer models, it effectively balances performance and speed. The method integrates a focused linear attention module into the traditional convolutional neural network, which includes linear attention. While maintaining the core functions of the attention mechanism, it improves computational efficiency. The module adjusts the feature directions of the query and key through a mapping function to make the attention weight more obvious, thereby enhancing the model's ability to focus on the instance segmentation target.

[0006] In order to solve the above technical problems, the technical solution of the present invention is:

[0007] A real-time instance segmentation method for urban street scenes based on lightweight attention includes the following steps:

[0008] Step 1: Read the urban street view dataset and perform preprocessing and data enhancement;

[0009] Step 2: The image processed in step 1 is used as input, and features are extracted through a backbone network to output a feature map, wherein the backbone network includes a 3×3 convolution kernel and a C2f module;

[0010] Step 3: The feature map is input into a focused linear attention module with a focusing function to further extract features so that it focuses on the target instance;

[0011] Step 4: Fusing the feature map extracted by the focus attention module with the feature maps of different sizes extracted by the backbone network;

[0012] Step 5: Based on the decoupling head, the detection branch and the mask branch are obtained, and the fused features are input into the detection branch and the mask branch respectively to obtain the detection result and the segmentation mask. Finally, the detection result and the segmentation mask are synthesized to obtain the instance segmentation result of the target.

[0013] Preferably, the preprocessing method includes performing a letterbox scaling operation on the urban street view dataset and unifying the image size to 640×640.

[0014] In the above technical solution, the long side of the image is first scaled to 640, and then the short side is scaled proportionally. If it cannot be scaled, the excess part is rounded up to fill. This operation is used to maintain the aspect ratio of the original image and ensure that the image is not distorted.

[0015] Preferably, the data enhancement method includes HSV enhancement, MixUp enhancement, and flipping. In the above technical solution, HSV enhancement is used to enhance the visual features of the image, and MixUp enhancement and flipping are used to enhance the diversity of the data and improve the generalization ability of the model.

[0016] Preferably, the backbone network mainly uses convolutional layers and C2f modules as basic building blocks.

[0017] The C2f module makes the network more lightweight while maintaining the idea of ​​Cross Stage Partial. This module divides the feature extraction process into two stages: compression and expansion. In the compression stage, the input feature map is reduced in dimension through convolution operations to reduce the amount of calculation; in the expansion stage, the feature map is restored to its original size through convolution and upsampling operations, and feature fusion is performed. This design not only ensures the effectiveness of feature extraction, but also reduces the computational complexity while obtaining richer gradient flow information.

[0018] Preferably, the focusing function is to introduce a mapping function f for focusing capability. p , the expression is as follows:

[0019] φ p (x) = f p (ReLU(x))

[0020]

[0021] Among them, x **p Represents x element-wise to the power p and uses the ReLU function to ensure the non-negativity of the input and the validity of the denominator.

[0022] In the above technical solution, the mapping function simulates the original Softmax attention to focus on the information-rich area: by adjusting the direction of each query and key feature, similar query-key pairs are brought closer and dissimilar query-key pairs are pulled apart.

[0023] The focused linear attention module method first includes a novel mapping function to simulate the original Softmax attention to focus on information-rich areas. On this basis, the low-rank dilemma in the ordinary linear attention module is paid attention to, and deep convolution is used to restore feature diversity. In this way, the focused linear attention module can have both linear complexity and high feature representation ability.

[0024] Preferably, a deep convolution module is integrated into the attention matrix of the focused linear attention module, and the final focused linear attention module can be expressed as:

[0025]

[0026] Where Sim(Q,K) is the similarity function, φ p is the focusing function, DWC is the deep convolution module, Q, K, Refers to query, key, and value respectively.

[0027] In the above technical solution, the DWC module can be regarded as a kind of attention, where each query only focuses on a few adjacent features in the space instead of all features. This locality ensures that even if the linear attention values ​​corresponding to two queries are the same, different outputs can still be obtained from different local features, thereby maintaining the diversity of features. By adding the DWC module, the rank of the attention map in the linear attention can be restored to the full rank, maintaining the feature diversity of the original Softmax attention.

[0028] Preferably, in step 4, feature fusion is achieved through a feature pyramid network and a path aggregation network.

[0029] In the above technical solutions, FPN passes down the strong semantic features of the high layer from the top (small size, the result obtained by many convolutions, and rich semantic information) to the bottom (large size, the result obtained by few convolutions), and enhances the entire pyramid. PAN adds a bottom-up pyramid after FPN. By introducing the path aggregation method, the shallow feature map (low resolution but weak semantic information) and the deep feature map (high resolution but rich semantic information) are aggregated, and the feature information is passed along a specific path to pass the strong positioning features of the low layer up. It can further enhance the expression ability of multi-scale features.

[0030] Preferably, the detection result: takes the fused features corresponding to the target instance as input, and obtains the category, border information and k mask coefficients through the detection branch.

[0031] Preferably, the segmentation mask is: taking the fused features corresponding to the target instance as input, and generating k mask prototype images through mask branches.

[0032] Preferably, in step 5, the method for synthesizing the instance segmentation result of the target is: multiplying k mask coefficients with k mask prototype images, adding the multiplication result to the category and border information, and then connecting to the Sigmoid nonlinear function to generate the final mask, that is, the instance segmentation result of the target.

[0033] The present invention has the following characteristics and beneficial effects:

[0034] Using the above technical solution, this method introduces a focused linear attention mechanism for instance segmentation, which reduces the computational complexity of the attention mechanism while maintaining the representation capability. Tests on the urban landscape dataset show that this method can effectively balance performance and speed compared to pure convolution and pure attention mechanism methods. This makes it easier to deploy on edge devices such as autonomous driving in practical applications. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0036] Figure 1 It is a flowchart of the real-time instance segmentation method of urban street scenes based on lightweight attention of the present invention.

[0037] Figure 2 It is a specific network framework diagram of the real-time instance segmentation method of the present invention.

[0038] Figure 3 This is a data label distribution diagram of the data set used in the method of the present invention.

[0039] Figure 4 This is an example segmentation effect diagram of the method of the present invention in a complex road traffic scene. DETAILED DESCRIPTION

[0040] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other.

[0041] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below with reference to the accompanying drawings.

[0042] On the contrary, the present invention covers any substitution, modification, equivalent method and scheme made on the essence and scope of the present invention as defined by the claims. Further, in order to make the public have a better understanding of the present invention, some specific details are described in detail in the detailed description of the present invention below. Those skilled in the art can fully understand the present invention without the description of these details.

[0043] This embodiment provides a real-time instance segmentation method for urban street scenes based on lightweight attention. Figure 1 As shown, the following steps are included:

[0044] Step S1: Obtain a city street view image dataset, and preprocess and enhance the images in the dataset.

[0045] Specifically, the step S1 includes steps S1-1 to S1-4:

[0046] S1-1. Load the corresponding annotations in the image dataset, including category labels and instance labels.

[0047] S1-2. Perform an adaptive scaling operation on the image loaded in the image dataset. First, determine that the target size of the image processing is 640×640, and calculate the scaling ratio based on the original image and the target size, and take the minimum value of the aspect ratio for scaling. During the calculation process, a scaling limit is considered to prevent the image from being enlarged. Subsequently, the amount of padding required to achieve the target size is calculated, and padding is performed around the image to avoid loss of image content. The padding operation uses the (114,114,114) color value to ensure the consistency of the filled area. The segmentation mask label will then be updated based on the adjusted image to align it with the scaled and padded image to ensure the accuracy of subsequent processing steps.

[0048] S1-3, performing MixUp image enhancement processing on the image loaded in the image data set. The specific method is as follows:

[0049] First, a mixing coefficient λ between 0 and 1 is generated, and then the pixel values ​​and labels of the two images are linearly combined according to this coefficient. Specifically, it creates a new image whose pixel values ​​are the weighted average of the pixel values ​​of the original image and the randomly selected image, with the weights determined by λ. At the same time, it also merges the label information of the two images. It can be expressed as:

[0050] img mix =img 1 *λ+img 2 *(1-λ) (1)

[0051] where img 1 and img 2 is the sample to be mixed, and the mixing coefficient λ is sampled from the Beta distribution based on the following formula:

[0052] λ=Beta(α,β) (2)

[0053] The value of α and β is set to maintain the expectation Always approximately 0.5.

[0054] S1-4, performing HSV (hue, saturation, brightness value) enhancement and adjustment on the image loaded in the image data set to enhance the visual features of the image.

[0055] It should be noted that HSV enhancement enhances the visual features of the image by adjusting the hue, saturation, and brightness of the image. The HSV color space of the image is enhanced by randomly generating three multiplication factors and then multiplying them by the values ​​of Hue, Saturation, and Value. The HSV color space is constructed from the perspective of human eye perception. Compared with the RGB color space, it is closer to the way humans perceive color, thereby enriching the characteristics of urban street scene images and enhancing the robustness of the model.

[0056] S1-5. Randomly flip the images of the urban street view dataset horizontally and adjust the corresponding labels.

[0057] Step S2: Input the preprocessed image into the backbone network for feature extraction. The backbone network mainly includes 3×3 convolution kernels and C2f modules, and the convolution modules and residual blocks are serially stacked multiple times. After each pooling operation, the number of channels is doubled. The C2f module makes the network more lightweight while maintaining the idea of ​​cross-stage partial networks.

[0058] The C2f module divides the feature extraction process into two stages: compression and expansion. In the compression stage, the input feature map is reduced in dimension through convolution operations to reduce the amount of calculation; in the expansion stage, the feature map is restored to its original size through convolution and upsampling operations, and feature fusion is performed. This design ensures the effectiveness of feature extraction, reduces the computational complexity, and obtains richer gradient flow information.

[0059] It should be noted that the residual block borrows the idea of ​​the residual network (ResNet) and uses a large number of residual connections in the network, so the network structure can be designed to be very deep. Traditional deep neural networks attempt to learn the target function H(x), but in the residual network, each network layer actually learns a residual function F(x) = H(x)-x. Then, the residual result is added to the input x to form H(x) = F(x) + x. This mechanism makes it easier for the network to learn identity mapping, thereby alleviating the gradient vanishing problem.

[0060] Step S3: Input the feature map output by the backbone network into the focused linear attention module to further extract features and focus on the target instance.

[0061] Specifically, the step S3 includes steps S3-1 to S3-8.

[0062] S3-1. Downsample the high-level feature map extracted by the backbone network and input it into the focused linear attention module.

[0063] S3-2. The input feature map is processed. The original input feature map is divided into blocks of the same window size. In this method, the window is set to 20×20 and position encoding is added.

[0064] S3-3, Map the segmented blocks to vector representation: For each obtained block, map it to a one-dimensional feature vector through a linear transformation, flatten the dimension of the feature map into a sequence form, and then perform a transposition operation so that the sequence dimension is moved to the front. Then, a linear layer is used to map it into three parts: query, key, and value.

[0065] S3-4. Scale and normalize the query and key. Use the Softplus function to calculate a scaling factor. The Softplus function is a smooth nonlinear function that maps the input to a value greater than 0, similar in form to ln(1+e x ).

[0066] It should be noted that the scaling factor is a learnable parameter whose value is constantly adjusted during training to stabilize the self-attention calculation and avoid the problem of gradient vanishing or exploding. After that, each element of the query and key is divided by the scaling factor. Its purpose is to adjust the numerical range of the query and key to a suitable size so that the subsequent dot product operation will not be affected by numerical problems.

[0067] S3-5. Use a mapping function f p By adjusting the feature direction of each query and key, similar query-key pairs are brought closer and the distance between dissimilar query-key pairs is increased. It can be expressed as:

[0068]

[0069] where x **p Represents the power p of x. The ReLU function is used to ensure the non-negativity of the input and the validity of the denominator.

[0070] S3-6, calculate the self-attention weight. The principle of Einstein summation convention (einsum) is used to perform matrix operations, calculate the dot product of the query and the key, and then apply the Softmax function to get the attention weight.

[0071] It should be noted that Einstein summation is a symbolic system for representing vector and tensor operations. In the string expression of einsum, each letter represents a dimension, and the operator defines the relationship between these dimensions.

[0072] S3-7, Feature Map and Residual Connection: Rearrange the values ​​into feature maps, and then process the feature maps through a deep convolution DWC module to increase the representation ability of the model and extract richer features to address the limitations of linear attention. For each input channel, the output feature map O(c) of the DWC module is calculated as follows:

[0073]

[0074] Where I[c] is the c-th channel of the input feature map, O(c) is the c-th channel of the output feature map, and K(c) is the convolution kernel corresponding to channel c.

[0075] Furthermore, the attention matrix of the focused linear attention module is integrated with a deep convolution module, which can be expressed as follows based on the focused linear attention module method described above:

[0076]

[0077] S3-8, residual connection and output processing. The processed feature map is residually connected with the original query, which will avoid the problem of gradient vanishing or exploding in deep networks. Then the dimension is transformed through the projection layer to adjust the dimension of the output feature to adapt it to the input requirements of the subsequent layers. At the same time, the random deactivation method (dropout) is applied to help reduce overfitting.

[0078] Step S4, the features extracted by the focused linear attention module are fused through upsampling and the features extracted by the C2f module in the backbone network, and multi-level upsampling and downsampling are performed. This is achieved through the feature pyramid network (FPN) and the path aggregation network (PAN). FPN is top-down, passing down the strong semantic features of the high level to enhance the entire pyramid. PAN is to add a bottom-up pyramid after FPN. By introducing the path aggregation method, the shallow feature map and the deep feature map are aggregated, and the feature information is passed along a specific path, and the strong positioning features of the low level are passed up, which can further enhance the expression ability of multi-scale features.

[0079] Specifically, the step S4 includes steps S4-1 to S4-8:

[0080] S4-1, upsampling the feature map extracted by the focus attention module by two times, thus doubling the resolution of the feature map;

[0081] S4-2, connecting the feature map obtained in step S4-1 with the third-level feature map of the backbone network in step S2 to obtain a new feature map;

[0082] S4-3, the feature map obtained in S4-2 is processed by the C2f module, and upsampled by two times to increase the resolution of the feature map by two times;

[0083] S4-4, connecting the feature map obtained in step S4-3 with the second-level feature map of the backbone network in S2 to obtain a new feature map;

[0084] S4-5, the feature map obtained in step S4-4 is processed by the C2f module, and downsampled by two times through a 3×3 convolution layer to reduce the resolution of the feature map by half;

[0085] S4-6, connecting the feature map obtained in step S4-5 with the feature map obtained in step S4-2 to obtain a new feature map;

[0086] S4-7, the feature map obtained in S4-6 is processed by the C2f module, and downsampled by two times through a 3×3 convolution layer to reduce the resolution of the feature map by half;

[0087] S4-8, connect the feature map extracted by the focus attention module with the feature map obtained by S4-7 to obtain a new feature map.

[0088] S5. Based on the decoupling head, the detection branch and the mask branch are obtained, and then the detection result and the segmentation mask are synthesized to obtain the instance segmentation result of the target. Specifically, for the detection branch, for each target object, k mask coefficients (Mask Coefficients) of category and bounding box information are output; for the mask branch, k mask prototypes (Mask Prototype) are output for the current input image. For each target object, the k mask coefficients are multiplied by the k mask prototypes, and then all the results are combined to obtain the instance segmentation result of the target object. It should be noted that k here is set to 32.

[0089] Specifically, Figure 2 As shown, the step S5 includes steps S5-1 to S5-2:

[0090] Step S5-1, the feature map obtained by S4-4 is input to the segmentation head, 32 mask prototype maps are obtained through the mask branch, 32 mask coefficients, the target detection box of the instance and the instance category index are obtained through the detection branch;

[0091] Step S5-2: The feature map obtained by S4-6 is input to the segmentation head, and 32 mask coefficients, the target detection box of the instance and the instance category index are obtained through the detection branch;

[0092] Step S5-3, the feature map obtained by S4-8 is processed by the C2f module and input to the segmentation head, and 32 mask coefficients, the target detection box of the instance and the instance category index are obtained through the detection branch;

[0093] Step S5-4: Combine the 32 mask coefficients obtained by the detection head in S5-3 with the 32 mask prototype images obtained by the segmentation head to obtain a mask for a specific instance. Specifically, the 32 mask coefficients and the 32 mask prototype images are linearly combined and multiplied to obtain the optimal mask associated with the detection box;

[0094] Step S5-5: Post-process the obtained mask by first performing confidence detection and non-maximum suppression to determine the valid target, and then performing mask processing.

[0095] Specifically, first determine whether the set confidence and IoU thresholds are between 0 and 1. If not, an error is reported that the threshold does not meet the requirements. Then filter out the results that meet the confidence score. Sort the results according to the score, and cut out the part with the highest score according to the set maximum number of non-maximum suppression. Then obtain the shape and size of the original image, map the obtained category index to the text category, map the box, category, and mask back to the original image scale, and save the final instance segmentation mask label or visualization image according to different needs.

[0096] In order to verify the effect of the present invention, the following experiment was carried out:

[0097] The present invention uses the Cityscape dataset, which contains high-quality images from city streets, covering scenes of different weather, time of day and seasons. The dataset consists of 5000 images designated for training purposes and another 500 images assigned to the validation phase. The size of the image is 1024×2048 pixels. Each image is provided with dense pixel-level annotations covering 19 semantic classes, such as roads, buildings, vehicles, etc. 8 of which have instance-level segmentation. Figure 3 The distribution of instance labels is shown. It can be seen that this dataset is suitable for evaluating the image instance segmentation performance in autonomous driving and smart city traffic environments.

[0098] Experimental environment and parameters

[0099] The experimental configuration of the present invention is: the operating system is Ubuntu 20.04.6, the processor is Intel Core TM i9-13900K CPU, main frequency 3.0GHz, NVIDIA RTX A6000 graphics card with 48G video memory. The deep learning framework used is Pytorch 2.0.0 version, and Python 3.9 version is used to implement the training and verification of the invented method.

[0100] In this embodiment, the performance of the present invention is evaluated on the validation set of the Ciyscapes dataset. The experiment uses mAP, AP50, Para(M), FPS, and Runtime(ms) to evaluate the accuracy and performance of the method of the present invention.

[0101] It should be noted that Intersection over Union (IoU) is an indicator that measures the degree of overlap between the model's predicted value and the true value. For object detection tasks, IoU is used to evaluate the overlap between the detection box and the true box; for image segmentation tasks, IoU is used to calculate the overlap between the predicted mask and the true mask. Its calculation formula is the ratio of the intersection area to the union area, and the specific formula is as follows:

[0102]

[0103] Among them, TP (True Positive) represents the number of correctly predicted positive samples, FP (False Positive) represents the number of incorrectly predicted positive samples, and FN (False Negative) represents the number of positive samples that cannot be predicted.

[0104] mAP is the mean average precision, and the calculation formula is as follows:

[0105]

[0106] Among them, mAP stands for average precision, which is the average of the AP values ​​of all categories in a multi-category task. Here, C represents the number of categories. AP50 refers to the average precision when the IoU threshold is 0.5. The calculation method is similar to mAP, but it is only calculated when IoU=0.5. Its definition is as follows:

[0107] AP50=AP IoU=0.5 (8)

[0108] Para(M) refers to the number of parameters contained in the model, which is an important indicator affecting the model's memory requirements and computational load. The expression for the number of parameters is:

[0109]

[0110] Among them, L is the number of layers of the model, P i is the number of parameters in the i-th layer. A model with fewer parameters is generally more efficient because it requires less memory and can be deployed on resource-constrained devices such as edge devices and mobile platforms. However, it is important to strike a balance between the number of parameters and model accuracy to ensure that performance is not compromised.

[0111] FPS refers to frames per second, which is an important indicator for measuring the real-time performance of model image reasoning. The definition of FPS is as follows:

[0112]

[0113] Where N is the number of frames processed and T is the total time required to process these frames. A higher FPS indicates that the model is able to process more frames in real time.

[0114] Runtime (ms) refers to the inference speed, which measures the time required for the model to process a single image or frame, measured in milliseconds (ms) per frame and is defined as follows:

[0115]

[0116] Where T is the total time required to process N frames. Faster inference speed is critical for real-time applications because it ensures that the model can respond in a timely manner. This metric is affected by the model architecture and the hardware on which the model is deployed. Optimizing inference speed usually involves a trade-off between model complexity and computational efficiency.

[0117] The comparison of verification results of the method of the present invention and the prior art on the Cityscapes dataset is shown in Table 1.

[0118] Table 1. Verification results of different methods on the Cityscapes dataset

[0119]

[0120] The comparison of the verification results of the method of the present invention and the prior art on the Cityscapes dataset is shown in Table 1. The model parameters of the method of the present invention are only 3.46M, while the mAP and AP50 reach 18.7 and 37.8 respectively, the FPS reaches 357, and the inference speed reaches 2.8ms. The experimental results are shown in Table 1. Figure 4 As shown in FIG. 1 , the invention exceeds the performance of most advanced real-time instance segmentation methods and can achieve a good balance between accuracy and speed with a small number of parameters.

[0121] The embodiments of the present invention are described in detail above with reference to the accompanying drawings, but the present invention is not limited to the described embodiments. For those skilled in the art, various changes, modifications, substitutions and variations of these embodiments including components are made without departing from the principles and spirit of the present invention, and still fall within the scope of protection of the present invention.

Claims

1. A real-time instance segmentation method for urban street scenes based on lightweight attention, characterized in that: The steps include: Step 1: Read the urban street view dataset and perform preprocessing and data enhancement; Step 2: The image processed in step 1 is used as input, and features are extracted through a backbone network to output a feature map, wherein the backbone network includes a 3×3 convolution kernel and a C2f module; Step 3: The feature map is input into a focused linear attention module with a focusing function to further extract features so that it focuses on the target instance; Step 4: Fusing the feature map extracted by the focus attention module with the feature maps of different sizes extracted by the backbone network; Step 5: Based on the decoupling head, the detection branch and the mask branch are obtained, and the fused features are input into the detection branch and the mask branch respectively to obtain the detection result and the segmentation mask. Finally, the detection result and the segmentation mask are synthesized to obtain the instance segmentation result of the target.

2. The method for real-time instance segmentation of urban street scenes based on lightweight attention according to claim 1, characterized in that: The preprocessing method includes performing a letterbox scaling operation on the urban street view dataset and unifying the image size to 640×640.

3. The method for real-time instance segmentation of urban street scenes based on lightweight attention according to claim 1, characterized in that: The data enhancement methods include HSV enhancement, MixUp enhancement, and flipping.

4. The method for real-time instance segmentation of urban street scenes based on lightweight attention according to claim 1, characterized in that: In step 3, the feature map of the input focused linear attention module needs to be downsampled first.

5. The method for real-time instance segmentation of urban street scenes based on lightweight attention according to claim 1, characterized in that: The focusing function is to introduce a mapping function f for focusing capability. p , the expression is as follows: φ p (x)=f p (ReLU(x)) Among them, x **p Represents x element-wise to the power p and uses the ReLU function to ensure the non-negativity of the input and the validity of the denominator.

6. The method for real-time instance segmentation of urban street scenes based on lightweight attention according to claim 1, characterized in that: The attention matrix of the focused linear attention module is integrated with a deep convolution module, and the final focused linear attention module can be expressed as: Where Sim(Q, K) is the similarity function, φ p is the focusing function, DWC is the deep convolution module, Q, K, Refers to query, key, and value respectively.

7. The method for real-time instance segmentation of urban street scenes based on lightweight attention according to claim 1, characterized in that: In step 4, feature fusion is achieved through a feature pyramid network and a path aggregation network.

8. The method for real-time instance segmentation of urban street scenes based on lightweight attention according to claim 1, characterized in that: The detection result: taking the fused features corresponding to the target instance as input, obtaining the category, border information and k mask coefficients through the detection branch.

9. The method for real-time instance segmentation of urban street scenes based on lightweight attention according to claim 8, characterized in that: The segmentation mask is: taking the fused features corresponding to the target instance as input, and generating k mask prototype images through the mask branch.

10. The method for real-time instance segmentation of urban street scenes based on lightweight attention according to claim 9, characterized in that: In step 5, the method for synthesizing the instance segmentation result of the target is: multiplying k mask coefficients with k mask prototype images, adding the multiplication result to the category and border information, and then connecting to the Sigmoid nonlinear function to generate the final mask, that is, the instance segmentation result of the target.

Citation Information

Patent Citations

  • Image segmentation method based on lightweight recursive non-local self-attention

    CN112132844A

  • Ground semantic cognition method based on segmentation and attention mechanism

    CN113033411A

  • Video instance segmentation method of dynamic convolution solution of lightweight attention mechanism

    CN117115703A

Cited By

  • Camera cleaning method and system, electronic equipment and storage medium

    CN119091254A

  • Camera cleaning method, system, electronic device and storage medium

    CN119091254B

  • Multi-scale background segmentation and retrieval method and device, computer equipment and storage medium

    CN121210701A

  • Training method for street scene understanding model assisted by large vision model

    WO2026060961A1