Semantic segmentation method, device, computer equipment and storage medium

By calculating the loss value and adjusting the parameters of the semantic segmentation network, the problem of insufficient classification accuracy of the semantic segmentation network in the existing technology is solved, and the classification accuracy and consistency of the semantic segmentation network are improved.

CN112613515BActive Publication Date: 2024-09-20刘丽
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011321218.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-23
Publication Date
2024-09-20
Estimated Expiration
2040-11-23

AI Technical Summary

Technical Problem

The classification accuracy of existing semantic segmentation networks still needs to be further improved, especially in fields such as autonomous driving and medical image analysis.

Method used

By obtaining the training sample set, the preset loss function is used to calculate the total loss value, which characterizes the correlation between pixels with similar semantic labels in the sample image and the difference between the training segmentation results and the annotations, and based on the total loss value Adjust the adjustable parameters of the semantic segmentation network until the total loss value meets the convergence condition, thereby improving the classification accuracy of the semantic segmentation network.

Benefits of technology

Improves the classification accuracy of the semantic segmentation network, reduces intra-class diversity, and forces the semantic segmentation network to produce more consistent classifications of similar objects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112613515B
    Figure CN112613515B
Patent Text Reader

Abstract

The present application relates to a semantic segmentation method, apparatus, computer equipment and storage medium. The method comprises: obtaining a target image to be semantically segmented; inputting the target image into a pre-trained target semantic segmentation network to obtain a target segmentation result output by the target semantic segmentation network; the target segmentation result comprises a target semantic label corresponding to each pixel in the target image; wherein the target semantic segmentation network is obtained based on the correlation between pixels with the same semantic label in a sample image and the annotation training corresponding to the sample image. The use of this method can improve the classification accuracy of the semantic segmentation network.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer vision technology, and in particular to a semantic segmentation method, apparatus, computer device and storage medium. Background Art

[0002] In the field of computer vision, the current applications of neural networks mainly include image recognition, target location and detection, and semantic segmentation. Among them, semantic segmentation networks are widely used in fields such as autonomous driving, medical image analysis, and robotics, and the accuracy of their classification is one of the issues that researchers are most concerned about.

[0003] In related technologies, semantic segmentation networks are usually trained using a cross entropy loss function, or trained using a function improved on the basis of the cross entropy loss function, such as weighted loss and focal loss.

[0004] However, the classification accuracy of semantic segmentation networks still needs to be further improved. Summary of the invention

[0005] Based on this, it is necessary to provide a semantic segmentation method, device, computer equipment and storage medium that can improve the classification accuracy of the semantic segmentation network in response to the above technical problems.

[0006] A semantic segmentation method, the method comprising:

[0007] Obtain the target image to be semantically segmented;

[0008] Input the target image into the pre-trained target semantic segmentation network to obtain the target segmentation result output by the target semantic segmentation network; the target segmentation result includes the target semantic label corresponding to each pixel in the target image;

[0009] Among them, the target semantic segmentation network is trained based on the correlation between pixels with similar semantic labels in the sample image and the annotations corresponding to the sample image.

[0010] In one embodiment, before inputting the target image into the pre-trained target semantic segmentation network, the method further includes:

[0011] Acquire a training sample set; the training sample set includes multiple sample images and annotations corresponding to each sample image; the annotations corresponding to the sample image include actual semantic labels corresponding to each pixel in the sample image;

[0012] Input the sample image into the initial semantic segmentation network to obtain the training segmentation result output by the initial semantic segmentation network; the training segmentation result includes the training semantic label corresponding to each pixel in the sample image;

[0013] The total loss value is calculated using the preset loss function and the training segmentation result; the total loss value represents the correlation between pixels with similar semantic labels in the sample image, and the difference between the training segmentation result and the annotation corresponding to the sample image;

[0014] According to the total loss value, the adjustable parameters in the initial semantic segmentation network are adjusted until the total loss value meets the convergence condition, and the semantic segmentation network when the total loss value meets the convergence condition is used as the target semantic segmentation network.

[0015] In one embodiment, the above-mentioned calculation of the total loss value using the preset loss function and the training segmentation result includes:

[0016] A first loss value is calculated using a preset first loss function and a training segmentation result; the first loss value represents the correlation between pixels with similar semantic labels in the sample image;

[0017] Calculating a second loss value using a preset second loss function and the training segmentation result; the second loss value represents the difference between the training segmentation result and the annotation;

[0018] The first loss value and the second loss value are summed to obtain a total loss value.

[0019] In one embodiment, the method of calculating the first loss value using a preset first loss function and a training segmentation result includes:

[0020] According to the training segmentation results, the pixel points corresponding to each type of training semantic label are counted to obtain the pixel point sets corresponding to each type of training semantic label;

[0021] For each pixel point set corresponding to each type of training semantic label, the first loss function is used to calculate the divergence sum of the probabilities of every two pixels in the pixel point set to obtain the first divergence sum corresponding to each type of training semantic label;

[0022] The first divergence sums corresponding to multiple types of training semantic labels are summed up to obtain the first loss value.

[0023] In one embodiment, the above-mentioned use of the first loss function to calculate the divergence sum of the probabilities of every two pixels in the pixel point set to obtain the first divergence sum corresponding to each type of training semantic label includes:

[0024] For each pixel point set, a pixel point in the pixel point set is taken as a target pixel point, and a second divergence sum of the target pixel point and the pixel points in the pixel point set other than the target pixel point is calculated using a first loss function until the pixel points in the pixel point set are cycled through, thereby obtaining a plurality of second divergence sums;

[0025] The sum of multiple second divergence sums is calculated to obtain the first divergence sum corresponding to a class of training semantic labels.

