A cross-domain semantic segmentation method based on three-branch cross-training
Through the three-branch cross-training and feature alignment strategy, the problem of pseudo-label inaccuracy and error accumulation in cross-domain semantic segmentation is solved, the accuracy and reliability of semantic segmentation are improved, and each segmentation network learns different and accurate targets. domain knowledge.
Patent Information
- Application Number
- CN202210323281.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-29
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2042-03-29
AI Technical Summary
Existing cross-domain semantic segmentation methods have large differences in data distribution between the source domain and the target domain, resulting in inaccurate pseudo labels and error accumulation, resulting in errors in the unique information learned by the model, and multi-branch cross-training does not fully utilize the capabilities of multiple branches. Reduced reliability of joint forecasts.
A three-branch cross-training method is adopted, in which three segmentation networks share a feature extraction network. Any two branches generate pseudo labels that are independent of the third branch for training. The model is updated through adversarial loss and label prediction loss, and through feature alignment. and pseudo-label evaluation strategies to improve segmentation results.
It improves the accuracy and reliability of cross-domain semantic segmentation, ensures that each segmentation network learns different and accurate target domain-specific knowledge, and improves the semantic segmentation effect.
Smart Images

Figure CN114842199B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of unsupervised domain adaptation technology, and in particular to a cross-domain semantic segmentation method based on three-branch cross-training. Background Art
[0002] Semantic segmentation aims to assign semantic class labels to each pixel of an image. It is a key method to provide comprehensive scene understanding for various real-world applications (such as autonomous driving and robots). However, it is very cumbersome to manually label each pixel in an image. The more complex the scene in the image, the more difficult it is to accurately label each pixel manually. This makes the available training data for semantic segmentation tasks extremely limited. Therefore, data generated by the virtual world (source domain) that can automatically label scenes can be used to train the model so that the model can automatically label unlabeled data in real life (target domain). However, due to the huge difference in data distribution between the source domain and the target domain, the cross-domain semantic segmentation effect is not good, and a better technical solution is urgently needed.
[0003] In recent years, self-training methods have been widely used in the field of cross-domain semantic segmentation. Self-training methods use pseudo-labels, that is, the target domain results predicted by the model itself, to train the model to learn knowledge specific to the target domain. However, the inaccurate pseudo-labels and the self-training mode that easily accumulates errors make the model usually learn wrong specific information. So far, many methods have tried to use a fixed probability threshold or a fixed ratio of pixels to select high-confidence pseudo-labels, but they still cannot solve the problem that high-confidence wrong labels will be repeatedly trained. Some methods that use multiple segmentation networks try to cross-train two branches, and finally generate pseudo-labels together or let one branch generate auxiliary information to adjust the prediction results of the main branch. However, these methods do not fully utilize the capabilities of multiple branches, and the branch prediction results are close to the same, which reduces the reliability of the joint prediction. Summary of the invention
[0004] The present invention provides a cross-domain semantic segmentation method based on three-branch cross-training, which is used to solve or at least partially solve the technical problem of poor cross-domain segmentation effect existing in the prior art.
[0005] In order to solve the above technical problems, the present invention provides a cross-domain semantic segmentation method based on three-branch cross-training, characterized in that it is applied to a three-branch model, the three-branch model includes three segmentation networks and a discriminator, the three segmentation networks share a feature extraction network, any two branches generate pseudo labels containing knowledge irrelevant to the third branch to train the third branch, and the method includes:
[0006] S1: Based on the input source domain data, labels, and target domain data, the adversarial loss of the feature extraction network and the discriminator is obtained;
[0007] S2: Based on the source domain data, the segmentation loss of the source domain is obtained;
[0008] S3: Extract source domain semantic features from source domain data and store the center points of the source domain semantic features;
[0009] S4: For the target domain data, the other two branches predict the probability distribution and calculate the pseudo-label. Then, the semantic features of the target domain are extracted and the center point of each extracted target domain feature is aligned with the stored center point of the source domain.
[0010] S5: Obtain label prediction loss based on the predicted probability distribution obtained by the other two branches;
[0011] S6: The loss of each branch is obtained based on the segmentation loss of the source domain and the label prediction loss;
[0012] S7: Obtain the total loss of the three-branch model according to the loss of each branch, and update the three-branch model;
[0013] S8: Cross-domain semantic segmentation using the updated three-branch model.
[0014] In one embodiment, step S1 includes:
[0015] Step S1 includes:
[0016] S1.1: Calculate the adversarial loss of the source domain data,
[0017] L src_adv =(D(F(x s ))) 2
[0018] Among them, x s is the source domain data, F(x s ) represents the features of the source domain data extracted by the feature extraction network, D(F(x s )) represents the probability that the discriminator judges that the extracted source domain features come from the source domain data;
[0019] S1.2: Calculate the adversarial loss of the target domain data,
[0020] L tgt_adv =(D(F(x t ))-1) 2
[0021] Among them, x t is the target domain data, F(x t ) represents the features of the target domain data extracted by the feature extraction network, D(F(x t)) represents the probability that the discriminator determines that the extracted target domain features come from the source domain data;
[0022] S1.3: Calculate the adversarial loss of the entire model.
[0023] L adv =λ adv L src_adv +λ adv L tgt_adv
[0024] Among them, λ adv is the weight of the adversarial loss, L src_adv , L tgt_adv are the adversarial losses on the source domain and target domain, respectively.
[0025] In one implementation, the segmentation loss of the source domain in step S2 is calculated as follows:
[0026]
[0027] in, For branch F i Calculate the source domain segmentation loss, x s is the source domain data, y s is the label of the source domain data, x t is the target domain data, F(x s ) is the feature of the source domain data extracted by the feature extraction network, F i (F(x s )) represents branch F i The classification probability distribution is obtained after parsing the features of the source domain data extracted from the feature extraction network.
[0028] In one embodiment, the categories include a foreground category f and a background category b, and step S3 includes:
[0029] For a single category, the foreground category extracts all connected blocks M in the image f The feature center point The background category extracts the feature center points of all pixels in the image The calculation formula is:
[0030]
[0031]
[0032] Among them, f i Representative branch F i The feature map, M f,j represents the jth connected graph for foreground category f, HW represents the length and width of the image, It is an indicator function. When the expression in the brackets is true, the value is 1, otherwise it is 0. Represents the sum of each pixel of the image, x s,hw It represents the source domain data x s The pixel point at the length and width hw, y s,hw Represents the label value at the length and width hw, that is, the category number;
[0033] The extracted feature center points are stored in a queue, wherein the queue stores a preset number of center points by category.
[0034] In one embodiment, step S4 includes:
[0035] S4.1: Calculate the probability distribution of the other two branches:
[0036] P a =F a (F(x t ))a=j,k
[0037] Among them, P a represents the probability distribution predicted by the other two branches, j and k represent the numbers of the other two branches, and F(x t ) represents the features of the target domain data extracted by the feature extraction network, F a (F(x t )) represents the classification probability distribution obtained after the other two branches parse the features of the target domain data extracted from the feature extraction network;
[0038] S4.2: Calculate pseudo labels based on the probability distribution of the other two branches,
[0039] y a = argmax P a a=j,k
[0040]
[0041] in, For branch F i Pseudo labels of
[0042] S4.3: Calculate the semantic alignment of background category features. The calculation method is:
[0043]
[0044] Among them, B represents all background categories, Representative branch F i Among the stored source domain feature center points, the ath center point belongs to category b. Indicates F i The total loss of the background category, Indicates the calculation of each background category b, In the example, the subscripts represent the data source, target domain t, source domain s; the first superscript i represents that the feature comes from F i Branch, the second superscript indicates that the feature comes from category b, The third superscript of represents the center point number stored in the queue. Represents all source domain features in the queue In the above example, we calculate the target and features closest distance;
[0045] S4.4: Calculate the semantic alignment of foreground category features. The calculation method is:
[0046]
[0047] Among them, F represents all foreground categories, Representative branch F i Among the stored source domain feature center points, the ath center point belongs to category f. The first term of the formula represents the closest distance between the target domain feature and the source domain feature of different categories. The second term represents the closest distance between the target domain feature and the source domain feature of the same category. The third term α is the size of the distance that can be controlled. Indicates F i The total loss for the foreground class.
[0048] In one embodiment, step S5 includes:
[0049] S5.1: Calculate the average probability distribution based on the probability distributions of the remaining two branches. The calculation method is:
[0050]
[0051] Among them, P j , P k Indicates the other two branches F j 、F k The probability distribution of is the average probability distribution;
[0052] S5.2: Based on the average probability distribution, calculate the difference between the two probability distributions as follows:
[0053]
[0054] Where w is the difference between the two probability distributions;
[0055] S5.3: Calculate the label prediction loss based on the difference between the two probability distributions, as follows:
[0056]
[0057] in, Indicates F i The label prediction loss is Indicates branch F i The pseudo labels of x t represents the target domain data, F(x t ) represents the features of the target domain data extracted by the feature extraction network, F i (F(x t )) represents branch F i The classification probability distribution is obtained after parsing the features of the target domain data extracted from the feature extraction network.
[0058] In one embodiment, step S6 calculates the loss of each branch according to the following formula:
[0059]
[0060] in, Respectively represent branches F i Label prediction loss, segmentation loss, λ tgt represents the weight of label prediction loss, Respectively represent branches F i The total loss of the background category, the total loss of the foreground category, λ b , f Branch F i The weight corresponding to the total loss of the background category and the weight corresponding to the total loss of the foreground category, L i Indicates F i loss.
[0061] In one embodiment, step S7 includes:
[0062] After summing the losses of each branch and adding the adversarial loss of the entire model, we get the total loss of the three-branch model.
[0063] The above one or more technical solutions in the embodiments of the present application have at least one or more of the following technical effects:
[0064] The present invention proposes a cross-domain semantic segmentation method based on three-branch cross-training, based on three segmentation networks cross-training neural network, the three segmentation networks share a feature extraction network, and any two branches generate pseudo labels containing knowledge irrelevant to the third branch to train the third branch (steps S4 to S6). Specifically, the intersection of the pseudo labels of the two branches represents the knowledge with high credibility in the two branches, which is not only different from the two distributions, but also irrelevant to the third distribution. Such cross-training can ensure that the target domain data has three different distributions in the same feature space, and each distribution can learn complementary and high-accuracy target domain-specific knowledge that is different from the three distributions. In this way, the diversity of each segmentation network is guaranteed, and the capabilities of the three networks are fully mined. The total loss of the three-branch model is obtained according to the loss of each branch, and the three-branch model is updated. Finally, the updated three-branch model is used for cross-domain semantic segmentation, which can greatly improve the semantic segmentation effect.
[0065] Furthermore, for the pseudo labels generated based on cross-training, the present invention also proposes two indirect pseudo label alignment strategies. In order to reduce the accumulated prediction error of self-training, the present invention proposes an indirect pseudo label alignment strategy, one of which is to align the segmentation features of the branches, bringing the same category features closer and the different category features farther apart. The second is to evaluate the pseudo labels. The difference in the probability distribution of the target domain data predicted by the two branches is related to the accuracy of the pseudo labels. This is unique information that supplements the pseudo label alignment, thereby further improving the semantic segmentation effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] 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 some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0067] Figure 1 Flow chart of a cross-domain semantic segmentation method based on three-branch cross-training in an embodiment of the present invention;
[0068] Figure 2 This is a feature processing diagram for semantic feature alignment in an embodiment of the present invention;
[0069] Figure 3 A structural diagram of a three-branch model provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0070] In order to prevent low-precision pseudo-labels from affecting the model's learning of target domain-specific knowledge, the present invention proposes three-branch cross-training, where any two branches generate new and unique target domain knowledge to train the third branch, so that each branch can ensure that it has a unique expression distribution in the same feature space. They share a feature extractor to ensure that the three branches have feature distributions that can learn from each other in the same feature space. The different structures of the three branches also ensure the diversity of the initial feature distribution. Subsequently, through a special method of selecting pseudo-labels, the pseudo-labels of each branch are different from the probability distribution of the three branches, ensuring that each branch can obtain new and supplementary target domain knowledge without additional constraints, further enhancing their diversity. This ensures that each branch can fully tap the potential of the architecture, and the results predicted together will have the greatest accuracy.
[0071] Furthermore, in order to maintain diversity, instead of directly aligning pseudo-labels, the present invention also proposes two strategies: one is feature semantic alignment, which extracts the feature center points of each category of each segmentation network, brings the center points of the source domain and the target domain of the background category closer, moves the center points of the source domain and the target domain of different categories of the foreground category farther apart, and brings the center points of the source domain and the target domain of the same category closer; the other is adaptability estimation, which calculates the probability distributions from two different distributions used for the pseudo-labels. According to the theory of multi-views, the greater the difference in the probability distributions, the higher the accuracy of the predicted pseudo-labels.
[0072] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0073] The embodiment of the present invention provides a cross-domain semantic segmentation method based on three-branch cross-training, characterized in that it is applied to a three-branch model, the three-branch model includes three segmentation networks and a discriminator, the three segmentation networks share a feature extraction network, any two branches generate pseudo labels containing knowledge irrelevant to the third branch to train the third branch, and the method includes:
[0074] S1: Based on the input source domain data, labels, and target domain data, the adversarial loss of the feature extraction network and the discriminator is obtained;
[0075] S2: Based on the source domain data, the segmentation loss of the source domain is obtained;
[0076] S3: Extract source domain semantic features from source domain data and store the center points of the source domain semantic features;
[0077] S4: For the target domain data, the other two branches predict the probability distribution and calculate the pseudo-label. Then, the semantic features of the target domain are extracted and the center point of each extracted target domain feature is aligned with the stored center point of the source domain.
[0078] S5: Obtain label prediction loss based on the predicted probability distribution obtained by the other two branches;
[0079] S6: The loss of each branch is obtained based on the segmentation loss of the source domain and the label prediction loss;
[0080] S7: The total loss of the three-branch model is obtained according to the loss of each branch, the adversarial loss of the feature extraction network and the discriminator, and the three-branch model is updated;
[0081] S8: Cross-domain semantic segmentation using the updated three-branch model.
[0082] See also Figure 1 , is a flowchart of the method proposed in the present invention, which divides the whole model (three-branch model) training process into the source domain data with labels and the target domain data that needs pseudo labels. The middle part shows the training process of the source domain data: first, the segmentation algorithm of the labels from the source domain, and then the extraction and storage of the semantic features of the source domain; the right side (F a The training process of the target domain data is as follows: the pseudo-label is calculated, and then the accuracy of the pseudo-label is obtained according to the probability distribution of the other two branches, and the pseudo-label is aligned. Then, the feature center points of each target domain extracted are aligned with the large number of source domain center points that have been stored. Finally, the entire model is updated.
[0083] The structure of the three-branch model is as follows: Figure 3 As shown, F1, F2 and F3 are three different branches (each branch is a segmentation network), D is the discriminator, and F is a shared feature extraction network. The three branches have different structures and are trained in pairs, which can meet the diversity and ensure the capability of the model.
[0084] Specifically, all three branches are composed of two parts, including a feature parser and a classifier. The classifier has the same structure, which is composed of multiple convolutional neural networks with different kernel sizes in parallel, trying to capture multi-scale features. The feature parser has a different structure. The feature parser of F1 imitates the fifth layer design of ResNet in the experiment, and is composed of three standard residual blocks to obtain general feature expressions. The feature parser of F3 has fewer layers than F1 in the experiment to extract shallow expressions of features. The number of layers of F2 is the same as F1, but the kernel of the convolution layer is larger to obtain a wider feature expression.
[0085] It should be noted that Figure 1 The flowchart shown in the figure calculates the number of category features and the feature loss calculation separately. Since there are usually multiple background categories, they need to be judged and calculated separately. The process is simplified to one category calculation, and the foreground category is similar.
[0086] In the cross-domain semantic segmentation method based on three-branch cross-training, the model used includes a feature extraction network F. The input data is extracted from the image features through the feature extraction network, and then passes through three branches F. i , F j , F k The model also includes a discriminator D, which is used to fuse the features extracted by the feature extraction network and reduce the difference between the features of the two domains.
[0087] In the cross-domain semantic segmentation method based on three-branch cross-training, the three branches F i , F j , F k And the processing is consistent, F a Represents any of the three branches.
[0088] In one embodiment, step S1 includes:
[0089] S1.1: Calculate the adversarial loss of the source domain data,
[0090] L src_adv =(D(F(x s ))) 2
[0091] Among them, x s is the source domain data, F(x s ) represents the features of the source domain data extracted by the feature extraction network, D(F(x s )) represents the probability that the discriminator judges that the extracted source domain features come from the source domain data;
[0092] S1.2: Calculate the adversarial loss of the target domain data,
[0093] Ltgt_adv =(D(F(x t ))-1) 2
[0094] Among them, x t is the target domain data, F(x t ) represents the features of the target domain data extracted by the feature extraction network, D(F(x t )) represents the probability that the discriminator determines that the extracted target domain features come from the source domain data;
[0095] S1.3: Calculate the adversarial loss of the entire model.
[0096] L adv =λ adv L src_adv +λ adv L tgt_adv
[0097] Among them, λ adv is the weight of the adversarial loss, L src_adv , L tgt_adv are the adversarial losses on the source domain and target domain, respectively.
[0098] Specifically, step S1 needs to mix the features of the source domain and the target domain data. The input data includes the source domain data x s , that is, a normal RGB three-channel image, and the source domain label y s , that is, a one-channel matrix, where the value is the category number, the target domain data x t , which is similar to the source domain data. For the source domain F(x s ), target domain feature F(x t ), the discriminator cannot clearly distinguish the difference. Then F(x s )、F(x t ) represent the source domain features and target domain features extracted by the feature extraction network respectively.
[0099] It should be noted that, in the present invention, image and data have the same meaning, target domain data refers to target domain image, and source domain data refers to source domain image.
[0100] In one implementation, the segmentation loss of the source domain in step S2 is calculated as follows:
[0101]
[0102] in, For branch F i Calculate the source domain segmentation loss, x s is the source domain data, y s is the label of the source domain data, x tis the target domain data, F(x s ) is the feature of the source domain data extracted by the feature extraction network, F i (F(x s )) represents branch F i The classification probability distribution is obtained after parsing the features of the source domain data extracted from the feature extraction network.
[0103] In one embodiment, the categories include a foreground category f and a background category b, and step S3 includes:
[0104] For a single category, the foreground category extracts all connected blocks M in the image f The feature center point The background category extracts the feature center points of all pixels in the image The calculation formula is:
[0105]
[0106]
[0107] Among them, f i Representative branch F i The feature map, M f,j represents the jth connected graph for foreground category f, HW represents the length and width of the image, It is an indicator function. When the expression in the brackets is true, the value is 1, otherwise it is 0. Represents the sum of each pixel of the image, x s,hw Represents the source domain data x s The pixel point at the length and width hw, y s,hw Represents the label value at the length and width hw, that is, the category number;
[0108] The extracted feature center points are stored in a queue, wherein the queue stores a preset number of center points by category.
[0109] Specifically, the queue stores M center points by category and updates them from old to new to ensure the matching between the center points and the model.
[0110] That is to say, the number of feature center points stored in each category is M. The foreground category is divided into connected blocks, and the background category is divided into images, all the pixels belonging to this category in an image. And it is updated from old to new during each iteration. In each iteration, the new source domain image generates center points of some categories, all enter the queue, and then the same number of previous center points are dequeued, so as to ensure that there are always M center points. Among them, when there are less than M center points at the beginning, the number of center points will increase.
[0111] Since the model is updated in each iteration, the old center points are difficult to represent the feature distribution of the new model, so new center points need to be continuously added to ensure the matching of the center points with the three-branch model.
[0112] See also Figure 2 , which is the feature processing map for semantic feature alignment. First, the labels are uniquely hot-tuned and then divided into mask sparse maps of background and foreground categories. The mask map and feature map of the background category are globally average-pooled to obtain a one-dimensional vector, which represents the semantic feature center of the entire image in the feature space. The mask map of the foreground category first extracts the connected blocks and then performs average pooling on each connected block to obtain the center point of each connected block. Finally, the newly generated center point is added to the storage queue. If the queue is full, the oldest center point is removed from the queue. When the queue is not full, it is the pre-training stage, and the target domain feature center is temporarily not involved in the training.
[0113] In one embodiment, step S4 includes:
[0114] S4.1: Calculate the probability distribution of the other two branches:
[0115] P a =F a (F(x t ))a=j,k
[0116] Among them, P a represents the probability distribution predicted by the other two branches, j and k represent the numbers of the other two branches, and F(x t ) represents the features of the target domain data extracted by the feature extraction network, F a (F(x t )) represents the classification probability distribution obtained after the other two branches parse the features of the target domain data extracted from the feature extraction network;
[0117] S4.2: Calculate pseudo labels based on the probability distribution of the other two branches,
[0118] y a = argmax P a a=j,k
[0119]
[0120] in, For branch F i Pseudo labels of
[0121] S4.3: Calculate the semantic alignment of background category features. The calculation method is:
[0122]
[0123] Among them, B represents all background categories, Representative branch F i Among the stored source domain feature center points, the ath center point belongs to category b. Indicates F i The total loss of the background category, Indicates the calculation of each background category b, In the example, the subscripts represent the data source, target domain t, source domain s; the first superscript i represents that the feature comes from F i Branch, the second superscript indicates that the feature comes from category b, The third superscript of represents the center point number stored in the queue. Represents all source domain features in the queue In the above example, we calculate the target and features closest distance;
[0124] S4.4: Calculate the semantic alignment of foreground category features. The calculation method is:
[0125]
[0126] Among them, F represents all foreground categories, Representative branch F i Among the stored source domain feature center points, the ath center point belongs to category f. The first term of the formula represents the closest distance between the target domain feature and the source domain feature of different categories. The second term represents the closest distance between the target domain feature and the source domain feature of the same category. The third term α is the size of the distance that can be controlled. Indicates F i The total loss for the foreground class.
[0127] Specifically, for each pixel in the target domain, the final output of each branch is a probability distribution, which represents the probability of belonging to each category, and the category with the highest probability is considered to be the category of the pixel. a It means F a The probability distribution of the output. When judging whether the source domain semantic features are sufficient, the judgment condition is whether the queue is full, that is, whether the number of source domain center points stored in this category is M. If not, the loss calculation of this category is skipped.
[0128] Since the background category generally occupies most of the area of a picture and is less affected by different regions and is relatively easy to distinguish, feature points can be extracted from the entire picture for alignment. For details, see the formula in step S4.3.
[0129] Since foreground features, such as cars and people, are classified by individuals, the individual differences are large, and the individual occupies a small area of the picture, it is necessary to extract each connected block of a picture and align them one by one. For details, please refer to the formula in step S4.4. The third term α represents the size of the artificial control distance, which is set to 0.1 in this implementation. The entire loss The distance between the target domain feature and the nearest source domain feature of the same type should be closer than the distance between features of different types within a certain distance.
[0130] In one embodiment, step S5 includes:
[0131] S5.1: Calculate the average probability distribution based on the probability distributions of the remaining two branches. The calculation method is:
[0132]
[0133] Among them, P j , P k Indicates the other two branches F j 、F k The probability distribution of is the average probability distribution;
[0134] S5.2: Based on the average probability distribution, calculate the difference between the two probability distributions as follows:
[0135]
[0136] Where w is the difference between the two probability distributions;
[0137] S5.3: Calculate the label prediction loss based on the difference between the two probability distributions, as follows:
[0138]
[0139] in, Indicates F i The label prediction loss is Indicates branch F i The pseudo labels of x t represents the target domain data, F(x t ) represents the features of the target domain data extracted by the feature extraction network, F i (F(x t )) represents branch F i The classification probability distribution is obtained after parsing the features of the target domain data extracted from the feature extraction network.
[0140] Specifically, steps S5.1 to S5.3 are the adaptability estimation. The average probability distribution can be calculated based on the probability distribution of the remaining two branches. Then the dissimilarity between the two probability distributions is obtained as the weight for pseudo-label training.
[0141] Three branches F i , F j , F k , for each pixel, the output probability distribution is P i , P j , P k , the prediction result generated by the probability distribution is y i ,y j ,y k The steps of the present invention can be regarded as calculating F i The steps of the other two branches are the same. a is a variable, representing the other two branches j and k.
[0142] In one embodiment, step S6 calculates the loss of each branch according to the following formula:
[0143]
[0144] in, Respectively represent branches F i Label prediction loss, segmentation loss, λ tgt represents the weight of label prediction loss, Respectively represent branches F i The total loss of the background category, the total loss of the foreground category, λ b , f Branch F i The weight corresponding to the total loss of the background category and the weight corresponding to the total loss of the foreground category, L i Indicates F i loss.
[0145] In one embodiment, step S7 includes:
[0146] After summing the losses of each branch and adding the adversarial loss of the entire model, we get the total loss of the three-branch model.
[0147] Among them, the adversarial loss of the entire model is the adversarial loss of the feature extraction network and the discriminator.
[0148] The differences and corresponding technical effects of the present invention compared with the prior art are:
[0149] (1) Three networks with different architectures are introduced, which share a feature extraction network and each undergoes the same training steps; each network maintains its uniqueness in the same feature space without diversity constraints by learning the unique target domain knowledge of the other two networks and its own unique architecture.
[0150] (2) When training pseudo-labels, not only the features of the same category but also the features of different categories are taken into account in feature alignment; in measuring the reliability of pseudo-labels, the differences in different distribution predictions in the same feature space are used as supplementary information to further mine the unique information of the target domain.
[0151] The above are the specific steps of the model loss and training process designed by the present invention. In the specific implementation, multiple branches can be used for cross-training, not just limited to three branches. The more branches with different structures, the higher the accuracy of the pseudo-labels generated, the more accurate the pseudo-label adaptation estimate will be, and more space will be needed to store special center points. In the specific implementation, computer software technology can be used to realize the automatic operation process, and the device running the process of the present invention should also be within the scope of protection.
[0152] By comparing the IoU (Intersection over Union) and mIoU (mean Intersection over Union) of nineteen classes from the virtual dataset GTA5 to the real dataset Cityscapes, the IoU and mIoU of sixteen classes from the virtual dataset SYNTHIA to the real dataset Cityscapes, and some visualized images of the segmentation results, it can be seen that the present invention has good segmentation results in the target domain, which is greatly improved compared with previous methods.
[0153] There are also the following points to note when implementing it:
[0154] First, when designing the network structure, the differences between branches do not need to be very large, but there must be differences, because in the early pre-training, each branch can dig out the feature structure extracted by the unique receptive field of the structure to ensure the initial diversity of the model. Otherwise, due to the existence of homogeneous branches, the pseudo-labels generated have the same error for each branch, and each branch cannot learn new target domain knowledge, resulting in inaccurate prediction results.
[0155] Secondly, when designing the number of stored feature center points, the foreground category is divided into connected blocks to extract the center point, so the number of center points stored in the foreground category should be much larger than that in the background category. In this experiment, the number is set to be ten times. For the determination of other parameters, those skilled in the art can determine them based on their own experience or a large number of experiments.
[0156] It should be emphasized that the embodiments described in the present invention are illustrative rather than restrictive. Therefore, the present invention includes but is not limited to the embodiments described in the specific embodiments, and any other embodiments derived by those skilled in the art based on the technical solution of the present invention also fall within the scope of protection of the present invention.
Claims
1. A cross-domain semantic segmentation method based on three-branch cross-training, characterized in that: Applied to a three-branch model, the three-branch model includes three segmentation networks and a discriminator, the three segmentation networks share a feature extraction network, any two branches generate pseudo labels containing knowledge irrelevant to the third branch to train the third branch, the method includes: S1: Based on the input source domain data, labels, and target domain data, the adversarial loss of the feature extraction network and the discriminator is obtained; S2: Based on the source domain data, the segmentation loss of the source domain is obtained; S3: Extract source domain semantic features from source domain data and store the center points of the source domain semantic features; S4: For the target domain data, for any one of the three branches, the probability distribution is obtained through the prediction of the other two branches, and the pseudo-label is calculated. Then, the semantic features of the target domain are extracted, and the center points of the extracted features of each target domain are aligned with the stored center points of the source domain, and the total loss of the background category and the total loss of the foreground category on one branch are calculated; S5: For any of the three branches, the label prediction loss on one branch is obtained according to the probability distribution of the predictions obtained from the other two branches; S6: The loss of each branch is obtained based on the segmentation loss of the source domain, the label prediction loss on each branch, the total loss of the background category on each branch, and the total loss of the foreground category; S7: The total loss of the three-branch model is obtained according to the loss of each branch, the adversarial loss of the feature extraction network and the discriminator, and the three-branch model is updated; S8: Cross-domain semantic segmentation using the updated three-branch model.
2. The cross-domain semantic segmentation method based on three-branch cross-training according to claim 1, characterized in that: Step S1 includes: S1.1: Calculate the adversarial loss of the source domain data, L src_adv =(D(F(x s ))) 2 Among them, x s is the source domain data, F(x s ) represents the features of the source domain data extracted by the feature extraction network, D(F(x s )) represents the probability that the discriminator judges that the extracted source domain features come from the source domain data; S1.2: Calculate the adversarial loss of the target domain data, L tgt_adv =(D(F(x t ))-1) 2 Among them, x t is the target domain data, F(x t ) represents the features of the target domain data extracted by the feature extraction network, D(F(x t )) represents the probability that the discriminator determines that the extracted target domain features come from the source domain data; S1.3: Calculate the adversarial loss of the entire model. L adv =λ adv L src_adv +λ adv L tgt_adv Among them, λ adv is the weight of the adversarial loss, L src_adv , L tgt_adv are the adversarial losses on the source domain and target domain, respectively.
3. The cross-domain semantic segmentation method based on three-branch cross-training as claimed in claim 1, characterized in that: The segmentation loss of the source domain in step S2 is calculated as: in, For branch F i Calculate the source domain segmentation loss, x s is the source domain data, y s is the label of the source domain data, x t is the target domain data, F(x s ) is the feature of the source domain data extracted by the feature extraction network, F i (F(x s )) represents branch F i The classification probability distribution is obtained after parsing the features of the source domain data extracted from the feature extraction network.
4. The cross-domain semantic segmentation method based on three-branch cross-training as claimed in claim 1, characterized in that: The categories include foreground category f and background category b, and step S3 includes: For a single category, the foreground category extracts all connected blocks M in the image f The feature center point The background category extracts the feature center points of all pixels in the image The calculation formula is: Among them, f i Representative branch F i The feature map, M f,j represents the j-th connected graph for the foreground category f, HW represents the length and width of the image, II is the indicator function, and its value is 1 when the formula in the brackets is true, otherwise it is 0. Represents the sum of each pixel of the image, X s,hw Represents the source domain data x s The pixel point at the length and width hw, y s,hw Represents the label value at the length and width hw, that is, the category number; The extracted feature center points are stored in a queue, wherein the queue stores a preset number of center points by category.
5. The cross-domain semantic segmentation method based on three-branch cross-training as claimed in claim 1, characterized in that: Step S4 includes: S4.1: Calculate the probability distribution of the other two branches: P a =F a (F(x t ))a=j,k Among them, P a represents the probability distribution predicted by the other two branches, j and k represent the numbers of the other two branches, and F(x t ) represents the features of the target domain data extracted by the feature extraction network, F a (F(x t )) represents the classification probability distribution obtained after the other two branches parse the features of the target domain data extracted from the feature extraction network; S4.2: Calculate pseudo labels based on the probability distribution of the other two branches, y a =argmax P a a=j,k in, For branch F i Pseudo labels of S4.3: Calculate the semantic alignment of background category features. The calculation method is: Among them, B represents all background categories, Representative branch F i Among the stored source domain feature center points, the ath center point belongs to category b. Indicates F i The total loss of the background category, Indicates the calculation of each background category b, In the example, the subscripts represent the data source, target domain t, source domain s; the first superscript i represents that the feature comes from F i Branch, the second superscript indicates that the feature comes from category b, The third superscript of represents the center point number stored in the queue. Represents all source domain features in the queue In the above example, we calculate the target and features closest distance; S4.4: Calculate the semantic alignment of foreground category features. The calculation method is: Among them, F represents all foreground categories, Representative branch F i Among the stored source domain feature center points, the ath center point belongs to category f. The first term of the formula represents the closest distance between the target domain feature and the source domain feature of different categories. The second term represents the closest distance between the target domain feature and the source domain feature of the same category. The third term α is the size of the distance that can be controlled. Indicates F i The total loss for the foreground class.
6. The cross-domain semantic segmentation method based on three-branch cross-training as claimed in claim 1, characterized in that: Step S5 includes: S5.1: Calculate the average probability distribution based on the probability distributions of the remaining two branches. The calculation method is: Among them, P j , P k Indicates the other two branches F j 、F k The probability distribution of is the average probability distribution; S5.2: Based on the average probability distribution, calculate the difference between the two probability distributions as follows: Where w is the difference between the two probability distributions; S5.3: Calculate the label prediction loss based on the difference between the two probability distributions, as follows: in, Indicates F i The label prediction loss is Indicates branch F i The pseudo labels of x t represents the target domain data, F(x t ) represents the features of the target domain data extracted by the feature extraction network, F i (F(x t )) represents branch F i The classification probability distribution is obtained after parsing the features of the target domain data extracted from the feature extraction network.
7. The cross-domain semantic segmentation method based on three-branch cross-training according to claim 1, characterized in that: Step S6 calculates the loss of each branch according to the following formula: in, Respectively represent branches F i Label prediction loss, segmentation loss, λ tgt represents the weight of label prediction loss, Respectively represent branches F i The total loss of the background category, the total loss of the foreground category, λ b , f Branch F i The weight corresponding to the total loss of the background category and the weight corresponding to the total loss of the foreground category, L i Indicates F i loss.
8. The cross-domain semantic segmentation method based on three-branch cross-training as claimed in claim 1, characterized in that: Step S7 includes: After summing the losses of each branch and adding the adversarial loss of the entire model, we get the total loss of the three-branch model.
