A remote sensing image semantic segmentation method based on class center prototype
By introducing class center prototypes and regularization constraints into the semantic segmentation model of remote sensing images, the problems of poor interpretability and insufficient intra-class representation of the parameterized Softmax classifier in semantic segmentation of remote sensing images are solved, and higher segmentation accuracy and interpretability are achieved.
Patent Information
- Application Number
- CN202410062317.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-16
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2044-01-16
AI Technical Summary
Existing parameterized Softmax classifiers suffer from poor interpretability, insufficient intra-class representation, and inability to directly supervise pixel features in semantic segmentation of remote sensing images.
A class-centric prototype-based approach is adopted. By assigning multiple class prototypes to each class and introducing orthogonal constraints to increase the distance between prototypes, a first constraint to increase the distance between pixels and ground truth class prototypes, and a second constraint to increase the distance between pixels and non-ground truth class prototypes, a semantic segmentation loss function is constructed to optimize the feature extractor and classifier modules.
It improves the interpretability and accuracy of semantic segmentation of remote sensing images, enhances intra-class representation capabilities, directly supervises pixel representations, and overcomes the limitations of the parameterized Softmax classifier.
Smart Images

Figure CN117876688B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the fields of deep learning and computer vision, and in particular relates to a semantic segmentation method for remote sensing images based on class-centric prototypes. Background Technology
[0002] Semantic segmentation, aiming to predict the semantic category of each pixel in an image, is one of the fundamental and highly challenging tasks in remote sensing image analysis. By providing semantic and localization information for ground objects of interest, semantic segmentation plays a crucial role in fields such as road extraction, urban planning, and environmental monitoring. Compared to natural images, ground features in remote sensing images exhibit inherent spatial correlations, which are often observable; for example, vehicles typically remain on roads, and buildings are densely distributed along roadside areas.
[0003] In recent years, Convolutional Neural Networks (CNNs) have become an important method for improving semantic segmentation performance due to their powerful feature extraction capabilities. A typical CNN usually consists of three parts: an encoder, a decoder, and a classifier. Among classifiers, the parameterized Softmax classifier has become the preferred CNN classifier in many practical applications due to its simplicity, flexibility, and versatility.
[0004] However, the parameterized Softmax classifier also has the following limitations: First, the weight matrix W∈{w... 1 ,…,w k} and the paranoid vector b∈{b 1 ,…,b k The parameters are all learnable, and their classification decision-making process is not transparent, making it difficult to provide interpretability for the model; secondly, the parameterized softmax classifier uses only a weight vector and bias to represent a specific class, while semantic segmentation tasks usually have large intra-class variance, which limits the performance of the parameterized softmax classifier; thirdly, the cross-entropy loss function of the parameterized softmax classifier optimizes the parameters by supervising the classification probability of each pixel, rather than directly supervising the pixel representation, which makes the pixel representation difficult to train well. Summary of the Invention
[0005] The technical problem this invention aims to solve is how to implement a general architecture that can be applied to most semantic segmentation networks, introducing interpretability to the model while making minimal changes to the original model. It also proposes a corresponding solution to address the problem of large intra-class variance and small inter-class variance in remote sensing image semantic segmentation tasks. This invention assigns multiple class prototypes to each class and makes decisions based on the distance between the pixel representation and the class prototype. Furthermore, this invention introduces three regularization terms to constrain the model, controlling the direction of class prototype generation, thereby improving the model's accuracy while introducing interpretability.
[0006] The specific technical solution adopted in this invention is as follows:
[0007] A semantic segmentation method for remote sensing images based on class-centric prototypes is disclosed, comprising the following steps: A trained semantic segmentation model is obtained, consisting of a feature extractor and a classifier module. The feature extractor comprises an encoder module and a decoder module. The semantic segmentation model is jointly trained using a semantic segmentation loss function that minimizes the distance between prototypes. This loss function includes an orthogonal constraint to increase the distance between prototypes, a first constraint to increase the distance between pixels and ground truth prototypes, and a second constraint to increase the distance between pixels and non-ground truth prototypes. The remote sensing image to be semantically segmented is input into the feature extractor to obtain the first pixel feature extracted by the feature extractor. The first pixel feature is input into the classifier module. During training, the classifier module generates the final local class prototypes corresponding to each semantic category. The Euclidean distance between the first pixel feature and each final local class prototype is calculated. A similarity conversion function is used to convert the Euclidean distance into a similarity between the first pixel feature and each final local class prototype. The semantic category to which the final local class prototype with the highest similarity belongs is taken as the semantic segmentation result of the remote sensing image.
[0008] In each training round of the semantic segmentation model, the input remote sensing image is processed by the feature extractor to extract the second pixel feature. The second pixel feature is then pre-classified to obtain a coarse segmentation result. The second pixel feature is then segmented along the spatial dimension to obtain n identically sized local pixel feature blocks. The coarse segmentation result is then segmented along the spatial dimension to obtain n identically sized local coarse segmentation result blocks. Matrix multiplication is performed on the local coarse segmentation result blocks and the local pixel feature blocks to obtain n local class prototypes for each semantic category. For each semantic category, the prototypes obtained from the previous training round are then analyzed. After momentum updates, the Euclidean distance between each local class prototype and each subclass prototype is calculated sequentially. The subclass prototype with the smallest Euclidean distance is selected, and each subclass prototype is updated using momentum updates to obtain the momentum-updated subclass prototypes. Based on the momentum-updated subclass prototypes, the orthogonal loss, the first constraint, and the second constraint are calculated. The semantic segmentation loss function is used to optimize the feature extractor and the classifier module. The training process is iterated until the semantic segmentation model converges. Finally, the training is completed, and m optimized subclass prototypes are obtained as the final local class prototypes corresponding to each semantic category.
[0009] Preferably, the pre-classification operation uses a 1×1 convolutional layer.
[0010] Preferably, the semantic segmentation loss function L has the following functional form:
[0011] L = L ce +L pix2proto +α1L pro2pro +βL pix2other +γL Dice +L aux
[0012] Among them, L ce L represents the cross-entropy loss; pix2proto α1 represents the first constraint; β represents the first coefficient; γ represents the second coefficient; L represents the third coefficient; pro2pro L represents the orthogonal constraint; pix2other L represents the second constraint; Dice Indicates Dice loss; L aux This indicates the loss of the auxiliary head.
[0013] Preferably, the functional form of the orthogonal constraint is:
[0014] L pro2pro =L sp +L pp
[0015]
[0016]
[0017] Among them, L sp L represents the orthogonalization subclass space loss; pp E(k) represents the loss between orthogonalization classes and class space. T E(k1) T E(k2) T Let E(k), E(k1), and E(k2) represent the orthogonal basis matrices of the prototypes of all subclasses of class k, class k1, and class k2, respectively; k∈(1,…K). I represents the square of the Frobenius norm of a matrix; m This represents an identity matrix with dimensions m×m.
[0018] Preferably, the functional form of the first constraint is:
[0019]
[0020] Where σ represents the label ignored during the training of the semantic segmentation model; N represents the number of pixel features; 1[y ik =1] means when y ik The value is 1 when y = 1, otherwise the value is 0; ik Represents the feature x of the i-th pixel i The true category; c j Represents the prototype of the j-th subclass; This represents the transpose of the prototype of the j-th subclass; Represents the feature x of the i-th pixel i Transpose of the prototype of the j-th subclass The relative similarity distance mapping between them, the functional form of which is:
[0021]
[0022] Where log(·) represents the logarithmic function; Represents the feature x of the i-th pixel i transpose of the prototype of the j-th subclass The relative similarity between them, the functional form of which is:
[0023]
[0024] This indicates the relative similarity. The value is limited to between ε and 1; ε represents a constant. Describing the natural constant e The exponentiation [·] indicates the dot product operation.
[0025] Preferably, the functional form of the second constraint is:
[0026]
[0027] Among them, 1[y ik ≠1] indicates that when y ik The value is 1 when it is not equal to 1, otherwise the value is 0.
[0028] Preferably, the first coefficient α1 is 1.0, the second coefficient β is 0.5, and the third coefficient γ is 1.0.
[0029] Preferably, the constant ε = 1e -6 .
[0030] Preferably, the similarity conversion function f cls The function form is:
[0031] f cls = (1+α2·Dist) pro2feat ) -1
[0032] Where α2 represents the fourth coefficient; Dist pro2feat This represents the Euclidean distance between pixel features and the prototypes of each final local class.
[0033] Preferably, the fourth coefficient α2 is 2.
[0034] Compared with the prior art, the present invention has the following advantages:
[0035] 1) This invention addresses the three limitations of current semantic segmentation networks for remote sensing images that use parameterized Softmax classifiers: poor interpretability, insufficient intra-class representation, and inability to directly supervise pixel features. It proposes a general framework that can be applied to any semantic segmentation network that uses a fully parameterized Softmax classifier.
[0036] 2) This invention assigns multiple class prototypes to each class and compares the distance between the class prototypes and the test set data in the feature space to simulate the human inference process of "this looks like". It makes decisions based on the distance between the pixel representation and the class prototype, thus introducing interpretability to the semantic segmentation task of remote sensing images.
[0037] 3) This invention assigns multiple class prototypes to each class to handle the rich intra-class representations in remote sensing images; this invention directly supervises pixel representations, enabling better training of pixel representations. Furthermore, to better control the direction of prototype generation, this invention employs three regularization terms: an orthogonal constraint that increases the distance between prototypes, a first constraint that increases the distance between pixels and ground truth class prototypes, and a second constraint that increases the distance between pixels and non-ground truth class prototypes. These measures address the problem of high intra-class variance and low inter-class variance in remote sensing images, thereby improving the performance of remote sensing image semantic segmentation tasks and providing a new solution for these tasks. Attached Figure Description
[0038] Figure 1 This is a structural diagram of the ProtoCls semantic segmentation model of the present invention;
[0039] Figure 2 The orthogonal constraint L for increasing the distance between prototypes in this invention pro2pro Schematic diagram;
[0040] Figure 3 The first constraint L for the distance between the pixel and the truth class prototype in this invention is... pix2proto Schematic diagram;
[0041] Figure 4 The second constraint L for the distance between the distanced pixel and the non-truth class prototype in this invention pix2other Schematic diagram;
[0042] Figure 5 This is a comparison chart of test visualization results in an embodiment of the present invention;
[0043] Figure 6 This is a visualization diagram of the model in an embodiment of the present invention. Detailed Implementation
[0044] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. Many specific details are set forth in the following description to provide a thorough understanding of the present invention. However, the present invention can be practiced in many other ways different from those described herein, and those skilled in the art can make similar modifications without departing from the spirit of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below. Technical features in the various embodiments of the present invention can be combined accordingly without mutual conflict.
[0045] To address the common lack of interpretability in current deep learning semantic segmentation models for high-resolution remote sensing images, as well as the large intra-class variance and small inter-class variance of these images, this invention proposes a general framework applicable to any semantic segmentation network employing a fully parameterized Softmax classifier, building upon the aforementioned limitations of the parameterized Softmax classifier. This framework is based on class-center prototypes, and its decision-making process compares the distance between the class prototype and the test set data in the feature space. This indicates the position of the learned class prototype in the training set data, simulating the human "this looks like" inference process, thus introducing interpretability to deep learning models and overcoming one limitation of the parameterized Softmax classifier. Furthermore, this invention assigns multiple learned class prototypes to each class, rather than using only one weight and bias to represent a class as in the parameterized Softmax classifier, overcoming another limitation. Finally, this invention directly supervises the pixel representation, rather than optimizing parameters by supervising the classification probability of each pixel, as in the parameterized Softmax classifier. This allows for better training of the pixel representation, overcoming a third limitation.
[0046] This invention provides a remote sensing image semantic segmentation method based on class-centric prototypes, such as... Figure 1 As shown, the specific process is as follows:
[0047] Obtain a trained semantic segmentation model (Class Center Prototypes Classifier, ProtoCls). This semantic segmentation model consists of a feature extractor and a classifier module. The feature extractor is composed of an encoder module and a decoder module. The semantic segmentation model is jointly trained by minimizing a semantic segmentation loss function, which includes an orthogonal constraint L that increases the distance between prototypes. pro2pro The first constraint L that brings the pixel closer to the prototype of the truth class. pix2proto And the second constraint L, which increases the distance between pixels and non-truth class prototypes. pix2otherA semantic segmentation loss function is constructed, and the semantic segmentation model is jointly trained by minimizing this loss function. The remote sensing image to be semantically segmented is input into the semantic segmentation model to obtain a more interpretable and accurate semantic segmentation result. Specifically, the remote sensing image to be semantically segmented is input into the feature extractor to obtain the first pixel feature extracted by the feature extractor; the first pixel feature is input into the classifier module, which generates the final local class prototypes corresponding to each semantic category during training. The Euclidean distance between the first pixel feature and each final local class prototype is calculated, and a similarity conversion function is used to convert the Euclidean distance into a similarity between the first pixel feature and each final local class prototype. The semantic category to which the final local class prototype with the highest similarity belongs is taken as the semantic segmentation result of the remote sensing image. The image used in this invention is preferably a remote sensing image, and more preferably a high-resolution remote sensing image with a spatial resolution of less than 1m.
[0048] It should be noted that in this invention, the semantic segmentation model follows two different processes during model training and inference. Their common core idea is to train a set of class prototypes with good representational capabilities and calculate the L2 distance Dist between the pixel representation x extracted by the feature extractor and each final local class prototype C. pro2feat =|Cx|², where |·|² represents the L2 distance calculation. Then, the similarity transformation function f is used. cls = (1+α·Dist) pro2feat ) -1 The L2 distance between pixel representations and final local class prototypes is converted into similarity. Finally, the Argmax operation is applied, and the class to which the prototype with the highest similarity in the final local class prototypes belongs is taken as the semantic segmentation result of the remote sensing image. in, The prediction result is represented by m×K, which represents the total number of final local class prototypes, and f. cls This represents the similarity transformation function. It is derived from the semantic segmentation results of remote sensing images. As can be seen from the functional form, the quality of semantic segmentation results is closely related to the quality of class prototype generation. Therefore, during training, the classifier module of the semantic segmentation model uses samples from the training dataset to generate class prototypes and continuously optimizes the generated class prototypes in the process, so that the class prototypes can better capture the features of each semantic category; during inference, the classifier module of the semantic segmentation model will no longer update the class prototypes, but will directly use the already generated class prototypes for inference.
[0049] The specific structure and principles of the semantic segmentation model ProtoCls described above are described in detail below.
[0050] The semantic segmentation model described above consists of a feature extractor and a classifier module. The feature extractor comprises an encoder module and a decoder module. In the encoder module, features are first extracted using a backbone network, with the output features serving as a coarse feature representation. In the decoder module, this coarse feature representation is processed through a common decoding head (e.g., the PPM (Pyramid Pooling Module) in PSPNet or the dual-path attention module in DANet) to obtain an enhanced feature representation. This invention concatenates the encoder and decoder modules to form the feature extractor, which will not be elaborated further below.
[0051] In each training round of the semantic segmentation model described above, the input remote sensing image is processed by the feature extractor to extract the second pixel feature. This second pixel feature is then pre-classified to obtain a coarse segmentation result. The second pixel feature is then segmented along the spatial dimension to obtain n identically sized local pixel feature blocks. The coarse segmentation result is then segmented along the spatial dimension to obtain n identically sized local coarse segmentation result blocks. Matrix multiplication is performed on the local coarse segmentation result blocks and the local pixel feature blocks to obtain n local class prototypes for each semantic category. For each semantic category, m initial subclass prototypes are preset for training to obtain the obtained results. After processing the m subclass prototypes updated with momentum in the previous training round, calculate the Euclidean distance between each local class prototype and each subclass prototype in turn, and select the subclass prototype with the smallest Euclidean distance. Update each subclass prototype with momentum to obtain the momentum-updated subclass prototypes. Based on the momentum-updated subclass prototypes, calculate the orthogonal loss, the first constraint, and the second constraint. Optimize the feature extractor and classifier modules using the semantic segmentation loss function. Iterate the training process until the semantic segmentation model converges. Finally, after training, obtain m optimized subclass prototypes as the final local class prototypes corresponding to each semantic category.
[0052] It's important to note that unlike traditional Softmax classifiers that obtain segmentation results based on the probability distribution of each pixel, the semantic segmentation model ProtoCls directly predicts based on the similarity between pixels and class prototypes. Unlike black-box models, it inherently possesses a built-in case-based reasoning process. When the source of class prototypes is limited to remote sensing images in the training set, ProtoCls compares the currently inferred remote sensing image with the class prototypes learned in the training set during inference, naturally providing a human-understandable explanation for the prediction—"this looks like it." This interpretability is related to the decision-making pattern within the semantic segmentation model; that is, the semantic segmentation model is self-explanatory, rather than ex-post interpretable. The semantic segmentation model first calculates the L2 distance between the pixel representation and the trained class prototypes. Then, it uses a similarity transformation function to convert the distance between pixel features and the final local class prototypes trained to a similarity score. Finally, it adopts a winner-takes-all strategy, using the class of the subclass prototype with the highest similarity as the prediction result. As can be seen, the semantic segmentation model ProtoCls addresses three limitations of traditional parametric Softmax classifiers: First, ProtoCls learns class prototypes for case reasoning rather than relying on learnable parameters, providing excellent self-interpretability. Second, ProtoCls assigns multiple sub-semantic category prototypes to each semantic category for learning, unlike the parametric Softmax classifier which provides only a weight vector and bias to represent a class, thus enhancing the model's representational power. Third, ProtoCls directly supervises pixel representations, unlike the parametric Softmax classifier which optimizes parameters by supervising the classification probability of each pixel, allowing for better training of pixel representations.
[0053] In this embodiment, the processing flow of the classifier module can be mainly divided into three steps: first, generating a local class prototype; then, updating the subclass prototype; and finally, using the final local class prototype for inference.
[0054] 1) The process of generating local class prototypes can be described as follows: First, the pixel features extracted by the feature extractor are pre-classified to obtain coarse segmentation results; then, the pixel features are cut along the spatial dimension to obtain n pairs of cut local pixel feature blocks of the same size; the above coarse segmentation results are cut along the spatial dimension to obtain n pairs of cut local coarse segmentation result blocks of the same size; finally, matrix multiplication is performed on the local coarse segmentation result blocks and the local pixel feature blocks to obtain n×K local class prototypes.
[0055] 2) The process of updating subclass prototypes can be described as follows: For each local class prototype, m initial subclass prototypes are preset for training, and each initial subclass prototype is randomly initialized. The L2 distance matrix between each local class prototype and each initial subclass prototype is calculated sequentially. For the current local class prototype, the initial subclass prototype with the smallest Euclidean distance to the current local class prototype is selected, and the initial subclass prototype is updated using momentum updates, updating the n×K local class prototypes to the m×K subclass prototypes. Simultaneously, the classifier module uses an orthogonal constraint L to widen the distance between prototypes. pro2pro The first constraint L that brings the pixel closer to the prototype of the truth class. pix2proto And the second constraint L, which increases the distance between pixels and non-truth class prototypes. pix2other Control the direction of subclass prototype generation until the model converges, resulting in m×K final local class prototypes.
[0056] 3) The process of using the final local class prototype for inference can be described as follows: During model inference, the classifier module no longer updates the learned final local class prototype, but directly uses the learned local class prototype for inference. First, the L2 distance between each pixel feature extracted by the feature extractor and the local class prototype is calculated. Then, the L2 distance between the pixel feature and the class prototype is converted into the similarity between the pixel feature and the class prototype through a similarity conversion function. Finally, a winner-takes-all strategy is adopted to select the final classification result through the Argmax operation.
[0057] It should be noted that, considering the often large intra-class variance of remote sensing images, even within the same input image, significant differences can easily exist between members of the same class. To address this issue, this invention introduces local class prototypes to better capture the semantic category features of different regions in remote sensing images, thereby ensuring that the semantic segmentation model ProtoCls can learn richer class prototype representations. In this embodiment, the intermediate processes of the semantic segmentation model ProtoCls and the dimensions of each parameter are further described to facilitate a better understanding of the principle of this semantic segmentation model by those skilled in the art. The input remote sensing image to be processed is first used to extract pixel features X using a feature extractor F, with pixel feature dimensions of Ch×H×W. After passing through a 1×1 convolutional layer for pre-classification, the pixel features X yield a coarse segmentation result D, with dimensions of K×H×W. Then, to generate local class prototypes, the pixel features X and the coarse segmentation result D are segmented along the spatial dimensions, corresponding to the local pixel feature representation R. l ∈R=Split(X) and the result of local coarse segmentation represented by D l ∈R = Split(D∈R), local pixel feature representation R l The dimensions are n×Ch×H×W, and the local coarse segmentation result is represented by D.l The dimensions are n×K×H×W. Let the height of each feature block after this split operation be h and the width be w. Then the number of blocks obtained by horizontal splitting is N. h =H / h, the number of blocks N obtained by vertical segmentation w =W / w. Representing local pixel features R l The result of local coarse segmentation is represented by D. l Perform matrix multiplication to obtain the initial local class prototype. After the above steps, we can obtain a total of n = N. h ×N w There are K feature blocks, each containing K class prototypes, generating C local class prototypes. i ∈R K×n×C The dataset contains a total of K×n local class prototypes, with each semantic category containing n local class prototypes. The ProtoCls classifier module then learns by updating the class prototypes using momentum. First, the initial local class prototypes are rearranged in dimension to obtain the intermediate local class prototype C. i The intermediate local class prototypes have dimensions of K×n×Ch. To address the challenge of large intra-class variance in segmentation tasks, the classifier module of the semantic segmentation model ProtoCls first pre-defines m initial subclass prototypes C for the intermediate local class prototypes (a total of K classes) for the model to learn and then randomly initializes them. The initial subclass prototypes C have dimensions of K×m×Ch. The classifier module first calculates the difference between the initial subclass prototypes C and the intermediate local class prototypes C. i L2 distance Dist pro2pro ∈R K×n×m =|CC i 2. For the intermediate local class prototype C i Within each semantic category, find the one most similar to it (i.e., Dist). pro2pro The initial prototype index of the smallest (minimum) subclass Its dimensions are expanded using one-hot encoding. Finally, the initial subclass prototype C's momentum is updated, allowing the initial subclass prototype to learn a more representative class prototype, i.e. The updated subclass prototype C is obtained after one iteration. update Afterwards, it will participate in the next round of training as a new subclass prototype, and the finally updated subclass prototype will be used as the final local class prototype for each semantic category. Finally, the classifier module makes decisions based on the similarity between pixel features and class prototypes. First, it calculates the L2 distance Dist between pixel feature X and the final local class prototype. pro2feat Then, the similarity conversion function f is used. cls = (1+α2·Dist) pro2feat ) -1The distance between pixel representation X and the final local class prototype is converted into a similarity score. Finally, the Argmax operation is applied, and the class to which the prototype with the highest similarity score belongs is used as the prediction result among m×K final local class prototypes. Here, Ch, H, and W represent the number of channels, height, and width of the remote sensing image, respectively; K represents the local class prototype of the Kth class; n represents the number of blocks obtained after segmentation along the spatial dimension; m represents the set initial number of subclass prototypes; and α2 represents the fourth coefficient. This refers to matrix multiplication operations; [·] permute For dimension rearrangement operations; This represents a one-hot encoding operation with an expanded dimension of m; N index C represents the index of the nearest distance obtained from the calculation; update It is the local class prototype obtained after momentum update; μ∈[0,1] is the momentum update coefficient, which takes values between 0 and 1.
[0058] It should be noted that, in this invention, the above parameters can be adjusted according to actual conditions. In this embodiment, the momentum update coefficient μ = 0.999, m = 8, and N... h =2, N w =2, the fourth coefficient α2 takes the value of 2, n=4.
[0059] In this invention, the semantic segmentation loss function L has the following functional form:
[0060] L = L ce +L pix2proto +α1L pro2pro +βL pix2other +γL Dice +L aux
[0061] Among them, L ce L represents the cross-entropy loss; pix2proto The first constraint is represented by α1; the first coefficient is represented by β; the third coefficient is represented by γ; L pro2pro L represents the above orthogonal constraint; pix2other This represents the second constraint mentioned above; L Dice Indicates Dice loss; L aux This indicates the loss of the auxiliary head.
[0062] It should be noted that, in this invention, the first coefficient, the second coefficient, and the third coefficient can be set according to actual conditions. In this embodiment, the first coefficient α1 is 1.0; the second coefficient β is 0.5; and the third coefficient γ is 1.0.
[0063] It's important to note that distinguishing between class prototypes, especially those containing multiple subclass prototypes within the same class, is a significant challenge. Without constraints on prototype generation, a class prototype can easily degenerate from m×K subclass prototypes to K class prototypes, thus reducing its expressive power. Furthermore, the inference process of ProtoCls shows that inference quality is related to two quantities: the final local class prototype and the pixel representation. Therefore, improving the performance of the semantic segmentation model (ProtoCls) requires addressing how to generate more representative class prototypes and pixel representations. This invention proposes the following three regularization terms: an orthogonal constraint L that increases the distance between prototypes. pro2pro The first constraint L that brings the pixel closer to the prototype of the truth class. pix2proto And the second constraint L, which increases the distance between pixels and non-truth class prototypes. pix2other They are introduced during training to improve the performance of semantic segmentation models (ProtoCls).
[0064] In this invention, the functional form of the above orthogonal constraint is:
[0065] L pro2pro =L sp +L pp
[0066]
[0067]
[0068] Among them, L sp L represents the orthogonalization subclass space loss; pp E(k) represents the loss between orthogonalization classes and class space. T E(k1) T E(k2) T Let E(k), E(k1), and E(k2) represent the orthogonal basis matrices of the prototypes of all subclasses of class k, class k1, and class k2, respectively; k∈(1,…K). I represents the square of the Frobenius norm of a matrix; m This represents an identity matrix with dimensions m×m.
[0069] In this embodiment of the invention, the principle of the orthogonal constraint is further described to facilitate a better understanding of the invention by those skilled in the art. Class prototypes should possess diversity; this diversity allows for a more comprehensive understanding and description of a thing. In the semantic segmentation model ProtoCls, the class prototype of each semantic category is composed of a set of vectors, and each vector should have its unique representation. In this case, all subclass prototypes of each semantic category can be used as a set of basis vectors. These basis vectors must satisfy the requirement that there is no semantic overlap between them, i.e., the basis vectors need to be orthogonal. Therefore, the classifier module of this invention employs an orthogonal constraint to increase the distance between prototypes during training. This orthogonal constraint is added between prototypes. Figure 2 For the orthogonal constraint L pro2pro The diagram illustrates the specific approach: First, an orthogonalized subclass space loss L is used to widen the distance between subclass prototypes in each semantic category. sp This increases the distance between subclass prototypes within each semantic category, preventing the momentum update class prototype C from degenerating from m×K subclass prototypes to K subclass prototypes. When embedding subclass prototypes into a space, data from different semantic categories should typically be distributed across different subspaces, and for segmentation accuracy, these subspaces should be far apart from each other. For this purpose, a Grassmann manifold can be used to represent the subspace of each semantic category. Let the Grassmann manifold be denoted as G(Ch,m), and let R be a subset of the subspace of the semantic category. Ch The set of all Ch-dimensional linear subspaces in the semantic segmentation model ProtoCls. In ProtoCls, the subspace of each semantic category consists of m orthogonal basis vectors. These basis vectors form a Ch×m matrix Q, satisfying Q... T Q = I m Each semantic category subspace can be viewed as a point on a Grassmann manifold. Helmke et al. proved that each point on the Grassmann manifold corresponds to a unique projection matrix. The classifier module described above can project vectors from different subspaces onto their respective subspaces using a projection mapping on the Grassmann manifold, thereby obtaining their representations in the subspaces. This projection mapping can be represented as Π(E(k)) = E(k). T E(k), this projection matrix, can be used to measure the distance between different subspaces. By defining a suitable subspace distance metric, the distance between subspaces can be used as the orthogonalized subclass space loss mentioned above to construct the orthogonality constraint. By minimizing the orthogonalized subclass space loss, subspaces of different semantic categories can be made to move away from each other, thereby achieving better semantic category separation. In Grassmann manifolds, a common subspace distance metric is the projection metric, which can be represented as... The orthogonalized class and class space loss L can then be defined by maximizing the projection metric between each pair of subspaces. pp Finally, L is obtained by orthogonalizing the subclass space. sp And the L of orthogonalization of classes and class spaces pp This achieves diversity in class prototype expression, ultimately resulting in the orthogonal constraint L. pro2pro For L pro2pro =L sp +L pp .
[0070] The orthogonal constraint that widens the distance between prototypes only regulates the generation of class prototypes. Considering the two factors affecting reasoning quality—class prototypes and pixel representations—regulating pixel representations is equally important. Pixel representations should satisfy two conditions: first, the distance between a pixel representation and the class prototype of its truth class should be as small as possible; second, the distance between a pixel representation and the class prototype of its non-truth class should be as large as possible. Therefore, this embodiment proposes two corresponding loss functions—a first constraint that narrows the distance between pixels and truth class prototypes (i.e., compactness loss, pixel-to-prototype loss) and a second constraint that widens the distance between pixels and non-truth class prototypes (i.e., separability loss, pixel-to-other loss). By applying these two regularization terms, the normalized pixel representation can better reflect the characteristics of its semantic category and improve the accuracy and separability of reasoning.
[0071] In this invention, the aforementioned first constraint L pix2proto and the second constraint L pix2other The function forms are as follows:
[0072]
[0073]
[0074] Where σ represents the labels ignored during the training of the semantic segmentation model; N represents the number of pixel features; 1[condition] means that the value is 1 when the condition is true and 0 otherwise, then 1[y ik =1] means when y ik The value is 1 when = 1, otherwise the value is 0, 1[y ik ≠1] indicates that when y ik The value is 1 when ≠ 1, otherwise the value is 0; y ik Represents the feature x of the i-th pixel i The true category; c j Represents the prototype of the j-th subclass; This represents the transpose of the prototype of the j-th subclass. Represents the feature of the i-th pixel Transpose of the prototype of the j-th subclass The relative similarity distance mapping between them, the functional form of the above relative similarity distance mapping is:
[0075]
[0076] Where log(·) represents the logarithmic function; Represents the feature x of the i-th pixel i transpose of the prototype of the j-th subclass The relative similarity between them, the functional form of the above relative similarity is:
[0077]
[0078] Here, clamp(a,ε,1) represents the relative similarity constraint function, which restricts the relative similarity a to between ε and 1. This indicates that the relative similarity will be limited. Between ε and 1; ε represents a constant; Describing the natural constant e The exponentiation [·] indicates the dot product operation.
[0079] It should be noted that, in this invention, the constant ε can be set according to actual conditions. In this embodiment, ε = 1e -6 .
[0080] In this embodiment, the principles of the first and second constraints are further described to enable those skilled in the art to better understand the present invention. During training, the classifier module employs a first constraint L that shortens the distance between pixels and the ground truth class prototype. pix2proto ,like Figure 3 As shown, the specific approach is as follows: Since the model's final prediction result is obtained by calculating the similarity between pixel features and each class prototype, and performing an Argmax operation based on the similarity map, the absolute value of the similarity between a single pixel and its semantic category prototype has no practical significance. Only by comparing this similarity with the similarity of other semantic category prototypes can a reliable result be obtained. To facilitate comparison, this embodiment introduces the concept of relative similarity to replace the absolute value of similarity, measuring the similarity between a pixel and a class prototype, i.e., the aforementioned relative similarity. The obtained similarity is then mapped so that distance and relative similarity are negatively correlated, i.e., the aforementioned relative similarity-distance mapping. This further reduces the first constraint L that shortens the distance between the pixel and the prototype of the truth class. pix2proto Defined as the sum of distances from all pixels to their ground truth class prototypes, pixel features should be far away from labels of non-real semantic categories, thus defining a second constraint to increase the distance between pixels and non-real truth class prototypes. Figure 4 This is a schematic diagram of the second constraint. Furthermore, to ensure that the generation process of local class prototypes can also be supervised, this invention adds Dice loss L to the coarse segmentation result D. Dice Supervise it.
[0081] It should be noted that the encoder and decoder modules used in this invention can be derived from any open-source and general-purpose model, and can be selected according to the actual situation. In this embodiment, the encoder and decoder modules are ConvNeXt, and both need to load pre-trained weights learned on the dataset.
[0082] The above-mentioned remote sensing image semantic segmentation method based on class center prototypes will be applied to a specific embodiment to demonstrate its technical effects.
[0083] Example
[0084] In this embodiment, the semantic segmentation model ProtoCls uses ConvNeXt as the feature extractor. The specific network structure is as described above and will not be repeated here. The overall process of semantic segmentation of remote sensing images can be divided into three stages: data preprocessing, model training, and image prediction.
[0085] 1. Data Preprocessing Stage
[0086] For the obtained raw remote sensing images (using the LoveDA dataset as an example in this embodiment), image preprocessing is performed. First, the raw remote sensing images are cut into 512×512 pixels, and then the cut images are randomly rotated and flipped to perform data augmentation.
[0087] 2. Model Training
[0088] Step 1. Select a subset of samples from the LoveDA dataset to construct the training dataset, and divide the training dataset into batches of a fixed batch size, with a total of N.
[0089] Step 2. Select a batch of training samples with index i sequentially from the training dataset, where i∈0,1,…,N. Train the model proposed in this invention using the training samples of each batch. During training, calculate the overall loss function L proposed in this invention for each training sample, and calculate the total loss of all training samples in the batch. The network parameters throughout the model are adjusted until all batches of the training dataset have participated in the model training. After reaching the specified number of iterations, the model converges, and training is complete.
[0090] 3. Image Prediction
[0091] A subset of samples is reselected from the LoveDA dataset to construct a test dataset. The remote sensing images in the test dataset are used as input to the pre-trained semantic segmentation model. Finally, by comparing the similarity between the current pixel representation and the learned class center prototype, the class to which the class prototype with the highest similarity belongs is selected as the final output, thereby achieving semantic segmentation.
[0092] In this embodiment, the test visualization results are as follows: Figure 5 As shown in Table 1, the test data results are presented, and the prototype analysis case is as follows: Figure 6 As shown:
[0093] Table 1 Test Data Results
[0094] Model Back Building Road Water Barren Forest Agri mIoU ConvNeXt 42.66 48.93 52.61 75.90 17.69 40.71 51.85 47.19 ProtoCls 43.99 53.04 53.24 78.49 18.06 41.07 57.11 49.29
[0095] Table 1 compares the ConvNeXt model with the semantic segmentation model ProtoCls of this invention in this embodiment. The ConvNeXt model uses its original classifier, while the ProtoCls semantic segmentation model uses a classifier based on class center prototypes. Figure 5 , Figure 6 As shown in Table 1, the remote sensing image semantic segmentation method based on class center prototype of the present invention can provide interpretability for the semantic segmentation model and can effectively solve the problem of high intra-class variance and low inter-class variance of remote sensing images, thereby improving the performance of remote sensing image semantic segmentation tasks and providing a new solution for remote sensing image semantic segmentation tasks.
[0096] The embodiments described above are merely preferred embodiments of the present invention and are not intended to limit the invention. Those skilled in the art can make various changes and modifications without departing from the spirit and scope of the invention. Therefore, all technical solutions obtained through equivalent substitution or transformation fall within the protection scope of the present invention.
Claims
1. A semantic segmentation method for remote sensing images based on class-centric prototypes, characterized in that, The specific process is as follows: A trained semantic segmentation model is obtained, consisting of a feature extractor and a classifier module. The feature extractor comprises an encoder module and a decoder module. The semantic segmentation model is jointly trained using a semantic segmentation loss function that minimizes the semantic segmentation loss function. This loss function includes an orthogonal constraint to increase the distance between prototypes, a first constraint to increase the distance between pixels and ground truth prototypes, and a second constraint to increase the distance between pixels and non-ground truth prototypes. The remote sensing image to be semantically segmented is input into the feature extractor to obtain the first pixel feature extracted by the feature extractor. The first pixel feature is input into the classifier module. During training, the classifier module generates the final local class prototypes corresponding to each semantic category. The Euclidean distance between the first pixel feature and each final local class prototype is calculated. A similarity conversion function is used to convert the Euclidean distance into a similarity between the first pixel feature and each final local class prototype. The semantic category to which the final local class prototype with the highest similarity belongs is taken as the semantic segmentation result of the remote sensing image. In each training round of the semantic segmentation model, the input remote sensing image is processed by the feature extractor to extract the second pixel feature. The second pixel feature is then pre-classified to obtain a coarse segmentation result. The second pixel feature is then segmented along the spatial dimension to obtain n identically sized local pixel feature blocks. The coarse segmentation result is then segmented along the spatial dimension to obtain n identically sized local coarse segmentation result blocks. Matrix multiplication is performed on the local coarse segmentation result blocks and the local pixel feature blocks to obtain n local class prototypes for each semantic category. For each semantic category, the prototypes obtained from the previous training round are then analyzed. After momentum updates, the Euclidean distance between each local class prototype and each subclass prototype is calculated sequentially. The subclass prototype with the smallest Euclidean distance is selected, and each subclass prototype is updated using momentum updates to obtain the momentum-updated subclass prototypes. Based on the momentum-updated subclass prototypes, the orthogonal loss, the first constraint, and the second constraint are calculated. The semantic segmentation loss function is used to optimize the feature extractor and the classifier module. The training process is iterated until the semantic segmentation model converges. Finally, the training is completed, and m optimized subclass prototypes are obtained as the final local class prototypes corresponding to each semantic category.
2. The remote sensing image semantic segmentation method based on class-centric prototypes as described in claim 1, characterized in that, The pre-classification operation uses a 1×1 convolutional layer.
3. The remote sensing image semantic segmentation method based on class-centric prototypes as described in claim 1, characterized in that, The semantic segmentation loss function L has the following functional form: L=L ce +L pix2proto +α1L pro2pro +βL ptx2other +γL Dice +L aux Among them, L ce L represents the cross-entropy loss; pix2proto α1 represents the first constraint; β represents the first coefficient; γ represents the second coefficient; L represents the third coefficient; pro2pro L represents the orthogonal constraint; pix2other L represents the second constraint; Dice Indicates Dice loss; L aux This indicates the loss of the auxiliary head.
4. The remote sensing image semantic segmentation method based on class-centric prototypes as described in claim 3, characterized in that, The functional form of the orthogonal constraint is: L pro2pro L sp +L pp Among them, L sp L represents the orthogonalization subclass space loss; pp Represents the orthogonalization class and class space loss; Let E(k), E(k1), and E(k2) represent the orthogonal basis matrices of the prototypes of all subclasses of class k, class k1, and class k2, respectively; E(k), E(k1), and E(k2) represent the orthogonal basis matrices of the prototypes of all subclasses of class k, class k1, and class k2, respectively, k∈(1,…K). I represents the square of the Frobenius norm of a matrix; m This represents an identity matrix with dimensions m×m.
5. The remote sensing image semantic segmentation method based on class-centric prototypes as described in claim 4, characterized in that, The functional form of the first constraint is: Where σ represents the label ignored during the training of the semantic segmentation model; N represents the number of pixel features; 1[y ik =1] means when y ik The value is 1 when y = 1, otherwise the value is 0; ik Represents the feature x of the i-th pixel i The true category; c j Represents the prototype of the j-th subclass; This represents the transpose of the prototype of the j-th subclass; Represents the feature x of the i-th pixel i Transpose of the prototype of the j-th subclass The relative similarity distance mapping between them, the functional form of which is: Where log(·) represents the logarithmic function; Represents the feature x of the i-th pixel i transpose of the prototype of the j-th subclass The relative similarity between them, wherein the functional form of the relative similarity is: This indicates the relative similarity. The value is limited to between ε and 1; ε represents a constant. The natural constant e The exponentiation [·] indicates the dot product operation.
6. The remote sensing image semantic segmentation method based on class-centric prototypes as described in claim 5, characterized in that, The functional form of the second constraint is: Among them, 1[y ik ≠1] indicates that when y ik The value is 1 when it is not equal to 1, otherwise the value is 0.
7. The remote sensing image semantic segmentation method based on class-centric prototypes as described in claim 3, characterized in that, The first coefficient α1 is 1.0, the second coefficient β is 0.5, and the third coefficient γ is 1.
0.
8. The remote sensing image semantic segmentation method based on class-centric prototypes as described in claim 5, characterized in that, The constant ε=1e -6 .
9. The remote sensing image semantic segmentation method based on class-centric prototypes as described in claim 1, characterized in that, The similarity conversion function f cls The function form is: f cls =(1+α2·Dist pro2feat ) -1 Where α2 represents the fourth coefficient; Dist pro2feat This represents the Euclidean distance between pixel features and the prototypes of each final local class.
10. The remote sensing image semantic segmentation method based on class-centric prototypes as described in claim 9, characterized in that, The fourth coefficient α2 is set to 2.