[0026] In one embodiment, the method of calculating the second loss value using a preset second loss function and a training segmentation result includes:

[0027] The second loss function is used to calculate the loss between the probability of each pixel in the training segmentation result and the actual semantic label of the corresponding pixel in the annotation, and the loss value corresponding to each pixel is obtained;

[0028] The loss values ​​corresponding to multiple pixel points are summed up to obtain a second loss value.

[0029] In one of the embodiments, the sample images, annotations, and training segmentation results are all multi-dimensional vectors;

[0030] The dimensions of the sample image include batch size, number of categories, sample image width, and sample image height;

[0031] The annotated dimensions include batch data size, sample image width, and sample image height;

[0032] The dimensions of the training segmentation results include batch size, number of categories, sample image width, and sample image height.

[0033] A semantic segmentation device, comprising:

[0034] A target image acquisition module is used to acquire a target image to be semantically segmented;

[0035] A semantic segmentation module, used to input the target image into a pre-trained target semantic segmentation network to obtain a target segmentation result output by the target semantic segmentation network; the target segmentation result includes a target semantic label corresponding to each pixel in the target image;

[0036] The target semantic segmentation network is obtained by training based on the correlation between pixels with similar semantic labels in the sample image and the annotations corresponding to the sample image.

[0037] In one embodiment, the device further comprises:

[0038] A set acquisition module is used to acquire a training sample set; the training sample set includes a plurality of sample images and annotations corresponding to each sample image; the annotations corresponding to the sample image include actual semantic labels corresponding to each pixel in the sample image;

[0039] A result output module is used to input the sample image into the initial semantic segmentation network to obtain the training segmentation result output by the initial semantic segmentation network; the training segmentation result includes the training semantic label corresponding to each pixel in the sample image;

[0040] A loss calculation module is used to calculate a total loss value using a preset loss function and a training segmentation result; the total loss value represents the correlation between pixels with similar semantic labels in the sample image, and the difference between the training segmentation result and the annotation corresponding to the sample image;

[0041] The parameter adjustment module is used to adjust the adjustable parameters in the initial semantic segmentation network according to the total loss value until the total loss value meets the convergence condition, and the semantic segmentation network when the total loss value meets the convergence condition is used as the target semantic segmentation network.

[0042] In one embodiment, the loss calculation module includes:

[0043] A first loss calculation submodule is used to calculate a first loss value using a preset first loss function and a training segmentation result; the first loss value represents the correlation between pixels with similar semantic labels in the sample image;

[0044] A second loss calculation submodule, used to calculate a second loss value using a preset second loss function and the training segmentation result; the second loss value represents the difference between the training segmentation result and the annotation;

[0045] The total loss calculation submodule is used to sum the first loss value and the second loss value to obtain a total loss value.

[0046] In one of the embodiments, the above-mentioned first loss calculation submodule is specifically used to count the pixel points corresponding to each type of training semantic label according to the training segmentation results, and obtain the pixel point sets corresponding to each type of training semantic label; for the pixel point sets corresponding to each type of training semantic label, use the first loss function to calculate the divergence sum of the probabilities of every two pixels in the pixel point set, and obtain the first divergence sum corresponding to each type of training semantic label; sum the first divergence sums corresponding to multiple types of training semantic labels to obtain the first loss value.

[0047] In one of the embodiments, the above-mentioned first loss calculation submodule is specifically used to, for each pixel point set, take a pixel point in the pixel point set as the target pixel point, and use the first loss function to calculate the second divergence sum of the target pixel point and the pixel points in the pixel point set other than the target pixel point, until the pixel points in the pixel point set are cycled through, to obtain multiple second divergence sums; and sum the multiple second divergence sums to obtain the first divergence sum corresponding to a class of training semantic labels.

[0048] In one of the embodiments, the above-mentioned second loss calculation submodule is specifically used to use the second loss function to calculate the loss between the probability of each pixel point in the training segmentation result and the actual semantic label of the corresponding pixel point in the annotation to obtain the loss value corresponding to each pixel point; the loss values ​​corresponding to multiple pixels are summed up to obtain the second loss value.

[0049] In one of the embodiments, the sample images, annotations, and training segmentation results are all multi-dimensional vectors;

[0050] The dimensions of the sample image include batch size, number of categories, sample image width, and sample image height;

[0051] The annotated dimensions include batch data size, sample image width, and sample image height;

[0052] The dimensions of the training segmentation results include batch size, number of categories, sample image width, and sample image height.

[0053] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0054] Obtain the target image to be semantically segmented;

[0055] Input the target image into the pre-trained target semantic segmentation network to obtain the target segmentation result output by the target semantic segmentation network; the target segmentation result includes the target semantic label corresponding to each pixel in the target image;

[0056] Among them, the target semantic segmentation network is trained based on the correlation between pixels with similar semantic labels in the sample image and the annotations corresponding to the sample image.

[0057] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:

[0058] Obtain the target image to be semantically segmented;

[0059] Input the target image into the pre-trained target semantic segmentation network to obtain the target segmentation result output by the target semantic segmentation network; the target segmentation result includes the target semantic label corresponding to each pixel in the target image;

[0060] Among them, the target semantic segmentation network is trained based on the correlation between pixels with similar semantic labels in the sample image and the annotations corresponding to the sample image.

