Domain hybrid unsupervised domain adaptive image classification method based on data enhancement
By using data enhancement to generate an intermediate domain in the image classification task, the problem of excessive differences between the source domain and the target domain is solved, the image classification accuracy and generalization ability of the model are improved, and the transfer learning effect is optimized.
Patent Information
- Application Number
- CN202410712908.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-04
- Publication Date
- 2024-09-27
AI Technical Summary
In image classification tasks, when the domain difference between the source domain and the target domain is too large, traditional adversarial domain alignment methods are difficult to effectively align, resulting in model overfitting and poor transfer learning results.
A domain hybrid unsupervised domain adaptive image classification method based on data enhancement is used to generate intermediate domains through Fourier transform, reduce inter-domain differences, improve model generalization, and construct losses through feature extractors, classifiers and domain discriminators function for training.
By generating an intermediate domain to shorten the distance between the two domains, the image classification accuracy and generalization ability of the model are improved, training errors caused by early bias of the model are reduced, and the entire image classification process is optimized.
Smart Images

Figure CN118710951A
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer vision transfer learning domain adaptation image classification, and specifically is a domain mixing unsupervised domain adaptation image classification method based on data enhancement. Background Art
[0002] In the image classification task, domain adaptation, as a key method of transfer learning, aims to solve the distribution difference problem between the source domain and the target domain. Its core lies in extracting the domain-invariant features that are common to the source domain and the target domain and that are discriminative, thereby reducing the difference between the two and aligning the source domain and the target domain, so that the trained model can achieve a better image classification effect in the target domain.
[0003] The domain gap between the source domain and the target domain is an important issue in domain adaptation. When the difference between the two domains is too large, it becomes very difficult to directly perform global alignment. The goal of domain alignment is to find a way to effectively transfer the knowledge of the source domain to the target domain and improve the performance of the target domain model.
[0004] Traditional adversarial domain alignment methods, such as adversarial training, aim to achieve alignment by minimizing the distribution difference between the source and target domains. However, these methods are usually limited by the number of training samples. In the case of insufficient samples, it is difficult for the model to learn generalized features, which is especially obvious when the two domains are very different. Overfitting problems arise as the model may learn specific noise and details in the source domain data instead of generalized features.
[0005] In the early stages of model training, since the source domain data has labels, the classifier tends to learn the features of the source domain rather than finding common features between the source and target domains. This bias can cause the model to overfit the source domain and perform poorly on the target domain. As training progresses, if the model cannot effectively adjust and learn the features of the target domain, the accumulation of errors will further intensify, resulting in a significant reduction in the effectiveness of transfer learning. Summary of the invention
[0006] The present invention aims to address the deficiencies of the above-mentioned prior art and proposes a domain-mixing unsupervised domain-adaptive image classification method based on data enhancement, in order to overcome the problem that the gap between the source domain and the target domain in the domain-adaptive image classification task is too large and thus makes it impossible to align them. By generating an intermediate domain, the distance between the two domains is shortened, thereby improving the accuracy of image classification.
[0007] In order to achieve the above-mentioned purpose, the present invention adopts the following technical scheme:
[0008] The invention discloses a domain-mixed unsupervised domain adaptive image classification method based on data enhancement, which is characterized by being performed in the following steps:
[0009] Step 1. Data preprocessing:
[0010] Obtain labeled source domain dataset in, represents the i-th source domain sample, n s represents the total number of source domain samples, let The label is C L Represents the type of label;
[0011] Obtain an unlabeled target domain dataset in, represents the jth target domain sample without a label, n t Represents the total number of samples in the target domain;
[0012] The Fourier transform method is used to and Perform data enhancement to obtain the corresponding i-th source domain augmented sample and the jth target domain augmented sample
[0013] Step 2. Build a domain hybrid adaptive model, including: feature extractor G, classifier C, domain discriminator D;
[0014] Step 2.1: and They are sent to the feature extractor G for processing, and the corresponding The original characteristics and Enhanced features
[0015] Will and Sent to the feature extractor G for processing, and the corresponding The original characteristics and The augmented features
[0016] Step 2.2: The classifier C is used to classify and Processing is performed to obtain the original source domain prediction probability and augmented source domain prediction probability
[0017] The classifier C is respectively and Processing is performed to obtain the original target domain prediction probability and augmented target domain prediction probability
[0018] Step 2.3: The discriminator D is respectively and Processing is performed to obtain the corresponding prediction probability of the source domain enhancement area and the target domain enhancement domain prediction probability
[0019] Step 3: Construct loss function to train the network:
[0020] Step 3.1: Use formula (7) to construct the source domain supervised classification loss L cls :
[0021]
[0022] In formula (7), L ori represents the original supervised classification loss, L aug represents the enhanced supervised classification loss, l ce represents the cross entropy function, λ st represents a hyperparameter;
[0023] Step 3.2: Use formula (8) to construct consistency loss
[0024]
[0025] Step 3.3: Use formula (3) to construct enhanced adversarial loss
[0026]
[0027] Step 3.4: Use formula (4) to construct the overall classification loss L:
[0028] L=λ cr ×L cr +λ d ×L d +L cls (4)
[0029] In formula (4), λ cr and λ d are two hyperparameters;
[0030] Step 3.5: Train the domain mixture adaptation model by stochastic gradient descent method, and calculate the overall classification loss L to update the model parameters until the overall classification loss L converges, so as to obtain the optimal domain mixture adaptation model for the image classification task in the target domain.
[0031] The electronic device of the present invention includes a memory and a processor, wherein the memory is used to store a program that supports the processor to execute the domain mixed unsupervised domain adaptive image classification method, and the processor is configured to execute the program stored in the memory.
[0032] The present invention provides a computer-readable storage medium, and the computer-readable storage medium stores a computer program, which is characterized in that when the computer program is executed by a processor, the steps of the domain mixing unsupervised domain adaptive image classification method are executed.
[0033] Compared with the prior art, the present invention has the following beneficial effects:
[0034] 1. The present invention proposes a domain mixing method for generating an intermediate domain, which shortens the distance between the two domains through the intermediate domain, enhances the generalization of the model, and improves the image classification accuracy of the model.
[0035] 2. The present invention applies a Fourier transform-based approach to data augmentation, separates the semantically relevant information and domain-related information of an image at the sample level, and forms new samples, thereby reducing the accumulation of training errors caused by the bias to the source domain in the early stages of the model and improving the image classification accuracy of the model.
[0036] 3. The present invention uses enhanced samples for confrontation to align the two domains, expands the sample information, improves the generalization ability of the model, and thus optimizes the entire image classification process. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 It is a schematic diagram of the process of the present invention;
[0038] Figure 2 It is a structural diagram of the model of the present invention. DETAILED DESCRIPTION
[0039] In this embodiment, a domain-mixing unsupervised domain-adaptive image classification method based on data enhancement is described. Figure 1 As shown, the steps are as follows:
[0040] Step 1. Data preprocessing:
[0041] Step 1.1. Obtain a labeled source domain dataset in, represents the i-th source domain sample, n s represents the total number of source domain samples, let The label is C L Represents the type of label;
[0042] Step 1.2. Obtain an unlabeled target domain dataset in, represents the jth target domain sample without a label, n t Represents the total number of samples in the target domain;
[0043] Step 1.3. Use Fourier transform to and Perform data enhancement to obtain the corresponding i-th source domain augmented sample and the jth target domain augmented sample
[0044] In this embodiment, three well-known public datasets are used to evaluate the method of the present invention, namely Office-31, Office-Home and VisDA-2017.
[0045] Office-31 is a benchmark dataset widely used in domain adaptation research. It covers three different source domains: Amazon (A), DSLR (D), and Webcam (W), with a total of 31 categories. Specifically, the Amazon domain has 2817 images, the DSLR domain contains 498 images, and the Webcam domain contains 795 images. The diversity of these images and the differences in source domains provide a good testing platform for domain adaptation research.
[0046] Office-Home is a large-scale domain adaptation benchmark dataset, which contains 65 categories in daily life, with a total of 15,500 images. This dataset is specially designed for four different domains: Artistic (Ar), Clipart (Cl), Product (Pr), and Real-World (Rw). The diversity and scale of Office-Home make it an important resource for evaluating the performance of domain adaptation algorithms.
[0047] VisDA-2017 is a dataset and challenge focused on domain adaptation and transfer learning research. It focuses on image classification tasks and is built by extracting a large amount of image data from ImageNet. VisDA-2017 consists of two parts: training data and validation data. The training data is based on a large-scale image collection of ImageNet and is used to train the model; while the validation data is used to evaluate the actual performance of the model. The tasks of VisDA-2017 cover 12 different categories.
[0048] Through evaluation on these three datasets, the proposed method can be comprehensively tested and verified to ensure its robustness and effectiveness in different fields and complex scenarios.
[0049] Step 1.3.1: Use formula (1) to get The Fourier transform representation of
[0050]
[0051] In formula (1), express The Fourier transform value at the position (u,v) in , express The pixel at the position (h,w) in The length and width of , j represents an imaginary number;
[0052] Step 1.3.2: Use equations (2) and (3) to obtain the amplitude at the (u, v) position: and Phase
[0053] In formula (2) and formula (3), and Respectively The real and imaginary parts of
[0054] Step 1.3.3: Use equation (4) to The amplitude spectrum of and The amplitude spectrum of Linear interpolation is performed between the two to obtain the mixed amplitude
[0055]
[0056] In formula (4), α is a hyperparameter used to control the exchange ratio between two samples, which is set to 0.9 in this example.
[0057] Step 1.3.4: Use formula (5) to get The Fourier transform representation of
[0058]
[0059] In formula (5), express The mixed amplitude spectrum at the (u,v) position in ; express The Fourier transform value at the position (u,v) in ;
[0060] Step 1.3.5: Generate using formula (6) The augmented image
[0061]
[0062] In formula (6), F -1 represents the inverse Fourier transform.
[0063] Step 1.3.6: Repeat the process of steps 1.3.1-1.3.5 to process the target domain samples and obtain Enhanced sample
[0064] Step 2. Build a domain hybrid adaptive model, including: feature extractor G, classifier C, domain discriminator D;
[0065] In this embodiment, the feature generator G is based on the ResNet-50 architecture and consists of a five-layer network structure. The first layer consists of a convolutional layer (7×7 convolution kernel, 64 filters, step size 2), a batch normalization layer (3×3, step size 2), a ReLU activation function, and a maximum pooling layer (3×3, step size 2). The subsequent layers are composed of multiple bottleneck blocks, the number of which is 3, 4, 6, and 3 respectively. Each bottleneck block contains three convolutional layers, and the specific parameters are as follows:
[0066] First layer bottleneck blocks: (1×1,64), (3×3,64), (1×1,256)
[0067] Second-layer bottleneck blocks: (1×1,128), (3×3,128), (1×1,512)
[0068] The third layer bottleneck block: (1×1,256), (3×3,256), (1×1,1024)
[0069] Fourth-layer bottleneck blocks: (1×1,512), (3×3,512), (1×1,2048)
[0070] Each convolutional layer is followed by a batch normalization layer (3×3, stride 2) and a ReLU activation function. Finally, after global average pooling and a fully connected layer, the output feature dimension is 256.
[0071] The input dimension of classifier C is 256 and the output dimension is C L , the discriminator D has a minimum input dimension of 256 and an output dimension of 2.
[0072] Step 2.1: Figure 2 As shown, and They are sent to the feature extractor G for processing, and the corresponding The original characteristics and Enhanced features In this embodiment, the dimensions are all 256;
[0073] Will and Sent to the feature extractor G for processing, and the corresponding The original characteristics and The augmented features The dimensions are all 256;
[0074] Step 2.2: Classifier C is used to classify and Processing is performed to obtain the original source domain prediction probability and augmented source domain prediction probability Dimensions are all C L ;
[0075] Classifier C is used to classify and Processing is performed to obtain the original target domain prediction probability and augmented target domain prediction probability Dimensions are all C L ;
[0076] Step 2.3: The discriminator D is used to distinguish and Processing is performed to obtain the corresponding prediction probability of the source domain enhancement area and the target domain enhancement domain prediction probability The dimensions are all 2.
[0077] Step 3: Construct loss function to train the network:
[0078] Step 3.1: Use formula (7) to construct the source domain supervised classification loss L cls :
[0079]
[0080] In formula (7), L ori represents the original supervised classification loss, L aug represents the enhanced supervised classification loss, l ce represents the cross entropy function, λ st represents a hyperparameter; for and Although the latter has some changes in background information, its label information remains consistent with the original source domain sample. Therefore, these two samples are fed into the model for training. This loss function is designed to ensure that the model's prediction results for the original sample and the enhanced sample remain consistent, thereby improving the model's robustness and migration capabilities. Through this data augmentation strategy, the model can not only make full use of the complementary information between the source domain and the target domain, but also effectively enhance the generalization performance of the model, so that it can maintain stable prediction accuracy when facing different domain changes.
[0081] Step 3.2: Use formula (8) to construct consistency loss
[0082]
[0083] for and In reality, there are no labels. Previous methods often use pseudo labels. However, in the early training of pseudo label models, due to low accuracy, errors will be accumulated. This paper designs a consistency regularizer to better promote the model to extract identifiable features in domain mixing training. Ideally, the model should ensure that the target domain samples and The classification results remain completely consistent. The introduction of the regularization loss Lcr aims to promote linear behavior between training samples and thus achieve smoothing of sample outputs. In addition, by enforcing the prediction consistency between the original samples and the enhanced samples, Lcr fully utilizes the category-aware information contained in the target domain samples during the training process. This strategy not only enhances the model's ability to understand the target domain data, but also significantly improves the model's performance, enabling it to demonstrate stronger generalization capabilities when facing different target domain data.
[0084] Step 3.3: Use formula (3) to construct enhanced adversarial loss
[0085]
[0086] The traditional adversarial loss method of directly aligning source and target domain samples has limitations. Due to the large possible differences in domains and the limitation of the batch size of training samples, this method is often insufficient to achieve global distribution alignment. To overcome these challenges, the present invention proposes an innovative method that uses domain mixing to form an intermediate domain, thereby enriching the structural information of the samples. By using enhanced samples for adversarial learning, this method can better capture the complex relationships between different domains, improve the cross-domain generalization ability of the model, and achieve more accurate classification results.
[0087] Step 3.4: Use formula (4) to construct the overall classification loss L:
[0088] L=λ cr ×L cr +λ d ×L d +L cls (4)
[0089] In formula (4), λ cr and λ d These are two hyperparameters. In this embodiment, both are set to 0.1.
[0090] Step 3.5: Train the domain mixture adaptation model by stochastic gradient descent method, and calculate the overall classification loss L to update the model parameters until the overall classification loss L converges, so as to obtain the optimal domain mixture adaptation model for the image classification task in the target domain.
[0091] In this embodiment, an electronic device includes a memory and a processor, wherein the memory is used to store a program that supports the processor to execute the above method, and the processor is configured to execute the program stored in the memory.
[0092] In this embodiment, a computer-readable storage medium stores a computer program on the computer-readable storage medium, and the computer program executes the steps of the above method when executed by a processor.
Claims
1. A domain-mixing unsupervised domain-adaptive image classification method based on data augmentation, It is characterized in that The steps are as follows: Step 1. Data preprocessing: Obtain labeled source domain dataset in, represents the i-th source domain sample, n s represents the total number of source domain samples, let The label is C L Represents the type of label; Obtain an unlabeled target domain dataset in, represents the jth target domain sample without a label, n t Represents the total number of samples in the target domain; The Fourier transform method is used to and Perform data enhancement to obtain the corresponding i-th source domain augmented sample and the jth target domain augmented sample Step 2. Build a domain hybrid adaptive model, including: feature extractor G, classifier C, domain discriminator D; Step 2.1: and They are sent to the feature extractor G for processing, and the corresponding The original characteristics and Enhanced features Will and Sent to the feature extractor G for processing, and the corresponding The original characteristics and The augmented features Step 2.2: The classifier C is used to classify and Processing is performed to obtain the original source domain prediction probability and augmented source domain prediction probability The classifier C is respectively and Processing is performed to obtain the original target domain prediction probability and augmented target domain prediction probability Step 2.3: The discriminator D is respectively and Processing is performed to obtain the corresponding prediction probability of the source domain enhancement area and the target domain enhancement domain prediction probability Step 3: Construct loss function to train the network: Step 3.1: Use formula (7) to construct the source domain supervised classification loss L cls : In formula (7), L ori represents the original supervised classification loss, L aug represents the enhanced supervised classification loss, l ce represents the cross entropy function, λ st represents a hyperparameter; Step 3.2: Use formula (8) to construct consistency loss Step 3.3: Use formula (3) to construct enhanced adversarial loss Step 3.4: Use formula (4) to construct the overall classification loss L: L=λ cr ×L cr +λ d ×L d +L cls (4) In formula (4), λ cr and λ d are two hyperparameters; Step 3.5: Train the domain mixture adaptation model by stochastic gradient descent method, and calculate the overall classification loss L to update the model parameters until the overall classification loss L converges, so as to obtain the optimal domain mixture adaptation model for the image classification task in the target domain.
2. An electronic device comprising a memory and a processor, It is characterized in that The memory is used to store a program that supports the processor to execute the domain mixing unsupervised domain adaptive image classification method according to claim 1, and the processor is configured to execute the program stored in the memory.
3. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the domain mixing unsupervised domain adaptive image classification method according to claim 1 are performed.
Citation Information
Patent Citations
Cross-domain image classification method based on unsupervised domain self-adaption
CN113298189A
Unsupervised domain adaptive image classification method based on bidirectional generation and middle domain alignment
CN113469273A
Cross-domain target identification method based on intermediate domain guidance and metric learning constraint
CN117456309A
Self-training contrast learning-based unsupervised field adaptive image classification method
CN117636051A
Domain adaptive optical remote sensing image classification method based on prototype comparative learning
CN117671515A
