Image classification model training method, image classification system and classification method
By constructing an image classification model including a shared feature extractor and branch network, cross-domain and domain orthogonal invariant features are extracted, which solves the problem of ignoring domain orthogonal features in the existing technology and improves the model's generalization ability and classification accuracy. Rate.
Patent Information
- Application Number
- CN202410609169.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-16
- Publication Date
- 2024-08-23
AI Technical Summary
Existing domain generalization methods ignore domain orthogonal invariant features when training deep neural network models, resulting in the model being unable to fully extract features related to the classification task, thereby reducing the classification accuracy.
By building an image classification model that contains a shared feature extractor, a first-class branch network and multiple second-class branch networks, cross-domain invariant features and domain orthogonal invariant features are extracted, and multiple training and preset strategies are used to optimize model performance. , ensuring that the model can extract cross-domain and domain orthogonally invariant features.
The model's generalization ability and classification accuracy are improved, and by separating cross-domain and domain orthogonal invariant features, the model can more effectively handle data from unseen fields.
Smart Images

Figure CN118537637A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision, and in particular, to image classification technology in the field of computer vision, and more particularly, to an image classification model training method, an image classification system and an image classification method. Background Art
[0002] Deep neural networks are very suitable for processing independent and identically distributed data, and when training deep neural networks, the training data and test data share the same data distribution (for example, the training set and the test set have the same set of category labels). However, when the trained deep neural network model faces data from unseen domains, the performance of the deep neural network model will drop significantly due to the shift in data distribution. To solve this problem, researchers proposed a domain generalization approach to train deep neural networks, where domain generalization aims to minimize the generalization risk of potential data transfer so that the trained deep neural network model can show the best processing performance on unseen data.
[0003] In the domain generalization method, extracting cross-domain invariant features is its core strategy, which aims to find cross-domain invariant features (DI). Cross-domain invariant features indicate features related to category classification tasks between similar samples in different datasets, so as to ensure that the deep neural network model has the ability to extract cross-domain invariant features after training, thereby enabling the deep neural network model to process data from unseen domains.
[0004] Although domain generalization can be used to train deep neural networks, the deep neural network models trained in this way still have defects when processing data from unseen domains. Figure 1 The feature extraction process of the existing domain generalization method is presented to explain the shortcomings of using this method to train deep neural network models. Figure 1 It can be seen that, assuming that during the training process, datasets D1 and D2 from different fields are used as training sets, and dataset D pT As a test set (the training set and the test set have the same label set), assume that the data sets D1, D2 and D pT The relationship between the classification task related information (Y) is as follows Figure 1 As shown in the left figure, the data sets D1, D2 and D pT The cross-domain invariant features between are shown in blue, which are highlighted during the training process. Figure 1 In the right figure, in addition to the cross-domain invariant features represented by the blue part, there are also pink parts with a check and pink parts with a cross. The pink part is the domain orthogonal invariant feature (DOI), which indicates the features related to the category classification task that only exist between similar samples in a specific dataset. Among them, the pink part with a check indicates that it exists between datasets D2 and DpT The features (information) related to the classification task between , and the crossed pink part represents the features (information) related to the classification task that only exist in the dataset D1. Based on the strategy of the domain generalization method, it can be seen that during the training process, Figure 1 In the right figure, the cross-domain invariant features indicated by the blue part will be highlighted, while the features related to the classification task but specific to the domain indicated by the pink part will be weakened. Although the pink part contains classification-related features that only exist in dataset D1, this part of the features is redundant and does not participate in the test evaluation, but exists in datasets D2 and D pT The features related to the classification task are the beneficial parts and should be involved in the test evaluation. If all the pink parts are weakened, the trained deep neural network model cannot fully extract the feature representation related to the classification task, which will reduce the generalization ability of the deep neural network model and lead to a decrease in classification accuracy.
[0005] In summary, existing domain generalization methods focus on cross-domain invariant features and ignore the domain orthogonal invariant features related to the classification task, resulting in the inability of the trained deep neural network model to fully extract feature representations related to the classification task, which in turn leads to a decrease in classification accuracy.
[0006] It should be noted that this background technology is only used to introduce the relevant information of the present invention to help understand the technical solution of the present invention, but it does not mean that the relevant information is necessarily the prior art. If there is no evidence that the relevant information has been disclosed before the application date of the present invention, the relevant information shall not be regarded as the prior art. Summary of the invention
[0007] Therefore, the purpose of the present invention is to overcome the defects of the above-mentioned prior art and provide an image classification model training method, an image classification system and an image classification method.
[0008] The objectives of the present invention are achieved through the following technical solutions.
[0009] According to a first aspect of the present invention, there is provided an image classification model training method, the method comprising: step S1, data acquisition step: acquiring multiple image data sets, each image data set belonging to a different field from the other image data sets, each image data set comprising multiple image samples of different categories and their corresponding category labels and domain labels, wherein the category label indicates the category corresponding to the image sample, the domain label indicates the image data set to which the image sample belongs, and each image data set has the same set of category labels; step S2, model training step: step S21, constructing an initial image classification model, which comprises a shared feature extractor, a first-class branch network and a plurality of second-class branch networks, wherein: the shared feature extractor is used to extract the overall features of each image sample in different image data sets; the first-class branch network is used to extract the overall features of each image sample in all image data sets based on the overall Feature extraction: a cross-domain invariant feature corresponding to each image sample, and outputting a first initial category classification result based on the cross-domain invariant feature of each image sample, wherein the cross-domain invariant feature represents a feature related to the category classification task that exists between similar image samples in different image data sets; each two-category branch network corresponds to an image data set in a domain, and is used to extract a domain orthogonal invariant feature of each image sample in the corresponding image data set based on the overall features of all image samples in all image data sets, and outputting a domain classification result and a second initial category classification result based on the domain orthogonal invariant feature of each image sample in the corresponding image data set, wherein the domain orthogonal invariant feature represents a feature related to the classification task that only exists between similar image samples in a specific data set; step S22: using the multiple image data sets to train the initial image classification model multiple times until the model converges.
[0010] In some embodiments of the present invention, the method also includes: step S3, model performance testing step: step S31, obtaining a test set, wherein the test set includes multiple image samples of different categories and their corresponding category labels, and the test set has the same category label set as the multiple image data sets obtained in step S1; step S32, using the model trained to convergence in step S2 to obtain the first initial category classification result, multiple second initial category classification results and multiple domain classification results of each image sample in the test set; step S33, using a preset strategy to process the first initial category classification result, multiple second initial category classification results and multiple domain classification results of each image sample in the test set to obtain the final category classification result of each image sample, and compare the final category classification results of all images with their respective corresponding category labels to determine whether the performance of the model trained to convergence in step S2 has reached the preset requirements, and if the model does not meet the preset requirements, retrain the model until its performance reaches the preset requirements.
[0011] In some embodiments of the present invention, a type of branch network includes a cross-domain invariant feature extraction network and a first type of classifier, wherein the cross-domain invariant feature extraction network is used to extract the cross-domain invariant features corresponding to each image sample based on the overall features of all image samples in all image data sets, and the first type of classifier is used to output the first initial category classification result of each image sample based on the cross-domain invariant features of the image sample.
[0012] In some embodiments of the present invention, each two-class branch network includes a domain orthogonal invariant feature extraction network, a second class classifier and a domain classifier, wherein the domain orthogonal invariant feature extraction network is used to extract the domain orthogonal invariant features of each image sample in the corresponding image dataset based on the overall features of all image samples in all image datasets, the second class classifier is used to output its second initial category classification result based on the domain orthogonal invariant features of each image sample in the corresponding image dataset, and the domain classifier is used to output its domain classification result based on the domain orthogonal invariant features of each image sample in the corresponding image dataset.
[0013] In some embodiments of the present invention, in step S22, each training includes: randomly selecting multiple image samples from each image data set as anchor samples to form an anchor set, and numbering each anchor sample in sequence; selecting a first positive sample set and a second positive sample set from multiple image data sets according to a preset screening rule based on the anchor set; calculating the domain invariant loss according to a preset domain invariant loss calculation rule based on the anchor set, the first positive sample set and the second positive sample set, and calculating the domain orthogonal invariant loss according to a preset domain orthogonal invariant loss calculation rule; calculating the first target loss according to a preset first training function based on the domain invariant loss and the domain orthogonal invariant loss and updating the parameters of the shared feature extractor, the cross-domain invariant feature extraction network, all domain orthogonal invariant feature extraction networks, the first class classifier and all the second class classifiers with it; calculating the second target loss according to a preset second training function and updating the parameters of all domain classifiers with it.
[0014] In some embodiments of the present invention, the preset screening rules are: selecting an image sample with the same category as the anchor sample but belonging to a different image dataset from multiple image datasets as a first positive example and numbering it, wherein one anchor sample corresponds to one first positive example and the difference in number between the anchor sample and the first positive example corresponding to it is equal to the number of anchor samples, and the first positive examples of all anchor samples constitute a first positive example set; selecting an image sample with the same category as the anchor sample and belonging to the same image dataset from multiple image datasets as a second positive example and numbering it, wherein one anchor sample corresponds to one second positive example and the difference in number between the anchor sample and the second positive example corresponding to it is equal to twice the number of anchor samples, and the second positive examples of all anchor samples constitute a second positive example set.
[0015] In some embodiments of the present invention, the domain invariant loss calculation rule is:
[0016]
[0017] in,
[0018]
[0019] in, represents the domain invariant loss corresponding to the cross-domain invariant feature extraction network, N represents the number of anchor samples in the anchor set, and l DI (i,i+N) represents the domain invariant loss of image sample i and image sample i+N, l DI (i+N,i) is the domain invariant loss between image sample i+N and image sample i, l DI (i, j) represents the domain invariant loss of image sample i and image sample j, exp(·) represents the natural exponential function, sim(·) represents the standardized cosine similarity, represents the overall features of image sample i output by the shared feature extractor, k i represents the image dataset to which image sample i belongs, represents the overall features of image sample j output by the shared feature extractor, k j represents the image dataset to which the image sample j belongs, τ represents the temperature parameter, and I∈{0,1}, which represents an indicator function that satisfies When is 1, represents a set that satisfies y i represents the category label of image sample i, y l represents the category label of image sample l, represents the overall features of the image sample l output by the shared feature extractor, k l Represents the image dataset to which the image sample l belongs.
[0020] In some embodiments of the present invention, the domain orthogonality invariant loss calculation rule is:
[0021]
[0022] in,
[0023]
[0024] in, represents the domain orthogonal invariant loss corresponding to the domain orthogonal invariant feature extraction network in the k-th second-class branch network, K represents the number of image datasets, k represents the index number of the image dataset, represents the domain orthogonal invariant loss of image sample i and image sample i+2N, represents the domain orthogonal invariant loss of image sample i+2N and image sample i, represents the domain orthogonal invariant loss of image sample i and image sample q, represents the overall features of the shared feature extractor output image sample q, k q represents the image dataset to which the image sample q belongs, represents the overall features of the image sample f output by the shared feature extractor, k f represents the image dataset to which the image sample f belongs, II∈{0,1}, which represents an indicator function that satisfies When is 1, represents a set that satisfies y f represents the category label of image sample f, k f Represents the image dataset to which the image sample f belongs.
[0025] In some embodiments of the present invention, the preset first training function is:
[0026]
[0027] in, represents the first objective loss, θ F represents the shared feature extractor parameters, represents the parameters of the k-th class classifier. When k = 0, represents the first classifier parameter in a class branch network. When k=1,…,K, represents the second class classifier parameters in the 1st to Kth second class branch networks, represents the kth cross-domain invariant feature extraction network parameter or domain orthogonal invariant feature extraction network parameter. When k = 0, represents the cross-domain invariant feature extraction network parameters in a class of branch networks. When k = 1,…,K, represents the domain orthogonal invariant feature extraction network parameters in the 1st to Kth second-class branch networks, α represents the hyperparameter, represents the cross entropy loss calculated based on the first initial category classification results of all image samples output by the first category classifier in a branch network. It represents the cross entropy loss calculated based on the second initial category classification results of all image samples in the corresponding image dataset output by the second category classifier in the kth two-category branch network.
[0028] In some embodiments of the present invention, the preset second training function is:
[0029]
[0030] in,
[0031]
[0032] in, represents the second target loss, represents the domain classifier parameters in the 1st to Kth two-class branch networks, represents the cross entropy loss calculated based on the domain classification results of all image samples in the corresponding image dataset output by the domain classifier in the k-th two-category branch network, represents the cross entropy loss function, Represents the image sample i, y belonging to the kth image dataset d for The domain label, Represents the kth image dataset.
[0033] In some embodiments of the present invention, the preset strategy is:
[0034]
[0035] in,
[0036]
[0037] Among them, y n ∈Y indicates that the category label of the image sample n in the test set belongs to the category label set Y, Y represents the category label set, α1 represents the first balance parameter, represents the first initial category classification result of image sample n output by the first class classifier in a class branch network, η H (·) represents a piecewise function, represents the domain classification result of image sample n output by the domain classifier in the k-th two-class branch network, λ represents the threshold, opt represents the option, represents the second initial category classification result of image sample n output by the second category classifier in the kth two-category branch network, O represents the best domain orthogonal invariant information selection strategy;
[0038] Or, the default selection strategy is:
[0039]
[0040] in,
[0041]
[0042] Among them, α2 represents the second balance parameter, and I represents the inclusive domain orthogonal invariant information selection strategy.
[0043] According to a second aspect of the present invention, there is provided an image classification system, the system comprising: an image classification model trained by the method described in the first aspect of the present invention, for processing an image to be processed to obtain its corresponding first initial category classification result, multiple second initial category classification results and multiple domain classification results; an output module, which is configured to adopt a preset strategy to process the first initial category classification result, multiple second initial category classification results and multiple domain classification results of the image to be processed to obtain a final category classification result of the image to be processed.
[0044] According to a third aspect of the present invention, an image classification method comprises: step F1, obtaining an image to be processed; step F2, using the image classification system described in the second aspect of the present invention to process the image to be processed to obtain a category classification result.
[0045] Compared with the prior art, the advantages of the present invention are: (1) the cross-domain invariant features and domain orthogonal invariant features are separated, so that the model has the ability to extract cross-domain invariant features and domain orthogonal invariant features, which is beneficial to improving the classification accuracy; (2) the optimal domain orthogonal invariant information selection strategy (ODS) and the inclusive domain orthogonal invariant information selection strategy (IDS) are proposed to improve the classification accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The embodiments of the present invention are further described below with reference to the accompanying drawings, in which:
[0047] Figure 1 A schematic diagram showing the feature extraction process of existing domain generalization methods;
[0048] Figure 2 A schematic diagram of a flow chart of an image classification model training method according to an embodiment of the present invention;
[0049] Figure 3 This is a schematic diagram of an example of an image classification model training process according to an embodiment of the present invention;
[0050] Figure 4 A schematic diagram showing an example of the data relationship between source domain data and target domain data;
[0051] Figure 5 A schematic diagram of the composition of an image classification system according to an embodiment of the present invention;
[0052] Figure 6 Schematic diagram of the process of an image classification method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0053] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below through specific embodiments in conjunction with the accompanying drawings. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0054] As mentioned in the background technology section, existing domain generalization methods focus on cross-domain invariant features and ignore the domain orthogonal invariant features related to the classification task, resulting in the inability of the trained deep neural network model to fully extract feature representations related to the classification task, which in turn leads to a decrease in classification accuracy.
[0055] In order to solve the above problems and effectively utilize cross-domain invariant features and domain orthogonal invariant features, the inventors proposed a domain disentanglement invariant model training scheme. In this scheme, the domain orthogonal invariant features of all image data sets and the domain invariant features of each image data set are divided during model training, and the model retains the ability to extract the domain orthogonal invariant features of each image data set, so that the trained model can fully extract feature representations related to the classification task, so as to improve the generalization ability of the model and thus improve the classification accuracy of the model.
[0056] In summary, if Figure 2 As shown, the present invention proposes an image classification model training method, the method comprising: step S1, data acquisition step: acquiring multiple image data sets, each image data set belongs to a different field from other image data sets, each image data set includes multiple image samples of different categories and their corresponding category labels and domain labels, wherein the category label indicates the category corresponding to the image sample, the domain label indicates the image data set to which the image sample belongs, and each image data set has the same set of category labels; step S2, model training step: step S21, constructing an initial image classification model, which includes a shared feature extractor, a first-class branch network and multiple second-class branch networks; step S22, using the multiple image data sets to train the initial image classification model multiple times until the model converges.
[0057] Furthermore, in order to test the model performance, the method also includes: step S3, model performance testing step: obtaining a test set, and testing according to a preset strategy whether the performance of the model trained to convergence in step S2 has reached a preset requirement.
[0058] In order to better understand the present invention, each step is described in detail below in conjunction with specific embodiments.
[0059] Step S1: Data acquisition step
[0060] The step S1 is used to obtain training data. In step S1, multiple image data sets are obtained, each image data set belongs to a different field from other image data sets, and each image data set includes multiple image samples of different categories and their corresponding category labels and domain labels, wherein the category label indicates the category corresponding to the image sample, and the domain label indicates the image data set to which the image sample belongs, and each image data set has the same category label set. Taking the animal classification task as an example, image data sets in different fields can be obtained and each image data set can include multiple different categories of animal image samples and their corresponding animal category labels. For example, the first image data set is an image in the form of a sketch, including sketch images of lions, tigers, leopards, giraffes and elephants, the second image data set is an image in the form of a color photo, including color images of lions, tigers, leopards, giraffes and elephants, and the third image data set is an image in the form of a cartoon, including cartoon images of lions, tigers, leopards, giraffes and elephants in cartoon style. This is only an example, and the image categories included in the image data set are subject to actual needs, and the present invention does not make specific restrictions.
[0061] Step S2: Model training step
[0062] The step S2 is used to train the image classification model. In the step S2, it includes steps S21-S22, and each step is described in detail below.
[0063] Wherein, the step S21 is used to construct an initial image classification model, which includes a shared feature extractor, a first-class branch network and multiple second-class branch networks, wherein: the shared feature extractor is used to extract the overall features of each image sample in different image data sets; the first-class branch network is used to extract the cross-domain invariant features corresponding to each image sample based on the overall features of all image samples in all image data sets, and output its first initial category classification result based on the cross-domain invariant features of each image sample, wherein the cross-domain invariant features represent features related to the category classification task that exist between similar image samples in different image data sets; each second-class branch network corresponds to an image data set in a domain, and is used to extract domain orthogonal invariant features of each image sample in the corresponding image data set based on the overall features of all image samples in all image data sets, and output its domain classification result and the second initial category classification result based on the domain orthogonal invariant features of each image sample in the corresponding image data set, wherein the domain orthogonal invariant features represent features related to the classification task that only exist between similar image samples in a specific data set.
[0064] According to one embodiment of the present invention, a type of branch network includes a cross-domain invariant feature extraction network and a first type of classifier, wherein the cross-domain invariant feature extraction network is used to extract the cross-domain invariant features corresponding to each image sample based on the overall features of all image samples in all image data sets, and the first type of classifier is used to output its first initial category classification result based on the cross-domain invariant features of each image sample. It should be noted that the setting of a type of branch network is to extract cross-domain invariant features related to the category classification task. Taking the animal classification task described in the above example as an example, a type of branch network can extract the cross-domain invariant features of giraffes (e.g., neck length), cross-domain invariant features of lions (e.g., lion manes), cross-domain invariant features of tigers (e.g., Wang character lines on the forehead) and cross-domain invariant features of elephants (e.g., long noses) shared by the first image data set, the second image data set and the third image data set, so that the model has the ability to extract features related to the category classification task between similar samples in different image data sets, which is conducive to performing the classification task.
[0065] According to one embodiment of the present invention, each two-category branch network includes a domain orthogonal invariant feature extraction network, a second class classifier and a domain classifier, wherein the domain orthogonal invariant feature extraction network is used to extract the domain orthogonal invariant features of each image sample in the corresponding image dataset based on the overall features of all image samples in all image datasets, the second class classifier is used to output its second initial category classification result based on the domain orthogonal invariant features of each image sample in the corresponding image dataset, and the domain classifier is used to output its domain classification result based on the domain orthogonal invariant features of each image sample in the corresponding image dataset. It should be noted that each two-category branch network is set up to extract domain orthogonal invariant features of the field where the corresponding image dataset is located. Taking the animal classification task described in the above example as an example, it is assumed that the two-category branch network numbered 1 corresponds to the first image dataset, the two-category branch network numbered 2 corresponds to the second image dataset, and the two-category branch network numbered 3 corresponds to the third image dataset (the numbers do not need to correspond one to one, as long as each two-category branch network corresponds to one image dataset, this is just an example). Among them, when the two-category branch network numbered 2 corresponds to the second image dataset, the two-category branch network numbered 2 can extract the domain orthogonal invariant features of the giraffe (for example, tan spots), the domain orthogonal invariant features of the tiger (for example, orange-yellow fur color), and the domain orthogonal invariant features of the elephant (for example, gray skin), etc., so that the model has the ability to extract features related to the category classification task that only exist between similar samples in image datasets in a specific field, which is conducive to performing classification tasks.
[0066] The step S22 is used to train the initial image classification model. In step S22, the initial image classification model is trained multiple times using the multiple image data sets until the model converges.
[0067] According to one embodiment of the present invention, in step S22, each training includes: randomly selecting multiple image samples from each image data set as anchor samples to form an anchor set, and numbering each anchor sample in sequence; selecting a first positive sample set and a second positive sample set from multiple image data sets according to a preset screening rule based on the anchor set; calculating the domain invariant loss according to a preset domain invariant loss calculation rule based on the anchor set, the first positive sample set and the second positive sample set, and calculating the domain orthogonal invariant loss according to a preset domain orthogonal invariant loss calculation rule; calculating the first target loss according to a preset first training function based on the domain invariant loss and the domain orthogonal invariant loss and updating the parameters of the shared feature extractor, the cross-domain invariant feature extraction network, all domain orthogonal invariant feature extraction networks, the first class classifier and all the second class classifiers with it; calculating the second target loss according to a preset second training function and updating the parameters of all domain classifiers with it.
[0068] According to one embodiment of the present invention, the preset screening rules are: select an image sample from multiple image data sets that has the same category as the anchor sample but belongs to a different image data set as the first positive example and number it, wherein one anchor sample corresponds to one first positive example and the difference in number between the anchor sample and the first positive example corresponding to it is equal to the number of anchor samples, and the first positive examples of all anchor samples constitute a first positive example set; select an image sample from multiple image data sets that has the same category as the anchor sample and belongs to the same image data set as the second positive example and number it, wherein one anchor sample corresponds to one second positive example and the difference in number between the anchor sample and the second positive example corresponding to it is equal to twice the number of anchor samples, and the second positive examples of all anchor samples constitute a second positive example set. It should be noted that the anchor set can be expressed as k i Represents image sample x i The image dataset to which it belongs, y i Represents image sample x i The category label of the first positive sample set can be expressed as k i+N Represents image sample x i+N The image dataset to which it belongs, y i+N Represents image sample x i+N The category label of the second positive sample set can be expressed as k i+2N Represents image sample x i+2N The image dataset to which it belongs, y i+2N Represents image sample x i+2N The category label of the anchor set and the first positive sample set satisfies the condition y i =y i+N and k i ≠ki+N , the anchor set and the second positive sample set meet the condition y i =y i+2N and k i =k i+2N .
[0069] According to one embodiment of the present invention, the domain invariant loss calculation rule is:
[0070]
[0071] in,
[0072]
[0073] in, represents the domain invariant loss corresponding to the cross-domain invariant feature extraction network, N represents the number of anchor samples in the anchor set, and l DI (i,i+N) represents the domain invariant loss of image sample i and image sample i+N, l DI (i+N,i) is the domain invariant loss between image sample i+N and image sample i, l DI (i, j) represents the domain invariant loss of image sample i and image sample j, exo(·) represents the natural exponential function, sim(·) represents the normalized cosine similarity, represents the overall features of image sample i output by the shared feature extractor, k i represents the image dataset to which image sample i belongs, represents the overall features of image sample j output by the shared feature extractor, k j represents the image dataset to which the image sample j belongs, τ represents the temperature parameter, and I∈{0,1}, which represents an indicator function that satisfies When is 1, represents a set that satisfies y i represents the category label of image sample i, y l represents the category label of image sample l, represents the overall features of the image sample l output by the shared feature extractor, k lRepresents the image dataset to which the image sample l belongs. It should be noted that the domain invariant loss is calculated based on the idea of contrastive learning. The core of contrastive learning is to make similar samples closer in the feature space and dissimilar samples farther away. Based on this, a cross-domain invariant feature extraction network in a type of branch network will continuously shorten the distance between each anchor sample and its corresponding first positive example (the difference between the number of the anchor sample and its corresponding first positive example is N), as well as the distance between each first positive example and its corresponding second positive example (the difference between the number of the first positive example and its corresponding second positive example is N) during each training process, and at the same time, push away the distance between other image samples that are dissimilar to each anchor sample and each first positive example, that is, push away each anchor sample and each first positive example from those that satisfy y. i ≠y l The distance between other image samples l, and because the anchor set, the first positive sample set and the second positive sample set meet the condition y i =y i+N =y i+2N and k i =k i+2N ≠k i+N Therefore, after multiple trainings, the cross-domain invariant feature extraction network is able to extract features related to category classification tasks between similar samples in different image datasets.
[0074] According to one embodiment of the present invention, the domain orthogonal invariant loss calculation rule is:
[0075]
[0076] in,
[0077]
[0078] in, represents the domain orthogonal invariant loss corresponding to the domain orthogonal invariant feature extraction network in the k-th second-class branch network, K represents the number of image datasets, k represents the index number of the image dataset, represents the domain orthogonal invariant loss of image sample i and image sample i+2N, represents the domain orthogonal invariant loss of image sample i+2N and image sample i, represents the domain orthogonal invariant loss of image sample i and image sample q, represents the overall features of the shared feature extractor output image sample q, k q represents the image dataset to which the image sample q belongs, represents the overall features of the image sample f output by the shared feature extractor, k f represents the image dataset to which the image sample f belongs, II∈{0,1}, which represents an indicator function that satisfies When is 1, represents a set that satisfies y f represents the category label of image sample f, k f represents the image dataset to which the image sample f belongs. It should be noted that the domain orthogonal invariant loss is also calculated based on the idea of contrastive learning. The difference is that the domain orthogonal invariant feature extraction network in each second-class branch network will continuously shorten the distance between each anchor sample belonging to its corresponding image dataset and the second positive sample corresponding to the anchor sample during each training process (the difference between the number of the anchor sample and the second positive sample corresponding to the anchor sample is 2N), and at the same time, push away the distance between other image samples that are not similar to each anchor sample, that is, push away the distance between each anchor sample and the image sample that satisfies y i ≠y f or k i ≠k f The distance between other image samples f, and because the anchor set and the second positive sample set meet the condition y i =y i+2N and k i =k i+2N Therefore, the domain orthogonal invariant feature extraction network in each two-category classification network can have the ability to extract features related to the category classification task that only exist between similar samples in a specific image dataset after multiple trainings.
[0079] According to one embodiment of the present invention, the preset first training function is:
[0080]
[0081] in, represents the first objective loss, θ F represents the shared feature extractor parameters, represents the parameters of the k-th class classifier. When k = 0, represents the first classifier parameter in a class branch network. When k=1,…,K, represents the second class classifier parameters in the 1st to Kth second class branch networks, represents the kth cross-domain invariant feature extraction network parameter or domain orthogonal invariant feature extraction network parameter. When k = 0, represents the cross-domain invariant feature extraction network parameters in a class of branch networks. When k = 1,…,k, represents the domain orthogonal invariant feature extraction network parameters in the 1st to Kth second-class branch networks, α represents the hyperparameter, represents the cross entropy loss calculated based on the first initial category classification results of all image samples output by the first category classifier in a branch network. It represents the cross entropy loss calculated based on the second initial category classification results of all image samples in the corresponding image dataset output by the second category classifier in the kth two-category branch network.
[0082] According to one embodiment of the present invention, the preset second training function is:
[0083]
[0084] in,
[0085]
[0086] in, represents the second target loss, represents the domain classifier parameters in the 1st to Kth two-class branch networks, represents the cross entropy loss calculated based on the domain classification results of all image samples in the corresponding image dataset output by the domain classifier in the k-th two-category branch network, represents the cross entropy loss function, Represents the image sample i, y belonging to the kth image dataset d for The domain label, Represents the kth image dataset.
[0087] In order to better understand the model training step of step S2 introduced in the above embodiment, Figure 3 The model training process shown is taken as an example for specific explanation.
[0088] First, let’s introduce the training data. Figure 3 It can be seen that the training data includes image datasets in three fields. The first field is a sketch image dataset, which includes multiple sketch image samples of giraffes. The image dataset can be represented as Wherein, V represents the number of categories (in this case, V=1, and each image dataset only includes images of the giraffe category), s1 represents the image dataset of the first domain, represents the number of image samples contained in the image dataset of the first domain; the second domain is an image dataset in the form of color photos, which includes multiple color image samples of giraffes. This image dataset can be represented as s2 represents the image dataset of the second domain, represents the number of image samples contained in the image dataset of the second domain; the third domain is a cartoon image dataset, which includes multiple cartoon image samples of giraffes. This dataset can be represented as s3 represents the image dataset in the third field. Represents the number of image samples contained in the image dataset of the third domain.
[0089] Secondly, we introduce the initial image classification model built based on the training data. Figure 3 It can be seen that the initial image classification model includes a shared feature extractor, a first-class branch network, a first-class branch network, a second-class branch network and a third-class branch network, wherein the first-class branch network includes a cross-domain invariant feature extraction network and a first-class classifier, each second-class branch network includes a domain orthogonal invariant feature extraction network, a second-class classifier and a domain classifier, and the first-class branch network corresponds to an image dataset in the first field, the second-class branch network corresponds to an image dataset in the second field, and the third branch network corresponds to an image dataset in the third field.
[0090] It should be noted that the shared feature extractor is used to extract the overall feature z of each image sample input to it. c , the cross-domain invariant feature extraction network is used to extract the overall feature z of each image sample c Extract the cross-domain invariant feature R0 of each image sample. The first classifier is used to output the category classification result of each image sample based on the cross-domain invariant feature R0 of each image sample. The domain orthogonal invariant feature extraction network in the first and second branch networks is used to extract the overall feature z of each image sample based on the c Extract domain orthogonal invariant features belonging to the first domain for each image sample The second classifier in the first and second class branch network is based on domain orthogonal invariant features Output the category classification results for each image sample The domain classifiers in the first and second branch networks are used to classify domain orthogonal invariant features. Output the domain classification result for each image sample (indicating the probability that each image sample belongs to the first domain); the domain orthogonal invariant feature extraction network in the second class branch network is used to extract features based on the overall feature z of each image sample c Extract domain orthogonal invariant features belonging to the second domain for each image sample The second classifier in the second class branch network is based on domain orthogonal invariant features Output the category classification results for each image sample The domain classifier in the second branch network is used to classify the domain based on the domain orthogonal invariant features. Output the domain classification result for each image sample (indicating the probability that each image sample belongs to the second domain), the domain orthogonal invariant feature extraction network in the third second-class branch network is used to extract features based on the overall feature z of each image sample cExtract domain orthogonal invariant features belonging to the third domain for each image sample The second classifier in the third class branch network is based on domain orthogonal invariant features Output the category classification results for each image sample The domain classifier in the third branch network is used to classify the domain based on the orthogonal invariant features. Output the domain classification result for each image sample (indicating the probability of each image sample belonging to the third domain).
[0091] Finally, the initial image classification model is trained multiple times using the training data until the model converges. In each training process, multiple image samples are randomly selected from the image dataset of the first domain, the image dataset of the second domain, and the dataset of the third domain to form an anchor set A, and then different image samples of the same category in different domains corresponding to each anchor sample are selected based on the anchor set A to form a first positive sample set B, and different image samples of the same category in the same domain corresponding to each anchor sample are selected based on the anchor set A to form a second positive sample set C, and the anchor set A, the first positive sample set B, and the second positive sample set C constitute the training batch for the current training; then, the domain invariant loss and the domain orthogonal invariant loss are calculated based on the anchor set A, the first positive sample set B, and the second positive sample set C. Finally, based on the domain invariant loss and the domain orthogonal invariant loss, the first target loss is calculated according to the preset first training function and the parameters of the shared feature extractor, the cross-domain invariant feature extraction network, all domain orthogonal invariant feature extraction networks, the first class classifier, and all the second class classifiers are updated with it, and the second target loss is calculated according to the preset second training function and the parameters of all domain classifiers are updated with it.
[0092] Step S3: Model performance testing step
[0093] According to one embodiment of the present invention, step S3 includes: step S31, obtaining a test set, wherein the test set includes multiple image samples of different categories and their corresponding category labels, and the test set has the same category label set as the multiple image data sets obtained in step S1; step S32, using the model trained to convergence in step S2 to obtain a first initial category classification result, multiple second initial category classification results and multiple domain classification results for each image sample in the test set; step S33, using a preset strategy to process the first initial category classification result, multiple second initial category classification results and multiple domain classification results of each image sample in the test set to obtain a final category classification result for each image sample, and comparing the final category classification results of all images with their respective corresponding category labels to determine whether the performance of the model trained to convergence in step S2 has reached the preset requirements, and if the model does not reach the preset requirements, retrain the model until its performance reaches the preset requirements.
[0094] The preset strategies include the best domain orthogonal invariant information selection strategy (ODS) and the inclusive domain orthogonal invariant information selection strategy (IDS). Figure 4 The data relationship between the training data (source domain data) and the test data (target domain data) is shown to introduce the optimal domain orthogonal invariant information selection strategy and the inclusive domain orthogonal invariant information selection strategy.
[0095] Depend on Figure 4 As can be seen, suppose there are two training data sets D1 and D2 (D1 and D2 are source domain data) and a test data set D pT (D pT is the target domain data), datasets D1, D2 and D pT There is a relationship between the classification task related information (Y) Figure 4 The four quadrants shown correspond to four situations, where it is assumed that the data sets D1, D2 and D pT The relationship between the information related to the classification task (Y) corresponds to Figure 4 The first quadrant, which means that the test data set D pT Far away from the training datasets D1 and D2, in this case, only the cross-domain invariant features represented by the blue part are beneficial to the classification task during the test process; assuming that the datasets D1, D2 and D pT The relationship between the information related to the classification task (Y) corresponds to Figure 4 The second quadrant, which means that the test data set D pT Close to the training dataset D2 but far from D1, in this case, the cross-domain invariant features represented by the blue part and the domain orthogonal invariant features represented by the checked pink part are both beneficial to the classification task during the test process; assuming that the datasets D1, D2 and D pTThe relationship between the information related to the classification task (Y) corresponds to Figure 4 The third quadrant, which means that the test data set D pT It may include training datasets D1 and D2. In this case, the cross-domain invariant features represented by the blue part and the domain orthogonal invariant features represented by all the checked pink parts are all beneficial to the classification task during the test process; assuming that datasets D1, D2 and D pT The relationship between the information related to the classification task (Y) corresponds to Figure 4 The fourth quadrant, which means that the test data set D pT Close to including the training dataset D1 and far from D2, in this case, the cross-domain invariant features represented by the blue part and the domain orthogonal invariant features represented by the checked pink part are both beneficial to the classification task during the test process. Figure 4 It can be seen that cross-domain invariant features are always beneficial to the classification task in the test process (because the training data and the test data have the same label category distribution), but not all domain orthogonal invariant features are beneficial to the classification task in the test process. Therefore, the present invention proposes the best domain orthogonal invariant information selection strategy and the inclusive domain orthogonal invariant information selection strategy to deal with the classification task of the target domain data that meets different data relationships with the source domain data. It should be noted that Figure 4 The case where the source domain data includes two training data sets is used as an example to illustrate the data relationship between other numbers of source domain data and target domain data. Figure 4 Similar, I won’t go into details here.
[0096] Among them, the optimal domain orthogonal invariant information selection strategy corresponds to Figure 4 The best domain orthogonal invariant information selection strategy refers to that in the process of performing the classification task, in addition to the cross-domain invariant features, it may be necessary to select an optimal domain orthogonal invariant feature to assist the classification. According to one embodiment of the present invention, the best domain orthogonal invariant information selection strategy is:
[0097]
[0098] in,
[0099]
[0100] Among them, y n ∈Y indicates that the category label of the image sample n in the test set belongs to the category label set Y, Y represents the category label set, α1 represents the first balance parameter, represents the first initial category classification result of image sample n output by the first class classifier in a class branch network, η H (·) represents a piecewise function, represents the domain classification result of image sample n output by the domain classifier in the k-th two-class branch network, λ represents the threshold, opt represents the option, represents the second initial category classification result of the image sample n output by the second class classifier in the kth second class branch network, and O represents the best domain orthogonal invariant information selection strategy. It should be noted that the value of the threshold λ can be 1 / 2, or can be determined based on actual needs, and the present invention does not impose any special restrictions.
[0101] The inclusive domain orthogonal invariant information selection strategy corresponds to Figure 4 The inclusive domain orthogonal invariant information selection strategy refers to selecting all domain orthogonal invariant features that are beneficial to the classification task to assist classification in addition to cross-domain invariant features during the classification task. According to one embodiment of the present invention, the inclusive domain orthogonal invariant information selection strategy is:
[0102]
[0103] in,
[0104]
[0105] Among them, α2 represents the second balance parameter, and I represents the inclusive domain orthogonal invariant information selection strategy.
[0106] Based on the above embodiments, Figure 5 As shown, the present invention also proposes an image classification system, which includes: an image classification model trained by the method described in the aforementioned embodiment, used to process the image to be processed to obtain its corresponding first initial category classification result, multiple second initial category classification results and multiple domain classification results; an output module, which is configured to use a preset strategy to process the first initial category classification result, multiple second initial category classification results and multiple domain classification results of the image to be processed to obtain the final category classification result of the image to be processed.
[0107] In order to verify that the image classification system proposed in the present invention has better category classification effect than the prior art, the present invention proposes to configure algorithms ERM, DANN, CORAL, GroupDRO, IRM, VREx, ARM, SagNet, AND-mask, SAND-mask, Fish, Fisher, CCFP, DERM and RIDG on ResNet-50 respectively, and use them as control models to conduct control experiments with image classification systems configured with the best domain orthogonal invariant information selection strategy (IDS) and the inclusive domain orthogonal invariant information selection strategy (ODS), respectively. The size of the overall feature in the image classification model in the image classification system is set to 2048, the size of the cross-domain invariant feature or the domain orthogonal invariant feature is set to 512, the hyperparameter α is set to 0.16, the first balance parameter α1 is set to 0.2, the second balance parameter α2 is set to 0.08, and the temperature parameter τ is set to 0.07. During the experiment, the leave-one-domain-out (LODO) method was used for verification and evaluation. That is, when conducting experiments on the datasets RotatedMNIST, PACS, OfficeHome, VLCS, or DomainNet, one domain data was selected from the dataset as the unseen target domain (test data), and the remaining domain data was set as the source domain data (training data). The image sample size in the dataset was adjusted to 224×224 for the experiment, and the experimental results are shown in Table 1. Table 1 shows the average classification accuracy and overall classification accuracy of ResNet-50 for all domain data in the dataset RotatedMNIST, PACS, OfficeHome, VLCS, or DomainNet as the target domain when ResNet-50 is configured with algorithms ERM, DANN, CORAL, GroupDRO, IRM, VREx, ARM, SagNet, AND-mask, SAND-mask, Fish, Fisher, CCFP, DERM, and RIDG, as well as the average classification accuracy and overall classification accuracy of the image classification system configured with the best domain orthogonal invariant information selection strategy (IDS) and the inclusive domain orthogonal invariant information selection strategy (ODS) for all domain data in the dataset RotatedMNIST, PACS, OfficeHome, VLCS, or DomainNet as the target domain. As can be seen from Table 1, on all datasets, the image classification system configured with the best domain orthogonal invariant information selection strategy (IDS) and the inclusive domain orthogonal invariant information selection strategy (ODS) proposed in the present invention obtains the best and second-best performances, and has better category classification effect than the prior art.
[0108] Table 1
[0109] algorithm RotatedMNIST PACS OfficeHome VLCS DomainNet AVG ERM 98.0±0.0 85.5±0.2 66.5±0.3 77.5±0.4 40.9±0.1 73.7 DANN 97.8±0.1 83.6±0.4 65.9±0.6 78.6±0.4 38.3±0.1 72.8 CORAL 98.0±0.0 86.2±0.3 68.7±0.3 78.8±0.6 41.5±0.1 74.6 GroupDRO 98.0±0.0 84.4±0.8 66.0±0.7 76.7±0.6 33.3±0.2 71.7 IRM 97.7±0.1 83.5±0.8 64.3±2.2 78.5±0.5 33.9±2.8 71.6 VREx 97.9±0.1 84.9±0.6 66.4±0.6 78.3±0.2 33.6±2.9 72.2 ARM 98.2±0.1 85.1±0.4 64.8±0.3 77.6±0.3 35.5±0.2 72.2 SagNet 98.0±0.0 86.3±0.2 68.1±0.1 77.8±0.5 40.3±0.1 74.4 AND-mask 97.6±0.1 84.4±1.3 65.6±0.3 78.1±1.3 37.2±0.9 72.6 SAND-mask 97.4±0.1 84.6±01.2 65.8±0.5 77.4±0.7 32.1±0.7 71.5 Fish 97.9±0.1 85.5±0.1 68.6±0.3 77.8±0.3 42.7±0.4 74.5 Fishr 97.8±0.0 85.5±0.1 67.8±0.4 77.8±0.4 41.7±0.2 74.1 CCFP 97.8±0.1 86.6±0.2 68.9±0.1 78.9±0.3 41.2±0.0 74.7 DERM 97.6±0.1 84.8±0.5 65.7±0.6 77.9±0.5 41.0±0.2 73.4 RIDG 97.9±0.1 84.7±0.2 68.6±0.2 77.8±0.4 41.9±0.3 74.2 IDS(ours) 98.6±0.1 86.4±0.3 69.7±0.2 79.3±0.7 42.7±0.0 75.3 ODS(ours) 98.5±0.0 86.6±0.6 69.7±0.2 79.2±1.1 43.0±0.1 75.4
[0110] Based on the above embodiments, Figure 6 As shown, the present invention also proposes an image classification method, which includes: step F1, obtaining an image to be processed; step F2, using the image classification system described in the above embodiment to process the image to be processed to obtain a category classification result.
[0111] The beneficial effects of the present invention are: (1) separating cross-domain invariant features and domain orthogonal invariant features, so that the model has the ability to extract cross-domain invariant features and domain orthogonal invariant features; (2) proposing an optimal domain orthogonal invariant information selection strategy (ODS) and an inclusive domain orthogonal invariant information selection strategy (IDS), thereby improving the classification accuracy.
[0112] It should be noted that although the above describes the various steps in a specific order, it does not mean that the various steps must be executed in the above specific order. In fact, some of these steps can be executed concurrently or even in a different order as long as the required functions can be achieved.
[0113] The present invention may be a system, a method and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present invention.
[0114] Computer readable storage medium can be a tangible device that holds and stores instructions used by an instruction execution device. Computer readable storage medium can include, for example, but is not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination thereof. More specific examples (non-exhaustive list) of computer readable storage medium include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, for example, a punch card or a protruding structure in a groove on which instructions are stored, and any suitable combination thereof.
[0115] The embodiments of the present invention have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.
Claims
1. A method for training an image classification model, characterized in that: The method comprises: Step S1, data acquisition step: acquiring multiple image data sets, each image data set belongs to a different field than other image data sets, each image data set includes multiple image samples of different categories and their corresponding category labels and domain labels, wherein the category label indicates the category corresponding to the image sample, the domain label indicates the image data set to which the image sample belongs, and each image data set has the same category label set; Step S2, model training steps: Step S21: construct an initial image classification model, which includes a shared feature extractor, a first-class branch network and multiple second-class branch networks, wherein: The shared feature extractor is used to extract the overall features of each image sample in different image datasets; A branch network is used to extract a cross-domain invariant feature corresponding to each image sample based on the overall features of all image samples in all image data sets, and output a first initial category classification result of each image sample based on the cross-domain invariant feature, wherein the cross-domain invariant feature represents a feature related to the category classification task that exists between similar image samples in different image data sets; Each of the two-category branch networks corresponds to an image dataset in a domain, and is used to extract domain orthogonal invariant features of each image sample in the corresponding image dataset based on the overall features of all image samples in all image datasets, and output its domain classification result and the second initial category classification result based on the domain orthogonal invariant features of each image sample in the corresponding image dataset, wherein the domain orthogonal invariant features represent features related to the classification task that exist only between similar image samples in a specific dataset; Step S22: using the multiple image data sets to train the initial image classification model multiple times until the model converges.
2. The method according to claim 1, characterized in that The method further comprises: Step S3: Model performance test steps: Step S31, obtaining a test set, wherein the test set includes a plurality of image samples of different categories and their corresponding category labels, and the test set has the same category label set as the plurality of image data sets obtained in step S1; Step S32, using the model trained to convergence in step S2 to obtain a first initial category classification result, multiple second initial category classification results, and multiple domain classification results for each image sample in the test set; Step S33, using a preset strategy to process the first initial category classification result, multiple second initial category classification results and multiple domain classification results of each image sample in the test set to obtain the final category classification result of each image sample, and compare the final category classification results of all images with their corresponding category labels to determine whether the performance of the model trained to convergence in step S2 has reached the preset requirements, and if the model does not meet the preset requirements, retrain the model until its performance meets the preset requirements.
3. The method according to claim 2, characterized in that A type of branch network includes a cross-domain invariant feature extraction network and a first type of classifier, wherein the cross-domain invariant feature extraction network is used to extract the cross-domain invariant features corresponding to each image sample based on the overall features of all image samples in all image data sets, and the first type of classifier is used to output the first initial category classification result of each image sample based on the cross-domain invariant features.
4. The method according to claim 3, characterized in that Each two-category branch network includes a domain orthogonal invariant feature extraction network, a second class classifier and a domain classifier, wherein the domain orthogonal invariant feature extraction network is used to extract the domain orthogonal invariant features of each image sample in the corresponding image dataset based on the overall features of all image samples in all image datasets, the second class classifier is used to output its second initial category classification result based on the domain orthogonal invariant features of each image sample in the corresponding image dataset, and the domain classifier is used to output its domain classification result based on the domain orthogonal invariant features of each image sample in the corresponding image dataset.
5. The method according to claim 4, characterized in that In step S22, each training includes: Randomly select multiple image samples from each image dataset as anchor samples to form an anchor set, and number each anchor sample in sequence; Selecting a first positive sample set and a second positive sample set from a plurality of image data sets according to a preset screening rule based on the anchor set; Calculating a domain invariant loss according to a preset domain invariant loss calculation rule based on the anchor set, the first positive sample set, and the second positive sample set, and calculating a domain orthogonal invariant loss according to a preset domain orthogonal invariant loss calculation rule; Based on the domain invariant loss and the domain orthogonal invariant loss, a first target loss is calculated according to a preset first training function, and the first target loss is used to update the parameters of the shared feature extractor, the cross-domain invariant feature extraction network, all domain orthogonal invariant feature extraction networks, the first class classifier, and all the second class classifiers; The second target loss is calculated according to a preset second training function and used to update the parameters of all domain classifiers.
6. The method according to claim 5, characterized in that The preset filtering rules are: Select an image sample of the same category as the anchor sample but belonging to a different image dataset from multiple image datasets as a first positive sample and number it, wherein one anchor sample corresponds to one first positive sample and the difference between the numbers of the anchor sample and the first positive sample corresponding to it is equal to the number of anchor samples, and the first positive samples of all anchor samples constitute a first positive sample set; An image sample with the same category as the anchor sample and belonging to the same image dataset is selected from multiple image datasets as the second positive sample and is numbered, wherein one anchor sample corresponds to one second positive sample and the difference in number between the anchor sample and its corresponding second positive sample is equal to twice the number of anchor samples, and the second positive samples of all anchor samples constitute a second positive sample set.
7. The method according to claim 6, characterized in that The domain invariant loss calculation rule is: in, in, represents the domain invariant loss corresponding to the cross-domain invariant feature extraction network, N represents the number of anchor samples in the anchor set, represents the domain invariant loss of image sample i and image sample i+N, The domain invariant loss of image sample i+N and image sample i, represents the domain invariant loss between image sample i and image sample j, exp(·) represents the natural exponential function, sim(·) represents the standardized cosine similarity, represents the overall features of image sample i output by the shared feature extractor, k i represents the image dataset to which image sample i belongs, represents the overall features of image sample j output by the shared feature extractor, k j represents the image dataset to which the image sample j belongs, τ represents the temperature parameter, and I∈{0,1}, which represents an indicator function that satisfies When is 1, represents a set that satisfies y i represents the category label of image sample i, y l represents the category label of image sample l, represents the overall features of the image sample l output by the shared feature extractor, k l Represents the image dataset to which the image sample l belongs.
8. The method according to claim 7, characterized in that The calculation rule of domain orthogonal invariant loss is: in, in, represents the domain orthogonal invariant loss corresponding to the domain orthogonal invariant feature extraction network in the k-th second-class branch network, K represents the number of image datasets, k represents the index number of the image dataset, represents the domain orthogonal invariant loss of image sample i and image sample i+2N, represents the domain orthogonal invariant loss of image sample i+2N and image sample i, represents the domain orthogonal invariant loss of image sample i and image sample q, represents the overall features of the shared feature extractor output image sample q, k q represents the image dataset to which the image sample q belongs, represents the overall features of the image sample f output by the shared feature extractor, k f represents the image dataset to which the image sample f belongs, II∈{0,1}, which represents an indicator function that satisfies When is 1, represents a set that satisfies or k i ≠k f },y f represents the category label of image sample f, k f Represents the image dataset to which the image sample f belongs.
9. The method according to claim 8, characterized in that The preset first training function is: in, represents the first objective loss, θ F represents the shared feature extractor parameters, represents the parameters of the k-th class classifier. When k = 0, represents the first classifier parameter in a class branch network. When k=1,…,K, represents the second class classifier parameters in the 1st to Kth second class branch networks, represents the kth cross-domain invariant feature extraction network parameter or domain orthogonal invariant feature extraction network parameter. When k = 0, represents the cross-domain invariant feature extraction network parameters in a class of branch networks. When k = 1,…,K, represents the domain orthogonal invariant feature extraction network parameters in the 1st to Kth second-class branch networks, α represents the hyperparameter, represents the cross entropy loss calculated based on the first initial category classification results of all image samples output by the first category classifier in a branch network. It represents the cross entropy loss calculated based on the second initial category classification results of all image samples in the corresponding image dataset output by the second category classifier in the kth two-category branch network.
10. The method according to claim 9, characterized in that The preset second training function is: in, in, represents the second target loss, represents the domain classifier parameters in the 1st to Kth two-class branch networks, represents the cross entropy loss calculated based on the domain classification results of all image samples in the corresponding image dataset output by the domain classifier in the k-th two-category branch network, represents the cross entropy loss function, Represents the image sample i, y belonging to the kth image dataset d for The domain label, Represents the kth image dataset.
11. The method according to claim 10, characterized in that The default strategies are: in, Among them, y n ∈Y indicates that the category label of the image sample n in the test set belongs to the category label set Y, Y represents the category label set, α1 represents the first balance parameter, represents the first initial category classification result of image sample n output by the first class classifier in a class branch network, η H (·) represents a piecewise function, represents the domain classification result of image sample n output by the domain classifier in the k-th two-class branch network, λ represents the threshold, opt represents the option, represents the second initial category classification result of image sample n output by the second category classifier in the kth two-category branch network, O represents the best domain orthogonal invariant information selection strategy; Or, the default selection strategy is: in, Among them, α2 represents the second balance parameter, and I represents the inclusive domain orthogonal invariant information selection strategy.
12. An image classification system, characterized in that: The system comprises: An image classification model trained by the method according to any one of claims 1 to 11, used to process the image to be processed to obtain its corresponding first initial category classification result, multiple second initial category classification results and multiple domain classification results; The output module is configured to process the first initial category classification result, multiple second initial category classification results and multiple domain classification results of the image to be processed using a preset strategy to obtain a final category classification result of the image to be processed.
13. An image classification method, characterized in that: The method comprises: Step F1, obtaining an image to be processed; Step F2: using the image classification system described in claim 12 to process the image to be processed to obtain a category classification result.
14. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and the computer program can be executed by a processor to implement the steps of the method according to any one of claims 1-11 and 13.
15. An electronic device, characterized in that: include: one or more processors; as well as A memory, wherein the memory is used to store executable instructions; The one or more processors are configured to implement the steps of the method of any one of claims 1-11 and 13 by executing the executable instructions.