[0061] In the above-mentioned semantic segmentation method, apparatus, computer equipment and storage medium, the server obtains the target image to be semantically segmented, inputs the target image into the pre-trained target semantic segmentation network, and obtains the target segmentation result output by the target semantic segmentation network. The target semantic segmentation network is obtained based on the correlation between pixels with similar semantic labels in the sample image and the annotation training corresponding to the sample image, that is, considering that each pixel is not independent, the semantic segmentation network is forced to produce more consistent classifications for similar objects during the training process, thereby improving the classification accuracy of the semantic segmentation network. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] Figure 1 A diagram showing an application environment of a semantic segmentation method in an embodiment;

[0063] Figure 2 Schematic diagram of a flow chart of a semantic segmentation method in one embodiment;

[0064] Figure 3 Schematic diagram of a process flow of training a target semantic segmentation network in one embodiment;

[0065] Figure 4 A schematic diagram of a flow chart of a step of calculating a total loss value using a preset loss function and a training segmentation result in one embodiment;

[0066] Figure 5 A schematic flow chart of a step of calculating the divergence sum of the probabilities of every two pixels in a pixel point set by using a first loss function to obtain the first divergence sum corresponding to various types of training semantic labels in one embodiment;

[0067] Figure 6 is one of the structural block diagrams of a semantic segmentation device in one embodiment;

[0068] Figure 7 This is a second structural block diagram of a semantic segmentation device in an embodiment;

[0069] Figure 8 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0070] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0071] The semantic segmentation method provided in this application can be applied to Figure 1In the application environment shown. The application environment may include a terminal 102 and a server 104, and the terminal 102 communicates with the server 104 through a network. The terminal 102 obtains a target image to be semantically segmented and sends the target image to the server 104; the server 104 performs semantic segmentation on the target image and sends the obtained target segmentation result to the terminal 102 for display. Among them, the terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, and portable wearable devices, and the server 104 can be implemented by an independent server or a server cluster composed of multiple servers.

[0072] In one embodiment, Figure 2 As shown, a semantic segmentation method is provided, which is applied to Figure 1 The server in the example is used to illustrate the following steps:

[0073] Step 201: The server obtains a target image to be semantically segmented.

[0074] The user can select the target image to be semantically segmented through the terminal, and then the terminal sends the target image to the server, and the server receives the target image sent by the terminal. Alternatively, the user selects the target image from multiple candidate images pre-stored by the server through the terminal. The embodiment of the present disclosure does not limit the way in which the server obtains the target image, and it can be set according to actual conditions.

[0075] Step 202: input the target image into a pre-trained target semantic segmentation network to obtain a target segmentation result output by the target semantic segmentation network.

[0076] Among them, the target segmentation result includes the target semantic label corresponding to each pixel in the target image; the target semantic segmentation network is obtained based on the correlation between pixels with similar semantic labels in the sample image and the annotation training corresponding to the sample image.

[0077] The server pre-trains the target semantic segmentation network. In actual operation, the server calculates the loss based on the correlation between pixels with similar semantic labels in the sample image and the annotations corresponding to the sample image, and trains the semantic segmentation network based on the calculated loss value to obtain the target semantic segmentation network.

[0078] After the server obtains the target image, it inputs the target image into the pre-trained target semantic segmentation network, and the target semantic segmentation network outputs the target segmentation result corresponding to the target image. That is, the target semantic segmentation network outputs the target semantic label corresponding to each pixel in the target image.

[0079] For example, the target image A is input into the target semantic segmentation network, and the target semantic segmentation network outputs the target segmentation result. The target segmentation result is that the target semantic label corresponding to the first pixel in the target image A is background, the target semantic label corresponding to the second pixel is cat... and the target semantic label corresponding to the mth pixel is background.

[0080] In the above semantic segmentation method, the server obtains the target image to be semantically segmented, inputs the target image into the pre-trained target semantic segmentation network, and obtains the target segmentation result output by the target semantic segmentation network. The target semantic segmentation network is obtained based on the correlation between pixels with similar semantic labels in the sample image and the annotation training corresponding to the sample image, that is, considering that each pixel is not independent, the semantic segmentation network is forced to produce more consistent classifications for similar objects during the training process, thereby improving the classification accuracy of the semantic segmentation network.

[0081] In one embodiment, Figure 3 As shown, before the target image is input into the target semantic segmentation network, the training process of the target semantic segmentation can also be included:

[0082] Step 301: The server obtains a training sample set.

[0083] The training sample set includes multiple sample images and annotations corresponding to each sample image; the annotations corresponding to the sample images include actual semantic labels corresponding to each pixel in the sample images.

[0084] The server obtains a plurality of sample images and annotations corresponding to the sample images, and the plurality of sample images and the annotations corresponding to the sample images form a training sample set.

[0085] In practical applications, the training sample set can use Cityscape, which includes 2975 training images, 500 verification images, and 1525 test images. VOC can also be used, which includes 10582 training images, 1449 verification images, and 1456 test images. The embodiment of the present disclosure does not limit the training sample set, and it can be set according to actual conditions.

[0086] Step 302: input the sample image into the initial semantic segmentation network to obtain the training segmentation result output by the initial semantic segmentation network.

[0087] The training segmentation result includes the training semantic label corresponding to each pixel in the sample image.

[0088] The server first selects the structure of the semantic segmentation network. In practical applications, the semantic segmentation network can use PSPNet (Pyramid Scene Parsing Network) or BiSeNet (Bilateral Segmentation Network for Real-time Semantic Segmentation). The disclosed embodiment does not limit the structure of the semantic segmentation network, and it can be selected according to actual conditions.

[0089] After that, the server initializes the adjustable parameters in the selected semantic segmentation network. And inputs any sample image into the initial semantic segmentation network. The initial semantic segmentation network performs semantic segmentation on the sample image and outputs the training segmentation result, that is, the training semantic label corresponding to each pixel in the sample image.

