Image classification method and system based on potential domain and category diversity
By generating structurally consistent potential domains and maximizing category diversity, the problems of cross-domain feature extraction and category difference capture in unsupervised domain adaptation are solved, and the accuracy and generalization ability of image classification are improved, and the label-free is achieved Efficient image classification on the target domain.
Patent Information
- Application Number
- CN202411783364.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-06
- Publication Date
- 2025-01-03
AI Technical Summary
Existing unsupervised domain adaptation (UDA) methods have shortcomings in cross-domain feature extraction and class-level difference capture, especially in image classification tasks, which are difficult for traditional methods to maintain high generalization in target domains without labeled data and Accuracy, and ignore the coherence of category diversity and feature structure.
By generating a latent domain with a consistent structure, gradually aligning the distribution of the source domain and the target domain, maximizing category diversity, adopting a multi-level alignment strategy at the class level and domain level, combining entropy loss and pseudo-label generation, improving the cross-domain classification of the model performance.
It significantly improves the accuracy and generalization ability of the model in cross-domain classification tasks, enhances the category distinction ability and adaptability, reduces the cost of data annotation, and improves training efficiency and stability.
Smart Images

Figure CN119251605A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image classification, and in particular to an image classification method and system based on potential domain and category diversity. Background Art
[0002] With the successful application of deep neural networks in computer vision tasks such as image classification, video analysis, and image semantic segmentation, how to achieve efficient model migration in target domains without labeled data has become an urgent problem to be solved. Traditional supervised learning methods rely on large-scale labeled data for training. When the model is applied to a target domain that is inconsistent with the distribution of the training set, the performance often drops significantly. To this end, unsupervised domain adaptation (UDA) came into being, with the goal of maintaining high generalization in the unlabeled target domain through models trained with labeled data in the source domain. However, due to the significant difference in distribution between the source domain and the target domain, how to extract effective cross-domain invariant features is one of the main challenges in the field of UDA.
[0003] At present, mainstream UDA methods mainly include domain confusion methods based on adversarial networks and domain alignment methods based on metrics. However, these methods either fail to improve the distinguishability of features or fail to effectively capture cross-domain differences at the category level. In addition, existing studies have also explored generating intermediate images through generative adversarial networks (GANs) as a bridge between the source domain and the target domain, but such methods often ignore the structural information of inter-domain features, thus affecting the alignment effect. Although existing methods have introduced intermediate domains to alleviate the distribution differences between the source domain and the target domain, they often ignore the category diversity and the coherence of the feature structure, thus affecting the cross-domain recognition effect.
[0004] In image classification tasks, maximizing category diversity is an important strategy to achieve model generalization. By promoting the model to generate predictions with rich category distribution, the model's ability to distinguish samples of different categories can be significantly improved. To this end, it is urgent to propose an image classification method based on latent domain and category diversity. By constructing a latent domain to gradually align the distribution of the source domain and the target domain, while maximizing category diversity, the cross-domain classification performance of the model can be further improved, and the image classification accuracy can be improved. Summary of the invention
[0005] In order to solve the above-mentioned problems, the present invention provides an image classification method and system based on latent domain and category diversity. By generating a latent domain with consistent structure, the distribution difference between the source domain and the target domain is reduced, the category diversity is maximized, and accurate cross-domain alignment is achieved.
[0006] In a first aspect, the present invention provides an image classification method based on potential domain and category diversity, which adopts the following technical solution: An image classification method based on latent domain and category diversity, comprising: Acquiring image data, including acquiring image data of a source domain and a target domain; Preprocess the image data of the source domain and the target domain; Build a domain-adaptive image classification model; Conduct model training on the constructed domain adaptive image classification model; Use the trained domain adaptive image classification model to perform image classification.
[0007] Furthermore, the acquisition of image data of the source domain and the target domain includes acquiring a labeled image dataset as source domain data for training the model; acquiring an unlabeled image dataset as target domain data for testing the generalization ability of the model, wherein the source domain data is stored in a directory structure, each subdirectory represents a category, each category has multiple images, and the target domain data only contains the input image.
[0008] Furthermore, the image data of the source domain and the target domain are preprocessed, including adjusting the size of the image data, performing data enhancement on the image, and performing image, cropping and image scaling on the enhanced image, and finally normalizing the pixel value distribution in the image to conform to the standard normal distribution.
[0009] Furthermore, the construction of the domain adaptive image classification model includes constructing a latent domain to connect the source domain and the target domain, using the maximum mean difference (MMD) to calculate the global distribution difference between the latent domain and the target domain, thereby obtaining the domain-level alignment loss, and encouraging category balance by maximizing the entropy of the predicted distribution, and finally generating class-consistent pseudo-labels in small batches to enhance category consistency.
[0010] Furthermore, the constructing of the domain adaptive image classification model also includes using supervised learning and entropy loss to optimize the model parameters of the source domain and the target domain, wherein for the data in the source domain, a supervised learning method is used to train the classifier, and for the data in the target domain, entropy loss is used to maximize the uncertainty of the model prediction, i.e., entropy.
[0011] Furthermore, the training of the constructed model includes using the image data of the source domain to perform initial training on the model, and enabling the model to obtain the classification ability of the source domain features by minimizing the source domain classification loss; and then introducing potential domain generation, class level alignment, domain level alignment and category diversity maximization strategies to jointly optimize the model.
[0012] Furthermore, the method of using the trained model to perform image classification includes using the trained model to infer image samples in the target domain, wherein the features of the target domain sample images are first mapped to the classification head of the model, and the category probability distribution is output through the multi-layer network structure of the classification head, and the category label of the sample is determined according to the maximum probability value. Since the target domain has no category label, pseudo labels are used when classifying images in the target domain, wherein the pseudo labels generate a predicted probability distribution based on the target domain data.
[0013] In a second aspect, an image classification system based on potential domain and category diversity includes: A data acquisition module is configured to acquire image data, including acquiring image data of a source domain and a target domain; A preprocessing module is configured to preprocess the image data of the source domain and the target domain; The model building module is configured to build a domain adaptive image classification model; The model training module is configured to perform model training on the constructed domain adaptive image classification model; The image classification module is configured to perform image classification using a trained domain adaptive image classification model.
[0014] In a third aspect, the present invention provides a computer-readable storage medium storing a plurality of instructions, wherein the instructions are suitable for being loaded by a processor of a terminal device and executing the image classification method based on potential domain and category diversity.
[0015] In a fourth aspect, the present invention provides a terminal device including a processor and a computer-readable storage medium, the processor being used to implement various instructions; the computer-readable storage medium being used to store multiple instructions, the instructions being suitable for being loaded by the processor and executing the image classification method based on potential domain and category diversity.
[0016] In summary, the present invention has the following beneficial technical effects: The present invention gradually aligns the distribution differences between the source domain and the target domain by generating a potential domain, and adopts a multi-level alignment strategy at the class level and the domain level to achieve consistency in feature distribution among the source domain, the potential domain and the target domain, thereby significantly improving the accuracy of the model in cross-domain classification tasks. At the same time, the present invention introduces an entropy-based category diversity loss term to prevent the problem of uneven distribution of target domain categories, and enhances the category distinction and generalization capabilities of the model. In addition, the category-driven mini-batch domain translation module (CDBDT) generates class-consistent pseudo labels at the mini-batch level to ensure the category consistency of potential domain instances, thereby improving the model's recognition ability of category structure and cross-domain adaptability. By adopting unsupervised domain adaptation technology, the target domain does not need to be manually labeled, which greatly reduces the cost of data labeling, making the method applicable to a variety of unlabeled scenarios. By integrating the joint training strategy of source domain classification loss, class-level and domain-level alignment loss, and category diversity loss, the present invention significantly improves the training efficiency and stability of the model. In summary, the present invention performs well in image classification tasks with unsupervised domain adaptation, and has strong generalization ability, accuracy and application value. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 is a schematic diagram of an image classification method based on potential domain and category diversity according to Embodiment 1 of the present invention; Figure 2 4 is a flow chart of an image classification method based on potential domain and category diversity according to Embodiment 1 of the present invention. DETAILED DESCRIPTION
[0018] The present invention is further described in detail below in conjunction with the accompanying drawings.
[0019] Explanation of the name: Latent domain generation: The present invention first gradually aligns the data distribution of the source domain and the target domain by constructing a latent domain, and generates latent domain instances using the topological structure information between the source domain and the target domain. The latent domain generation module generates class-consistent latent domain instances by mapping the target domain samples into the source domain space. These instances have the structural features of the source domain, thus acting as a bridge between the source domain and the target domain. This generation strategy ensures the category consistency of the generated samples while maintaining the integrity of the cross-domain structural information.
[0020] Class-level and domain-level alignment: In order to effectively reduce cross-domain differences, the present invention designs a two-level alignment strategy: class-level alignment and domain-level alignment. Specifically, class-level alignment is used between the source domain and the latent domain. The intra-class mean difference is calculated for each category, and the intra-class consistency is enhanced by minimizing the intra-class distribution difference, so that the latent domain is closer to the feature distribution of the source domain. For the latent domain and the target domain, due to the lack of label information, domain-level alignment is adopted to ensure the consistency of the overall distribution by minimizing the global distribution difference between the two domains, thereby reducing the domain deviation of the target domain and enabling the model to maintain better performance on the target domain.
[0021] Category-Driven Batch Domain Translation (CDBDT): In the process of latent domain generation, category consistency and sample selection are crucial to the generation effect. This paper designs a Category-Driven Batch Domain Translation (CDBDT) module, which uses pseudo labels to select target domain samples with consistent categories in each mini-batch, thereby ensuring high-quality category consistency of latent domain instances. The CDBDT module assigns category information to target samples through pseudo labels, so that source domain samples and target domain samples match in the category dimension, thereby ensuring that the generated latent domain samples can effectively represent the category information of the target domain.
[0022] Maximizing category diversity: To avoid the model from making unbalanced category predictions in the target domain and to enhance the model's ability to distinguish between different categories, this paper introduces an entropy-based category diversity loss term. Category diversity loss encourages the model to generate a balanced category prediction distribution, prompting the model to increase the prediction possibilities of different categories during the optimization process, thereby improving the category distinction ability and the cross-domain generalization performance of the model. The design of this diversity loss ensures that the model outputs a more balanced category distribution, which helps to solve the category bias problem in cross-domain classification.
[0023] Joint training strategy: To achieve effective cross-domain alignment and maximize category diversity, this paper proposes a joint training strategy that combines the source domain classification loss, three-domain alignment loss, and category diversity loss to optimize the overall classification performance of the model in the target domain. The final loss function balances the above loss terms so that the model can maintain the cross-domain consistency of features and maximize the diversity of category distribution during training, ultimately improving the classification accuracy and generalization ability of the model in the target domain.
[0024] Example 1 Reference Figure 1 , an image classification method based on potential domain and category diversity of this embodiment includes: Acquiring image data, including acquiring image data of a source domain and a target domain; Preprocess the image data of the source domain and the target domain; Build a domain-adaptive image classification model; Conduct model training on the constructed domain adaptive image classification model; Use the trained domain adaptive image classification model to perform image classification.
[0025] The specific steps include: Step 1: Obtain image data of the source domain and the target domain; Among them, the source domain dataset D S and the target dataset D T The source domain data is Labeled data, namely: The target domain is There are no labeled data images, namely: .
[0026] The image data of the source domain and the target domain come from public datasets, such as Office-Home, Office-31, Image-CLEF, etc. The source domain data usually contains labeled image data for training models. The source domain dataset contains input images and corresponding category labels. The source domain data is usually stored in a directory structure, where each subdirectory represents a category and each category has multiple images. We can load images from the source domain directory and assign a label to each image (matching the label by the directory name).
[0027] The target domain is usually an unlabeled dataset used to test the generalization ability of the model or for transfer learning. The dataset of the target domain only contains input images without labels.
[0028] First, os.walk through the specified directory to find all files with image file extensions. Use PIL.Image or other libraries to load each image file.
[0029] Then, for the source domain data, the directory name is used as the category label, and for the target domain data, since there is no label, the image path is directly returned.
[0030] Step 2: Data preprocessing and initial model training; Preprocess the image data of the source and target domains to unify the data format, resolution, and other features to ensure that the data is suitable for the subsequent model training process. Label the source domain data, while the target domain data remains unlabeled. Use the labeled data in the source domain to perform initial training on the classification model, and use the source domain classification loss to learn the source domain features to obtain the initial parameters of the model.
[0031] The following are the specific preprocessing steps and corresponding formulas: First, resize the image to a fixed size: in, x is the input image, is the resized image.
[0032] Secondly, the image is randomly flipped horizontally as part of data augmentation. x : This step is done by probability p Controls whether to flip the image.
[0033] Then, we center crop the image to the central region of the image to 224×224 pixels: This means cropping off the four edge portions of the image, leaving a central 224×224 pixel area.
[0034] Again, convert the image from Numpy array to PyTorch tensor. , whose value range is [0,225]: After conversion, the range of image values is scaled to [0,1], that is: Finally, the image is normalized so that the mean of each channel is 0 and the standard deviation is 1. , there are three channels, red, green and blue, with mean and standard deviation respectively , , and , , : in and is the mean and standard deviation of each channel, usually using the mean and standard deviation of the ImageNet dataset: , , , =0.229, =0.224, = 0.225. This will ensure that the pixel values for each channel follow a standard normal distribution (mean 0, standard deviation 1).
[0035] These steps can effectively improve the quality and diversity of the data and help the model learn features better.
[0036] Then, feature extraction is achieved through the pre-trained convolutional neural network (CNN) model. After preprocessing, we can get an image , the image is a 224×224×3 tensor. Forward propagation through a convolutional neural network (we use ResNet) outputs the following features: in, Ne t represents the convolutional neural network, f It is the output feature of the network, usually a high-dimensional feature vector (2048 dimensions).
[0037] Step 3: Model construction; The overall structure of the model based on latent domain and category diversity is as follows Figure 1As shown in the figure. The model consists of three parts: (a) latent domain generation and class-level alignment and domain-level alignment, (b) category diversity maximization design, and (c) category-driven small batch domain translation module: The core of the latent domain generation module is the latent domain generation network, which maps the features of the source domain and the target domain to a shared latent space Z. First, the distribution of the source domain and the target domain in the latent space is aligned by the maximum mean difference (MMD) loss function to reduce the distribution difference between the two. Then, the class-level alignment module ensures that the features of the same category in the source domain and the target domain are as close as possible to reduce the deviation between categories. Domain-level alignment further optimizes the overall feature distribution, making the overall feature distribution of the source domain and the target domain in the latent space more consistent, ensuring that the model can effectively perform cross-domain migration. The category diversity maximization design module introduces the prediction diversity maximization loss and improves the category diversity of the target domain data based on the entropy measurement method, avoiding the model's biased prediction of minority categories in the target domain. This module guides the network to produce more balanced predictions, thereby enhancing the model's ability to recognize different categories and further reducing the impact of category bias. The category-driven mini-batch domain translation module uses a mini-batch training strategy to adjust the training process based on category information in each batch. This module uses category labels to dynamically select mini-batch samples to ensure that during the training process, the model can effectively convert between features of different categories, thereby improving the transfer learning effect between the source domain and the target domain. This translation module combines self-supervised learning and unsupervised learning methods, and can effectively promote the transfer of source domain knowledge to the target domain in the absence of target domain labels. Through the collaborative work of these three key modules, the proposed model can achieve efficient alignment and diversity enhancement between multiple domains and categories, and significantly improve classification performance in the target domain, especially when the target domain lacks labels.
[0038] In addition, in order to evaluate the performance of our model, we conducted experiments on three datasets: Image-CLEF, Office-Home, and Office-31, and used classification accuracy as the main evaluation method. Specifically, we trained and tested the model on each dataset, and used classification accuracy as the main performance evaluation indicator. Classification accuracy can intuitively reflect the performance of the model in the target domain, especially when processing unlabeled target domain data, it can measure the model's ability to recognize new categories and maintain the structure of the potential domain. Through experiments on these datasets, we verified the superiority of the image classification method proposed in this invention in a diverse data environment, and proved that it can effectively improve the adaptability and robustness of the model in practical applications.
[0039] Among them, TP is the number of samples correctly predicted as positive by the model, TN is the number of samples correctly predicted as negative by the model, FP is the number of samples incorrectly predicted as positive by the model, and FN is the number of samples incorrectly predicted as negative by the model.
[0040] Specifically, the model construction includes the following steps: (1) First, we use the Category Driven Mini-Batch Domain Translation module (CDBDT) to enhance the category consistency of the target domain data. In this stage, we generate pseudo labels through mini-batches and filter out samples with consistent categories to provide more consistent and stable target data for the subsequent latent domain generation module. The specific process is as follows: For each target domain sample x∈ B T , the model predicts the probability p(y|x) that the target belongs to each category, and determines the pseudo label y by selecting the maximum probability value pseudo : in, C Indicates the total number of categories. According to the pseudo label y pseudo , from small batches B T Select all predictions for the same category c The samples constitute the class consistent sample set : The function of this module is to ensure that the target domain samples have been screened as samples with consistent categories before entering the potential domain generation module, so as to ensure the category consistency of the samples after the potential domain is generated.
[0041] (2) After CDBDT, use the selected class-consistent sample set To generate the potential domain Z , to connect to the source domain S and target domain T Instances in the potential domain are mapped via the mapping function T -> Z Generate, that is: in, is the latent domain feature vector, is the probability distribution of belonging to each category, is the target feature vector. This ensures that the latent domain is topologically consistent with the source and target domains. Next, class-level alignment is performed by minimizing the mean difference between the source and latent domains for each class. d(uSc , uZc) to achieve, where oeLh and u Represent the categories in the source domain and the potential domain respectively cThe characteristic mean of is defined as follows: Among them d(·,·) is the distance function used to measure the difference in class means, , ( is the feature representation of the source domain / latent domain sample x, represents the set of samples belonging to category c in the source domain / latent domain). In order to align the features of the latent domain and the target domain, we can use the maximum mean difference (MMD) to measure the global feature distribution difference between the source domain, latent domain, and target domain. The global distribution difference between the latent domain and the target domain can be expressed as: The total loss of the latent domain is: (3) Next, in order to further enhance the class balance of the target domain, the present invention designs a class diversity maximization module to encourage class balance by maximizing the entropy of the predicted distribution. The class probability distribution of the target domain samples is defined as , then the category diversity loss The calculation is as follows: in N T is the number of samples in the target domain, Representation sample i Belongs to category c By minimizing this loss term, the model's prediction results are more evenly distributed across all categories in the target domain, forcing the model to learn more category features.
[0042] (4) Finally, we use supervised learning and entropy loss to optimize the model parameters of the source and target domains. For the source domain data, supervised learning methods are usually used to train the classifier. For any given source domain batch , the supervision loss is defined as: in. It is a batch S The size of y For labels, is the output probability of the classifier, that is, given the input , the model outputs the probability distribution of belonging to each category.
[0043] Since the target domain D T The samples in the dataset lack labels, so we cannot directly use the supervised loss To calculate the loss of the target domain. Therefore, entropy loss is used to maximize the uncertainty (i.e., entropy) of the model prediction, thereby optimizing the classification performance of the target domain. The entropy loss of the target domain is defined as: in, is a mini-batch of samples in the target domain. The form of the entropy loss function aims to minimize the entropy of the predicted probability distribution of each sample, thereby promoting more stable and deterministic predictions of the classifier on the target domain data.
[0044] Finally, the loss functions of all modules are combined to form the final total loss L : Through the joint optimization of the above modules, the final model can align cross-domain features and maintain the diversity of category distribution under unsupervised conditions, achieving effective classification and generalization of target domain data.
[0045] Method invention: The experimental development environment used is pytorch3.0.1. On an NVIDIA RTX 4090 graphics processor, the Adam optimizer is used, the learning rate is 0.0001, and the number of model training rounds is 50. The batch size is set to 30. The experimental environment and specific settings are shown in Table 2.
[0046] Step 4: Model training; During the model training phase, the present invention adopts a joint optimization training strategy to achieve effective alignment of cross-domain features and enhanced category diversity in the target domain through the joint effects of source domain classification loss, class-level alignment loss, domain-level alignment loss, and category diversity loss. The training process is divided into two stages: first, the model is initially trained using source domain data to obtain the ability to classify source domain features. In this stage, by minimizing the source domain classification loss, the model has good basic classification performance in the source domain. Then, the model enters the joint optimization phase, introducing potential domain generation, class-level alignment, domain-level alignment, and category diversity maximization strategies. Class-level alignment loss Used to minimize the intra-class differences between the source domain and the latent domain, thereby improving intra-class consistency; domain-level alignment loss Used to reduce the overall distribution difference between the potential domain and the target domain to ensure the consistency of cross-domain features; category diversity loss By increasing the balance of category predictions in the target domain, the model's ability to distinguish different categories is improved. The total loss of the final model is composed of the weighted sum of the above losses, so that the model gradually aligns the feature distribution between the source domain, potential domain, and target domain, and maximizes the diversity of category distribution, ensuring the generalization performance of the model in the target domain.
[0047] like Figure 2 As shown: Step 4.1 Set up and initialize the necessary components for training, such as the model, data loader, optimizer, and loss function.
[0048] 4.2 The loop performs multiple training iterations, each of which loads data from the source and target domains and calculates the corresponding losses.
[0049] 4.3 Add up all the losses weightedly to get the total loss.
[0050] 4.4 Calculate the gradient through back propagation and optimize the model parameters to minimize the total loss. Gradient descent updates the parameters: in, θ are model parameters, η is the learning rate, ▽ θ L is the gradient of the loss function with respect to the parameters.
[0051] 4.5 Regularly record the loss and accuracy during training and save model checkpoints for subsequent resumption of training.
[0052] 4.6 Regularly evaluate the accuracy of the model on the test set.
[0053] Step 5: Image classification; In the image classification stage, the present invention uses the trained model to infer the image samples of the target domain. During the inference process, the image data to be classified (the sample matrix of the target domain) is input into the trained model. Unlike the training stage, the potential domain generation module will no longer be used in the inference stage, because the effective representation of the target domain sample features has been ensured in the model through cross-domain feature alignment. Accordingly, the model directly uses the learned category feature distribution to infer and classify the target domain samples.
[0054] The specific operation is as follows: the features of the target domain samples are first mapped to the classification head of the model, and the multi-layer network structure of the classification head outputs the category probability distribution, and the category label of the sample is determined according to the maximum probability value. This process achieves efficient cross-domain image classification without the need to generate additional potential domains or intermediate domains.
[0055] Because the target domain has no category labels, pseudo labels are used when classifying images in the target domain. The pseudo label generation of this model is mainly based on the predicted probability distribution of the target domain data. The specific steps are as follows: First, the model passes through the target domain data The forward propagation of the classifier calculates the predicted probability of the classification p t:: in, It is the logits obtained after the target domain data passes through the model’s feature extraction and classifier. Represents the model. The softmax function converts logits into probability distribution: in C is the number of categories.
[0056] For each target domain sample, select the category with the highest predicted probability as the pseudo label: The output pseudo-label is then input to the domain discriminator to complete the training of the classification model described in the method of the present invention, and the target domain that has not participated in the training is D T The data is input into the classification model as a test set, and finally the classification result is obtained.
[0057] Table 1 Experimental results of the method of the present invention on three data sets Average accuracy Image-CLEF Office-Home Office-31 Existing DMAL methods 88.8 66.1 86.6 Method of the present invention 0.903 0.720 0.893 Table 2 Experimental environment and parameter settings of the method of the present invention Table 1 shows the experimental results of the proposed method and the existing DMAL (Domain Adaptation via Mixup Learning) method on three different datasets. We compared the average accuracy of the proposed method and the existing methods by training and testing the models on three datasets (Image-CLEF, Office-Home, and Office-31). By comparing the accuracy of the proposed method and the existing methods, it can be seen that the proposed method has achieved better performance on all three datasets, especially on the Office-Home dataset, where the accuracy has increased by 5.9 percentage points (72.0% vs. 66.1%), showing the advantages of the proposed method in cross-domain adaptation.
[0058] Table 2 lists the hardware environment, software environment and model parameter settings of this experiment. These settings and configurations ensure the smooth progress of the experiment and provide a reference for other researchers to repeat the experiment. After multiple experiments and tuning, the above experimental environment and parameter settings were finally determined. These configurations ensure that the model can be efficiently trained and stably converged on different data sets, and can achieve good performance.
[0059] Example 2 This embodiment provides an image classification system based on potential domains and category diversity, including: A data acquisition module is configured to acquire image data, including acquiring image data of a source domain and a target domain; A preprocessing module is configured to preprocess the image data of the source domain and the target domain; The model building module is configured to build a domain adaptive image classification model; The model training module is configured to perform model training on the constructed domain adaptive image classification model; The image classification module is configured to perform image classification using a trained domain adaptive image classification model.
[0060] A computer-readable storage medium stores a plurality of instructions, wherein the instructions are suitable for being loaded by a processor of a terminal device and executing the image classification method based on potential domain and category diversity.
[0061] A terminal device includes a processor and a computer-readable storage medium, wherein the processor is used to implement various instructions; the computer-readable storage medium is used to store multiple instructions, wherein the instructions are suitable for being loaded by the processor and executing the image classification method based on potential domain and category diversity.
[0062] The above are all preferred embodiments of the present invention, and are not intended to limit the protection scope of the present invention. Therefore, any equivalent changes made based on the structure, shape, and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. An image classification method based on latent domain and category diversity, characterized in that: include: Acquiring image data, including acquiring image data of a source domain and a target domain; Preprocess the image data of the source domain and the target domain; Build a domain-adaptive image classification model; Conduct model training on the constructed domain adaptive image classification model; Use the trained domain adaptive image classification model to perform image classification.
2. The image classification method based on potential domain and category diversity according to claim 1, characterized in that: The method of obtaining image data of the source domain and the target domain includes obtaining a labeled image dataset as source domain data for training the model; and obtaining an unlabeled image dataset as target domain data for testing the generalization ability of the model, wherein the source domain data is stored in a directory structure, each subdirectory represents a category, each category has multiple images, and the target domain data only contains input images.
3. The image classification method based on potential domain and category diversity according to claim 2, characterized in that: The image data of the source domain and the target domain are preprocessed, including adjusting the size of the image data, performing data enhancement on the image, and performing image, cropping and image scaling on the enhanced image. Finally, the pixel value distribution in the image is normalized to conform to the standard normal distribution.
4. The image classification method based on potential domain and category diversity according to claim 3, characterized in that: The domain adaptive image classification model is constructed, including constructing a latent domain to connect the source domain and the target domain, using the maximum mean difference (MMD) to calculate the global distribution difference between the latent domain and the target domain, thereby obtaining the domain-level alignment loss, and encouraging category balance by maximizing the entropy of the predicted distribution, and finally generating class-consistent pseudo labels in a small batch manner to enhance category consistency.
5. The image classification method based on potential domain and category diversity according to claim 4, characterized in that: The constructing of the domain adaptive image classification model also includes using supervised learning and entropy loss to optimize model parameters of the source domain and the target domain, wherein for the data in the source domain, a supervised learning method is used to train the classifier, and for the data in the target domain, an entropy loss is used to maximize the uncertainty of the model prediction, that is, the entropy.
6. The image classification method based on potential domain and category diversity according to claim 5, characterized in that: The training of the constructed model includes using the image data of the source domain to initially train the model, and enabling the model to acquire the classification capability of the source domain features by minimizing the classification loss of the source domain; Then, latent domain generation, class-level alignment, domain-level alignment and category diversity maximization strategies are introduced to jointly optimize the model.
7. The image classification method based on potential domain and category diversity according to claim 6, characterized in that: The method of using a trained model to classify images includes using the trained model to infer image samples in the target domain, wherein the features of the sample images in the target domain are first mapped to the classification head of the model, and the category probability distribution is output through the multi-layer network structure of the classification head, and the category label of the sample is determined according to the maximum probability value. Since the target domain has no category label, pseudo labels are used when classifying images in the target domain, wherein the pseudo labels generate a predicted probability distribution based on the target domain data.
8. An image classification system based on latent domain and category diversity, characterized in that: include: A data acquisition module is configured to acquire image data, including acquiring image data of a source domain and a target domain; A preprocessing module is configured to preprocess the image data of the source domain and the target domain; The model building module is configured to build a domain adaptive image classification model; The model training module is configured to perform model training on the constructed domain adaptive image classification model; The image classification module is configured to perform image classification using a trained domain adaptive image classification model.
9. A computer-readable storage medium storing a plurality of instructions, characterized in that: The instructions are suitable for being loaded by a processor of a terminal device and executing the method according to claim 1 .
10. A terminal device, comprising a processor and a computer-readable storage medium, wherein the processor is used to implement each instruction; and the computer-readable storage medium is used to store multiple instructions, characterized in that: The instructions are suitable for being loaded by a processor and executing the method as claimed in claim 1 .
Citation Information
Patent Citations
Noise scene image classification method and system based on domain adaptation
CN113378981A
Rolling bearing fault diagnosis method based on self-supervised learning and clustering
CN113792758A
Domain adaptive image classification model training method and device
CN115564967A
Domain adaptive image classification method based on regularization joint autonomous training
CN116091835A
Bridging multi-source-domain adaptive cross-domain histopathologic image recognition method
CN116188428A
Cited By
Hyperspectral image active domain adaptive classification method based on prototype alignment
CN119494989A
Underwater acoustic signal detection method and system based on domain prompt self-adaption
CN122020382A