[0090] Step 303, calculate the total loss value using the preset loss function and the training segmentation result.

[0091] Among them, the total loss value represents the correlation between pixels with similar semantic labels in the sample image, as well as the difference between the training segmentation results and the annotations corresponding to the sample image.

[0092] The loss function is set in advance. After the initial semantic segmentation network outputs the training segmentation result, the correlation between pixels with the same semantic label in the sample image is determined according to the loss function; and the difference between the training segmentation result and the label corresponding to the sample image is determined according to the loss function. The total loss value is obtained by combining the correlation and difference obtained above.

[0093] Step 304, adjusting the adjustable parameters in the initial semantic segmentation network according to the total loss value until the total loss value meets the convergence condition, and taking the semantic segmentation network when the total loss value meets the convergence condition as the target semantic segmentation network.

[0094] After obtaining the first total loss value, if the total loss value does not meet the convergence conditions, the server adjusts the adjustable parameters in the initial semantic segmentation network according to the total loss value. Afterwards, the server inputs another sample image into the adjusted semantic segmentation network, obtains the second training segmentation result output by the adjusted semantic segmentation network, and calculates the second total loss value based on the second training segmentation result. If the second total loss value does not meet the convergence conditions, the adjustable parameters in the adjusted semantic segmentation network are adjusted again according to the second total loss value. And so on, until the calculated total loss value meets the convergence conditions, and the semantic segmentation network whose total loss value meets the convergence conditions is used as the target semantic segmentation network. The embodiments of the present disclosure do not limit the adjustable parameters and convergence conditions, and can be set according to actual conditions.

[0095] In one embodiment, the sample image, annotation and training segmentation results are all multi-dimensional vectors; the dimensions of the sample image include batch data size, number of categories, sample image width and sample image height; the dimensions of the annotation include batch data size, sample image width and sample image height; the dimensions of the training segmentation results include batch data size, number of categories, sample image width and sample image height.

[0096] For example, the dimensions of the sample image are [B, C, W, H], the dimensions of the annotation are [B, W, H], and the dimensions of the training segmentation result are [B, C, W, H]. Among them, B is the batch data size, C is the number of categories, W is the width of the sample image, and H is the height of the sample image. If one sample image is input into the semantic segmentation network, the batch data size B is 1; if t sample images are input into the semantic segmentation network at the same time, the batch data size B is t.

[0097] In the training process of the above-mentioned target semantic segmentation network, the server obtains a set of training samples; inputs the sample image into the initial semantic segmentation network to obtain the training segmentation result output by the initial semantic segmentation network; calculates the total loss value using the pre-set loss function and the training segmentation result; adjusts the adjustable parameters in the initial semantic segmentation network according to the total loss value until the total loss value meets the convergence condition, and uses the semantic segmentation network when the total loss value meets the convergence condition as the target semantic segmentation network. In the disclosed embodiment, not only the difference between the training segmentation result and the annotation corresponding to the sample image is taken into account, but also semantic segmentation is a structured information prediction task, and each pixel point is not independent, and pixels with the same semantic label are correlated. During the training process, the semantic segmentation network is forced to produce more consistent classifications for the same objects. Therefore, not only the classification accuracy of the trained target semantic segmentation network is higher, but also the intra-class diversity can be reduced.

[0098] In one embodiment, if Figure 4As shown, the above step of calculating the total loss value using the preset loss function and the training segmentation result may include:

[0099] Step 401: The server calculates a first loss value using a preset first loss function and a training segmentation result.

[0100] The first loss value represents the correlation between pixels with similar semantic labels in the sample image.

[0101] Based on the training segmentation results, the server counts the pixel points corresponding to each type of training semantic label to obtain a set of pixel points corresponding to each type of training semantic label; for the set of pixel points corresponding to each type of training semantic label, the server uses the first loss function to calculate the divergence sum of the probabilities of every two pixels in the pixel point set to obtain the first divergence sum corresponding to each type of training semantic label; the server sums the first divergence sums corresponding to multiple types of training semantic labels to obtain a first loss value.

[0102] For example, the server determines that the training segmentation results include training semantic label 1, training semantic label 2, and training semantic label 3, that is, including three types of training semantic labels. Among them, the pixel points corresponding to the training semantic label 1 constitute the pixel point set The pixel points corresponding to the training semantic label 2 constitute a pixel point set The pixel points corresponding to the training semantic label 3 constitute the pixel point set That is, we get the pixel point sets corresponding to various training semantic labels. Calculate the divergence of the probability of every two pixels, and then sum the calculated divergences to obtain the first divergence sum M1 corresponding to the training semantic label 1. Similarly, calculate the first divergence sum M2 corresponding to the training semantic label 2, and the first divergence sum M3 corresponding to the training semantic label 3. Then, sum the first divergence sum M1 corresponding to the training semantic label 1, the first divergence sum M2 corresponding to the training semantic label 2, and the first divergence sum M3 corresponding to the training semantic label 3 to obtain the first loss value L1, as shown in formula (1):

[0103]

[0104] Among them, i is the serial number of the pixel set, and C is the number of categories.

[0105] The above-mentioned divergence (Kullback-Leibler divergence) is an asymmetric measure of the difference between two probability distributions (probability distribution). A more accurate understanding is to measure the information loss (infomation lost) of one distribution compared to another distribution. Divergence is also called relative entropy.

[0106] Step 402: Calculate a second loss value using a preset second loss function and the training segmentation result.

[0107] The second loss value represents the difference between the training segmentation result and the annotation.

[0108] The server uses the second loss function to calculate the loss between the probability of each pixel in the training segmentation result and the actual semantic label of the corresponding pixel in the annotation to obtain the loss value corresponding to each pixel; the loss values ​​corresponding to multiple pixels are summed to obtain the second loss value.

[0109] For example, the server uses the second loss function to calculate the loss between the training semantic label of the jth pixel in the training segmentation result and the actual semantic label of each jth pixel in the annotation, and obtains the loss value corresponding to the jth pixel. Similarly, the loss values ​​of all pixels are calculated separately, and the loss values ​​of all pixels are summed to obtain the second loss value L2, see formula (2):

[0110]

[0111] Among them, j is the serial number of the pixel, m is the total number of pixels in the sample image, P j is the probability of the jth pixel, l i is the actual semantic label of the j-th pixel, L CE is the second loss function.

[0112] Step 403: sum the first loss value and the second loss value to obtain a total loss value.

[0113] After obtaining the first loss value and the second loss value, the first loss value and the second loss value are summed to obtain the total loss value L, as shown in formula (3):

[0114]

[0115] Among them, i is the serial number of the pixel set, C is the number of categories, j is the serial number of the pixel, m is the total number of pixels in the sample image, P j is the probability of the jth pixel, l i is the actual semantic label of the j-th pixel, L CE is the second loss function.

[0116] In the above process of calculating the total loss value using the preset loss function and the training segmentation result, the server calculates the first loss value using the preset first loss function and the training segmentation result; calculates the second loss value using the preset second loss function and the training segmentation result; and sums the first loss value and the second loss value to obtain the total loss value. In the disclosed embodiment, the first loss function is used to calculate the correlation between pixels with similar semantic labels, and the second loss function is used to calculate the difference between the training segmentation result and the annotation, and the total loss value is obtained by combining the correlation and the difference. That is, during the training process, pixels with similar semantic labels are self-distilled, forcing the semantic segmentation network to produce more consistent classifications for similar objects. Therefore, not only the classification accuracy of the target semantic segmentation network is improved, but also the intra-class diversity can be reduced.

[0117] In one embodiment, Figure 5 As shown, the above step of using the first loss function to calculate the divergence sum of the probabilities of every two pixels in the pixel point set to obtain the first divergence sum corresponding to each type of training semantic label may include:

[0118] Step 501, for each pixel point set, the server takes a pixel point in the pixel point set as the target pixel point, and uses the first loss function to calculate the second divergence sum of the target pixel point and the pixel points in the pixel point set except the target pixel point, until the pixel points in the pixel point set are cycled through, and multiple second divergence sums are obtained.

[0119] In actual operation, for a set of pixels Take the jth pixel as the target pixel and calculate the probability of the jth pixel and the pixel set The divergence between the probabilities of other pixels in the jth pixel and the divergence between the probabilities of multiple pixels is obtained. These divergences are summed to obtain the second divergence corresponding to the jth pixel and N j , see formula (3):

[0120]

[0121] Among them, j is the serial number of the pixel point, j' is the pixel point set The serial numbers of other pixels except pixel j, P j is the probability of the jth pixel, P j' is the probability of the j'th pixel, n is the total number of pixels in the pixel set, and KL is the divergence calculation function.

[0122] The second divergence sum corresponding to each pixel point in the pixel point set is calculated according to formula (3) to obtain multiple second divergence sums.

[0123] The above-mentioned divergence (Kullback-Leibler divergence) is an asymmetric measure of the difference between two probability distributions (probability distribution). A more accurate understanding is to measure the information loss (infomation lost) of one distribution compared to another distribution. Divergence is also called relative entropy.

[0124] Step 502: Sum multiple second divergence sums to obtain a first divergence sum corresponding to a class of training semantic labels.

[0125] Sum multiple second divergences to get a pixel point set The corresponding first divergence sum is the first divergence sum M1 corresponding to the training semantic label 1, see formula (4):

[0126]

[0127] Among them, j is the serial number of the pixel point, and n is the total number of pixels in the pixel point set.

[0128] According to formula (4), the first divergence sum corresponding to each type of training semantic label can be calculated. According to formulas (1), (3), and (4), the first divergence sum corresponding to multiple types of training semantic labels can be summed to obtain the first loss value L1, as shown in formula (5):

[0129]

[0130] Among them, i is the serial number of the pixel set, C is the number of categories, j is the serial number of the pixel, and j' is the pixel set The serial numbers of other pixels except pixel j in the pixel set n is The total number of pixels in P j is the probability of the jth pixel, P j' is the probability of the j'th pixel.

[0131] The total loss value L can be obtained by using the second loss value calculated by formula (3) and the first loss value calculated by formula (5), as shown in formula (6):

[0132]

[0133] Among them, i is the serial number of the pixel set, C is the number of categories, j is the serial number of the pixel, and j' is the pixel set The serial numbers of other pixels except pixel j in the pixel set n is The total number of pixels in the sample image, m is the total number of pixels in the sample image, P j is the probability of the jth pixel, Pj' is the probability of the j'th pixel.

[0134] In the process of using the first loss function to calculate the divergence sum of the probabilities of every two pixels in the pixel set to obtain the first divergence sum corresponding to each type of training semantic label, for each pixel set, the server uses a pixel in the pixel set as the target pixel, and uses the first loss function to calculate the second divergence sum of the target pixel and the pixels in the pixel set other than the target pixel, until the pixel points in the pixel set are cycled through to obtain multiple second divergence sums; the multiple second divergence sums are summed to obtain the first divergence sum corresponding to a type of training semantic label. In the disclosed embodiment, by calculating the divergence to calculate the correlation between every two pixels with the same semantic label in the sample image, self-distillation of pixels with the same semantic label can be achieved, thereby forcing the semantic segmentation network to produce more consistent classifications for objects of the same type.

[0135] It should be understood that although Figure 2-Figure 5 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2-Figure 5 At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.

[0136] In one embodiment, Figure 6 As shown, a semantic segmentation device is provided, comprising:

[0137] A target image acquisition module 601 is used to acquire a target image to be semantically segmented;

[0138] The semantic segmentation module 602 is used to input the target image into a pre-trained target semantic segmentation network to obtain a target segmentation result output by the target semantic segmentation network; the target segmentation result includes a target semantic label corresponding to each pixel in the target image;

[0139] The target semantic segmentation network is obtained by training based on the correlation between pixels with similar semantic labels in the sample image and the annotations corresponding to the sample image.

[0140] In one embodiment, if Figure 7 As shown, the device also includes:

[0141] The set acquisition module 603 is used to acquire a training sample set; the training sample set includes a plurality of sample images and annotations corresponding to each sample image; the annotations corresponding to the sample image include actual semantic labels corresponding to each pixel in the sample image;

[0142] The result output module 604 is used to input the sample image into the initial semantic segmentation network to obtain the training segmentation result output by the initial semantic segmentation network; the training segmentation result includes the training semantic label corresponding to each pixel in the sample image;

[0143] The loss calculation module 605 is used to calculate the total loss value using a preset loss function and the training segmentation result; the total loss value represents the correlation between pixels with similar semantic labels in the sample image, and the difference between the training segmentation result and the annotation corresponding to the sample image;

[0144] The parameter adjustment module 606 is used to adjust the adjustable parameters in the initial semantic segmentation network according to the total loss value until the total loss value meets the convergence condition, and use the semantic segmentation network when the total loss value meets the convergence condition as the target semantic segmentation network.

[0145] In one embodiment, the loss calculation module 605 includes:

[0146] A first loss calculation submodule is used to calculate a first loss value using a preset first loss function and a training segmentation result; the first loss value represents the correlation between pixels with similar semantic labels in the sample image;

[0147] A second loss calculation submodule, used to calculate a second loss value using a preset second loss function and the training segmentation result; the second loss value represents the difference between the training segmentation result and the annotation;

[0148] The total loss calculation submodule is used to sum the first loss value and the second loss value to obtain a total loss value.

[0149] In one of the embodiments, the above-mentioned first loss calculation submodule is specifically used to count the pixel points corresponding to each type of training semantic label according to the training segmentation results, and obtain the pixel point sets corresponding to each type of training semantic label; for the pixel point sets corresponding to each type of training semantic label, use the first loss function to calculate the divergence sum of the probabilities of every two pixels in the pixel point set, and obtain the first divergence sum corresponding to each type of training semantic label; sum the first divergence sums corresponding to multiple types of training semantic labels to obtain the first loss value.

[0150] In one of the embodiments, the above-mentioned first loss calculation submodule is specifically used to, for each pixel point set, take a pixel point in the pixel point set as the target pixel point, and use the first loss function to calculate the second divergence sum of the target pixel point and the pixel points in the pixel point set other than the target pixel point, until the pixel points in the pixel point set are cycled through, to obtain multiple second divergence sums; and sum the multiple second divergence sums to obtain the first divergence sum corresponding to a class of training semantic labels.

[0151] In one of the embodiments, the above-mentioned second loss calculation submodule is specifically used to use the second loss function to calculate the loss between the probability of each pixel point in the training segmentation result and the actual semantic label of the corresponding pixel point in the annotation to obtain the loss value corresponding to each pixel point; the loss values ​​corresponding to multiple pixels are summed up to obtain the second loss value.

[0152] In one of the embodiments, the sample images, annotations, and training segmentation results are all multi-dimensional vectors;

[0153] The dimensions of the sample image include batch size, number of categories, sample image width, and sample image height;

[0154] The annotated dimensions include batch data size, sample image width, and sample image height;

[0155] The dimensions of the training segmentation results include batch size, number of categories, sample image width, and sample image height.

[0156] For the specific definition of the semantic segmentation device, please refer to the definition of the semantic segmentation method above, which will not be repeated here. Each module in the above-mentioned semantic segmentation device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0157] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 8 As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store semantic segmentation data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a semantic segmentation method is implemented.

[0158] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0159] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:

[0160] Obtain the target image to be semantically segmented;

[0161] Input the target image into the pre-trained target semantic segmentation network to obtain the target segmentation result output by the target semantic segmentation network; the target segmentation result includes the target semantic label corresponding to each pixel in the target image;

[0162] Among them, the target semantic segmentation network is trained based on the correlation between pixels with similar semantic labels in the sample image and the annotations corresponding to the sample image.

[0163] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0164] Acquire a training sample set; the training sample set includes multiple sample images and annotations corresponding to each sample image; the annotations corresponding to the sample image include actual semantic labels corresponding to each pixel in the sample image;

[0165] Input the sample image into the initial semantic segmentation network to obtain the training segmentation result output by the initial semantic segmentation network; the training segmentation result includes the training semantic label corresponding to each pixel in the sample image;

[0166] The total loss value is calculated using the preset loss function and the training segmentation result; the total loss value represents the correlation between pixels with similar semantic labels in the sample image, and the difference between the training segmentation result and the annotation corresponding to the sample image;

[0167] According to the total loss value, the adjustable parameters in the initial semantic segmentation network are adjusted until the total loss value meets the convergence condition, and the semantic segmentation network when the total loss value meets the convergence condition is used as the target semantic segmentation network.

[0168] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0169] A first loss value is calculated using a preset first loss function and a training segmentation result; the first loss value represents the correlation between pixels with similar semantic labels in the sample image;

[0170] Calculating a second loss value using a preset second loss function and the training segmentation result; the second loss value represents the difference between the training segmentation result and the annotation;

[0171] The first loss value and the second loss value are summed to obtain a total loss value.

[0172] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0173] According to the training segmentation results, the pixel points corresponding to each type of training semantic label are counted to obtain the pixel point sets corresponding to each type of training semantic label;

[0174] For each pixel point set corresponding to each type of training semantic label, the first loss function is used to calculate the divergence sum of the probabilities of every two pixels in the pixel point set to obtain the first divergence sum corresponding to each type of training semantic label;

[0175] The first divergence sums corresponding to multiple types of training semantic labels are summed up to obtain the first loss value.

[0176] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0177] For each pixel point set, a pixel point in the pixel point set is taken as a target pixel point, and a second divergence sum of the target pixel point and the pixel points in the pixel point set other than the target pixel point is calculated using a first loss function until the pixel points in the pixel point set are cycled through, thereby obtaining a plurality of second divergence sums;

[0178] The sum of multiple second divergence sums is calculated to obtain the first divergence sum corresponding to a class of training semantic labels.

[0179] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0180] The second loss function is used to calculate the loss between the probability of each pixel in the training segmentation result and the actual semantic label of the corresponding pixel in the annotation, and the loss value corresponding to each pixel is obtained;

[0181] The loss values ​​corresponding to multiple pixel points are summed up to obtain a second loss value.

[0182] In one embodiment, the sample images, annotations, and training segmentation results are all multi-dimensional vectors;

[0183] The dimensions of the sample image include batch size, number of categories, sample image width, and sample image height;

[0184] The annotated dimensions include batch data size, sample image width, and sample image height;

[0185] The dimensions of the training segmentation results include batch size, number of categories, sample image width, and sample image height.

[0186] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:

[0187] Obtain the target image to be semantically segmented;

[0188] Input the target image into the pre-trained target semantic segmentation network to obtain the target segmentation result output by the target semantic segmentation network; the target segmentation result includes the target semantic label corresponding to each pixel in the target image;

[0189] Among them, the target semantic segmentation network is trained based on the correlation between pixels with similar semantic labels in the sample image and the annotations corresponding to the sample image.

[0190] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0191] Acquire a training sample set; the training sample set includes multiple sample images and annotations corresponding to each sample image; the annotations corresponding to the sample image include actual semantic labels corresponding to each pixel in the sample image;

[0192] Input the sample image into the initial semantic segmentation network to obtain the training segmentation result output by the initial semantic segmentation network; the training segmentation result includes the training semantic label corresponding to each pixel in the sample image;

[0193] The total loss value is calculated using the preset loss function and the training segmentation result; the total loss value represents the correlation between pixels with similar semantic labels in the sample image, and the difference between the training segmentation result and the annotation corresponding to the sample image;

[0194] According to the total loss value, the adjustable parameters in the initial semantic segmentation network are adjusted until the total loss value meets the convergence condition, and the semantic segmentation network when the total loss value meets the convergence condition is used as the target semantic segmentation network.

[0195] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0196] A first loss value is calculated using a preset first loss function and a training segmentation result; the first loss value represents the correlation between pixels with similar semantic labels in the sample image;

[0197] Calculating a second loss value using a preset second loss function and the training segmentation result; the second loss value represents the difference between the training segmentation result and the annotation;

[0198] The first loss value and the second loss value are summed to obtain a total loss value.

[0199] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0200] According to the training segmentation results, the pixel points corresponding to each type of training semantic label are counted to obtain the pixel point sets corresponding to each type of training semantic label;

[0201] For each pixel point set corresponding to each type of training semantic label, the first loss function is used to calculate the divergence sum of the probabilities of every two pixels in the pixel point set to obtain the first divergence sum corresponding to each type of training semantic label;

[0202] The first divergence sums corresponding to multiple types of training semantic labels are summed up to obtain the first loss value.

[0203] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0204] For each pixel point set, a pixel point in the pixel point set is taken as a target pixel point, and a second divergence sum of the target pixel point and the pixel points in the pixel point set other than the target pixel point is calculated using a first loss function until the pixel points in the pixel point set are cycled through, thereby obtaining a plurality of second divergence sums;

[0205] The sum of multiple second divergence sums is calculated to obtain the first divergence sum corresponding to a class of training semantic labels.

[0206] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0207] The second loss function is used to calculate the loss between the probability of each pixel in the training segmentation result and the actual semantic label of the corresponding pixel in the annotation, and the loss value corresponding to each pixel is obtained;

[0208] The loss values ​​corresponding to multiple pixel points are summed up to obtain a second loss value.

[0209] In one embodiment, the sample images, annotations, and training segmentation results are all multi-dimensional vectors;

[0210] The dimensions of the sample image include batch size, number of categories, sample image width, and sample image height;

[0211] The annotated dimensions include batch data size, sample image width, and sample image height;

[0212] The dimensions of the training segmentation results include batch size, number of categories, sample image width, and sample image height.

[0213] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).

[0214] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0215] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A semantic segmentation method, characterized in that: The method comprises: Obtain the target image to be semantically segmented; Inputting the target image into a pre-trained target semantic segmentation network to obtain a target segmentation result output by the target semantic segmentation network; the target segmentation result includes a target semantic label corresponding to each pixel in the target image; Before inputting the target image into a pre-trained target semantic segmentation network, the method further includes: Acquire a training sample set; the training sample set includes a plurality of sample images and annotations corresponding to each of the sample images; the annotations corresponding to the sample images include actual semantic labels corresponding to each pixel in the sample images; Inputting the sample image into an initial semantic segmentation network to obtain a training segmentation result output by the initial semantic segmentation network; the training segmentation result includes a training semantic label corresponding to each pixel in the sample image; According to the training segmentation result, the pixel points corresponding to each type of training semantic label are counted to obtain the pixel point sets corresponding to each type of training semantic label; for the pixel point sets corresponding to each type of training semantic label, a pixel point in the pixel point set is used as a target pixel point, and a second divergence sum of the target pixel point and the pixel points in the pixel point set other than the target pixel point is calculated using a first loss function until the pixel points in the pixel point set are cycled through, thereby obtaining a plurality of the second divergence sums; the plurality of the second divergence sums are summed to obtain a first divergence sum corresponding to a type of training semantic label; The first divergence sums corresponding to multiple types of training semantic labels are summed up to obtain a first loss value; The first loss value represents the correlation between pixels with similar semantic labels in the sample image; the second loss value is calculated using a preset second loss function and the training segmentation result; the second loss value represents the difference between the training segmentation result and the annotation; the first loss value and the second loss value are summed to obtain a total loss value; The total loss value represents the correlation between pixels with similar semantic labels in the sample image, and the difference between the training segmentation result and the annotation corresponding to the sample image; The adjustable parameters in the initial semantic segmentation network are adjusted according to the total loss value until the total loss value meets the convergence condition, and the semantic segmentation network when the total loss value meets the convergence condition is used as the target semantic segmentation network.

2. The method according to claim 1, characterized in that The calculating the second loss value by using the preset second loss function and the training segmentation result includes: The second loss function is used to calculate the loss between the probability of each pixel in the training segmentation result and the actual semantic label of the corresponding pixel in the annotation to obtain a loss value corresponding to each pixel; The loss values ​​corresponding to multiple pixel points are summed up to obtain the second loss value.

3. The method according to claim 1, characterized in that: The sample image, the annotation and the training segmentation result are all multi-dimensional vectors; The dimensions of the sample image include batch data size, number of categories, sample image width and sample image height; The annotated dimensions include batch data size, sample image width and sample image height; The dimensions of the training segmentation result include batch data size, number of categories, sample image width and sample image height.

4. The method according to claim 1, characterized in that: The target semantic segmentation network includes a pyramid scene parsing network or a bidirectional segmentation network for real-time semantic segmentation.

5. The method according to claim 1, characterized in that The total loss value is: Among them, i is the serial number of the pixel set, C is the number of categories, j is the serial number of the pixel, m is the total number of pixels in the sample image, P j is the probability of the jth pixel, l i is the actual semantic label of the j-th pixel, L1 is the first loss function, and L2 is the second loss function.

6. A semantic segmentation device, characterized in that: The device comprises: A target image acquisition module is used to acquire a target image to be semantically segmented; A semantic segmentation module, used to input the target image into a pre-trained target semantic segmentation network to obtain a target segmentation result output by the target semantic segmentation network; the target segmentation result includes a target semantic label corresponding to each pixel in the target image; A set acquisition module is used to acquire a training sample set; the training sample set includes a plurality of sample images and annotations corresponding to each of the sample images; the annotations corresponding to the sample images include actual semantic labels corresponding to each pixel in the sample images; A result output module, used for inputting the sample image into an initial semantic segmentation network to obtain a training segmentation result output by the initial semantic segmentation network; the training segmentation result includes a training semantic label corresponding to each pixel in the sample image; The loss calculation module is used to count the pixel points corresponding to each type of training semantic label according to the training segmentation result to obtain the pixel point set corresponding to each type of training semantic label; for the pixel point set corresponding to each type of training semantic label, a pixel point in the pixel point set is used as a target pixel point, and a first loss function is used to calculate the second divergence sum of the target pixel point and the pixel points in the pixel point set other than the target pixel point, until the pixel points in the pixel point set are cycled through, so as to obtain a plurality of the second divergence sums; summing the plurality of the second divergence sums to obtain a first divergence sum corresponding to a type of training semantic label; and summing the plurality of the second divergence sums to obtain a first divergence sum corresponding to a type of training semantic label. The first divergence and the first divergence corresponding to the class training semantic label are summed to obtain a first loss value; the first loss value represents the correlation between the pixels with the same semantic label in the sample image; the second loss value is calculated using a preset second loss function and the training segmentation result; the second loss value represents the difference between the training segmentation result and the annotation; the first loss value and the second loss value are summed to obtain a total loss value; the total loss value represents the correlation between the pixels with the same semantic label in the sample image, and the difference between the training segmentation result and the annotation corresponding to the sample image; A parameter adjustment module is used to adjust the adjustable parameters in the initial semantic segmentation network according to the total loss value until the total loss value meets the convergence condition, and use the semantic segmentation network when the total loss value meets the convergence condition as the target semantic segmentation network.

7. The device according to claim 6, characterized in that The loss calculation module includes: The second loss calculation submodule is used to use the second loss function to calculate the loss between the probability of each pixel point in the training segmentation result and the actual semantic label of the corresponding pixel point in the annotation to obtain the loss value corresponding to each pixel point; and sum the loss values ​​corresponding to multiple pixels to obtain the second loss value.

8. The device according to claim 6, characterized in that The sample image, the annotation and the training segmentation result are all multi-dimensional vectors; The dimensions of the sample image include batch data size, number of categories, sample image width and sample image height; The annotated dimensions include batch data size, sample image width and sample image height; The dimensions of the training segmentation result include batch data size, number of categories, sample image width and sample image height.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.