Picture classification method and device, electronic equipment and storage medium
By building an image classification model, utilizing feature extraction, reconstruction, and classification of historical source and target domain images, and combining it with multi-loss function training, the problem of inaccurate image classification in existing methods is solved, achieving higher accuracy and robustness.
Patent Information
- Application Number
- CN202210303659.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-24
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2042-03-24
AI Technical Summary
Existing methods rely on image classification models trained on large-scale datasets, which are not accurate enough in classifying target domain images. In addition, the appearance difference between random self-enhanced samples and original samples is small, which makes it difficult for the model to learn robust feature representations and cannot effectively reduce domain differences.
By constructing an image classification model, historical source domain images and target domain images are used for feature extraction, reconstruction and classification. The model is trained with multiple loss functions, including feature extraction layer, source domain classification layer, feature reconstruction layer, target domain classification layer and numerical classification layer. Clustering algorithm and similarity weighted average processing are used to improve the accuracy of the model.
It achieves accurate classification of images, improves the accuracy and robustness of the model in classifying images in the target domain, and reduces the impact of domain differences.
Smart Images

Figure CN114821153B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a method, device, electronic device and storage medium for image classification. Background Art
[0002] With the rapid development of convolutional neural networks, the accuracy of classification tasks has been greatly improved. However, existing methods rely on training large-scale datasets, and data labeling requires a lot of manpower, material resources, and time.
[0003] Currently, many cross-domain classification methods attempt to enforce consistency constraints between target domain samples and their randomly augmented counterparts. However, because the appearance of randomly augmented samples is minimal compared to the original samples, the model struggles to learn robust feature representations for the target domain, preventing the model from mitigating domain discrepancies. Consequently, using random augmented samples can still lead to inaccurate classification of target domain images and other data. Summary of the Invention
[0004] The present invention provides a method, device, electronic device and storage medium for image classification, which are used to solve the defect of inaccurate image classification in the prior art and realize accurate classification of images.
[0005] The present invention provides a method, device, electronic device, and storage medium for image classification, including:
[0006] Input the acquired target domain image to be classified into the image classification model to obtain the classification result output by the image classification model;
[0007] The image classification model is trained based on historical source domain images, historical target domain images, and category labels corresponding to the historical source domain images.
[0008] According to a picture classification method provided by the present invention, the picture classification model includes:
[0009] A feature extraction layer extracts source domain image features corresponding to the source domain image and target domain image features corresponding to the target domain image from the source domain image and the target domain image;
[0010] A source domain classification layer performs classification prediction on the source domain image features to obtain a source domain image classification score corresponding to the source domain image;
[0011] A feature reconstruction layer reconstructs the target domain image features based on the source domain image features to obtain target domain reconstructed features corresponding to the target domain image;
[0012] A target domain classification layer performs classification prediction on the target domain reconstruction features corresponding to the target domain image to obtain a target domain image classification score corresponding to the target domain image;
[0013] The numerical classification layer classifies the target domain source domain image classification score and the target domain image classification score to obtain the classification result.
[0014] According to a picture classification method provided by the present invention, the training steps of the picture classification model are as follows:
[0015] Inputting the historical source domain image and the historical target domain image into the feature extraction layer, and obtaining historical source domain image features corresponding to the historical source domain image and historical target domain image features corresponding to the historical target domain image;
[0016] Constructing a first loss function based on the historical source domain image features;
[0017] constructing a second loss function based on the historical source domain image features and the historical target domain image features;
[0018] Inputting the historical source domain image features and the historical target domain image features into the feature reconstruction layer to obtain the historical target domain reconstruction features corresponding to the historical target domain image;
[0019] constructing a third loss function based on the historical target domain reconstruction features and the historical target domain image features;
[0020] Inputting the historical target domain reconstruction features into the target domain classification layer to obtain the historical target domain image classification score corresponding to the historical target domain reconstruction features;
[0021] constructing a fourth loss function based on the historical target domain image classification score and the initial target domain image classification score corresponding to the historical target domain image feature;
[0022] The training is ended based on the convergence of the first loss function, the second loss function, the third loss function and the fourth loss function.
[0023] According to a picture classification method provided by the present invention, constructing a first loss function based on the historical source domain picture features includes:
[0024] Inputting the historical source domain image features into the source domain classification layer to obtain a historical source domain image classification score corresponding to the historical source domain image features;
[0025] The first loss function is constructed based on the category label of the historical source domain image and the classification score of the historical source domain image.
[0026] According to a picture classification method provided by the present invention, inputting the historical source domain picture features and the historical target domain picture features into the feature reconstruction layer to obtain the historical target domain reconstruction features of the historical target domain picture includes:
[0027] Obtaining a preset number of source domain visual words from historical source domain image features extracted from the historical source domain image;
[0028] Based on the source domain visual words and the historical target domain image features, obtaining a similarity value of each of the historical target source domain image features;
[0029] A weighted average process is performed on the similarity values to obtain the historical target domain reconstruction features.
[0030] According to a picture classification method provided by the present invention, obtaining a preset number of source domain visual words from historical source domain picture features extracted from the historical source domain pictures includes:
[0031] Clustering is performed on the historical source domain image features extracted from the historical source domain images based on a clustering algorithm to obtain a preset number of the source domain visual words.
[0032] The present invention also provides a picture classification device, comprising:
[0033] A classification module is used to input the acquired target domain image to be classified into the image classification model to obtain the classification result output by the image classification model;
[0034] The image classification model is trained based on historical source domain images, historical target domain images, and category labels corresponding to the historical source domain images.
[0035] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any of the above-described image classification methods when executing the computer program.
[0036] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which implements any of the above-mentioned image classification methods when executed by a processor.
[0037] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any of the above-mentioned image classification methods.
[0038] The image classification method, device, electronic device and storage medium provided by the present invention train an image classification model through historical source domain images, historical target domain images and category labels corresponding to the historical source domain images, and input the obtained target domain images to be classified into the trained image classification model to obtain classification results with category labels, thereby achieving accurate classification of images. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the technical solutions in the present invention or the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0040] Figure 1 1 is a flow chart of the image classification method provided by the present invention;
[0041] Figure 2 It is a structural diagram of the image classification device provided by the present invention;
[0042] Figure 3 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0043] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the embodiments described are only some of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.
[0044] The following combination Figures 1 to 3 The present invention describes the image classification method, device, electronic device and storage medium provided by the present invention.
[0045] Figure 1 It is a flow chart of the image classification method provided by the present invention, such as Figure 1 As shown, the present invention provides a method for image classification, wherein the execution subject can be a terminal, such as a computer, a vehicle-mounted terminal, etc. The method includes the following steps:
[0046] Step 101: Input the acquired target domain image to be classified into the image classification model to obtain the classification result output by the image classification model;
[0047] The image classification model is trained based on historical source domain images, historical target domain images, and category labels corresponding to the historical source domain images.
[0048] It can be understood that in this embodiment, the target domain image to be classified is input into the trained image classification model, thereby obtaining the classification result output by the image classification model.
[0049] During the training process of the image classification model, historical source domain images and historical target domain images are input into the classification model, and preliminary training is performed based on the category labels corresponding to the historical source domain images and historical source domain images. Then, the image classification model is trained based on the source domain historical images and historical target domain images.
[0050] Among them, source domain images refer to images with category labels, and target domain images refer to images without category labels.
[0051] The present invention trains an image classification model through historical source domain images, historical target domain images and category labels corresponding to the historical source domain images, and inputs the acquired target domain images to be classified into the trained image classification model to obtain classification results with category labels, thereby achieving accurate classification of images.
[0052] Furthermore, the image classification model includes:
[0053] A feature extraction layer extracts source domain image features corresponding to the source domain image and target domain image features corresponding to the target domain image from the source domain image and the target domain image;
[0054] A source domain classification layer performs classification prediction on the source domain image features to obtain a source domain image classification score corresponding to the source domain image;
[0055] A feature reconstruction layer reconstructs the target domain image features based on the source domain image features to obtain target domain reconstructed features corresponding to the target domain image;
[0056] A target domain classification layer performs classification prediction on the target domain reconstruction features corresponding to the target domain image to obtain a target domain image classification score corresponding to the target domain image;
[0057] The numerical classification layer classifies the target domain source domain image classification score and the target domain image classification score to obtain the classification result.
[0058] It can be understood that, in this embodiment, the image classification model includes a feature extraction layer, a source domain classification layer, a feature reconstruction layer, a target domain classification layer, and a numerical classification layer.
[0059] The feature reconstruction layer can be composed of a feature extraction network, such as ResNet50 or ResNet101. It is used to extract features from input data such as images. That is, during model training, historical source domain image features and historical target domain image features corresponding to historical source domain images can be extracted from historical source domain images and historical target domain images. During model application, target domain image features corresponding to the target domain images to be classified can also be extracted from the target domain images to be classified.
[0060] The source domain classification layer is used to classify and predict the extracted source domain image features to obtain the source domain image classification score corresponding to the source domain image features.
[0061] The feature reconstruction layer is used to reconstruct the target domain image features based on the source domain image features and the target domain image features to obtain the target domain reconstructed features corresponding to the target domain image.
[0062] The target domain classification layer is used to perform classification prediction on the extracted target domain image features and the target domain reconstruction features output by the feature reconstruction layer, and obtain the initial target domain image classification score corresponding to the target domain image features and the target domain image classification score corresponding to the target domain reconstruction features.
[0063] The numerical classification layer is used to classify the obtained target domain source domain image classification scores and target domain image classification scores.
[0064] For example, a score interval may be pre-set, and after the classification scores are obtained, the images may be classified according to the score interval.
[0065] The present invention forms an image classification model through a feature extraction layer, a source domain classification layer, a feature reconstruction layer, a target domain classification layer and a numerical classification layer, and can accurately classify images according to the image classification model.
[0066] Furthermore, the training steps of the image classification model are as follows:
[0067] Inputting the historical source domain image and the historical target domain image into the feature extraction layer, and obtaining historical source domain image features corresponding to the historical source domain image and historical target domain image features corresponding to the historical target domain image;
[0068] Constructing a first loss function based on the historical source domain image features;
[0069] constructing a second loss function based on the historical source domain image features and the historical target domain image features;
[0070] Inputting the historical source domain image features and the historical target domain image features into the feature reconstruction layer to obtain the historical target domain reconstruction features corresponding to the historical target domain image;
[0071] constructing a third loss function based on the historical target domain reconstruction features and the historical target domain image features;
[0072] Inputting the historical target domain reconstruction features into the target domain classification layer to obtain the historical target domain image classification score corresponding to the historical target domain reconstruction features;
[0073] constructing a fourth loss function based on the historical target domain image classification score and the initial target domain image classification score corresponding to the historical target domain image feature;
[0074] The training is ended based on the convergence of the first loss function, the second loss function, the third loss function and the fourth loss function.
[0075] It can be understood that when training the image classification model, the historical source domain images and the historical target domain images are first input into the feature extraction layer to obtain the historical source domain image features corresponding to the historical source domain images and the historical target domain image features corresponding to the historical target domain images.
[0076] After obtaining the historical source domain image features, the historical source domain image features are input into the source domain classification layer to obtain the classification score corresponding to the historical source domain image features. Then, based on the classification score and the category label of the historical source domain image, the first loss function is constructed using the following formula to obtain the standard classification loss value. The formula is as follows:
[0077]
[0078] Where, L cls is the standard classification loss value, is the category label, p s Score for classification.
[0079] When the historical source domain image features are input into the source domain classification layer, the historical source domain image features and the historical target domain image features are aligned and optimized. By constructing a second loss function and obtaining the optimized loss function value through the following formula, the difference between the source domain image features and the target domain image features is minimized. The formula is as follows:
[0080]
[0081] Where, L dis To optimize the loss value of the function, n s and n t represents the number of samples in the historical source domain image data and the historical target domain image data, respectively, and f i s and f j sThey represent the i-th historical source domain image feature and the j-th historical source domain image feature, respectively, and f i t and f j t They represent the i-th historical target domain image feature and the j-th historical target domain image feature, and k represents the kernel function.
[0082] After aligning and optimizing the historical source domain image features and the historical target domain image features and constructing the second loss function, the historical source domain image features and the historical target domain image features are input into the feature reconstruction layer to obtain the historical target domain reconstruction features corresponding to the historical target domain image.
[0083] After obtaining the historical target domain reconstruction features, the third loss function is constructed according to the historical target domain reconstruction features and the historical target domain image features through the following formula to obtain the feature loss value. The formula is as follows:
[0084]
[0085] Where, is the feature loss value, Reconstruct features for the historical target domain, is the historical target domain image feature.
[0086] After obtaining the historical target domain reconstruction feature, the historical target domain reconstruction feature is also input into the target domain classification layer to obtain the historical target domain image classification score corresponding to the historical target domain reconstruction feature.
[0087] Then, based on the historical target domain image classification score and the initial target domain image classification score corresponding to the historical target domain image features, the fourth loss function is constructed using the following formula to obtain the classification score loss value. The formula is as follows:
[0088]
[0089] Where, is the classification score loss value, is the initial target domain image classification score, Scoring historical target domain image classification.
[0090] After constructing the first loss function, the second loss function, the third loss function and the fourth loss function, and obtaining the corresponding standard classification loss value, optimization function loss value, feature loss value and classification score loss value, training is performed multiple times based on the features extracted from the historical source domain images and the historical target domain images until the standard classification loss value, optimization function loss value, feature loss value and classification score loss value are within a smaller range, that is, the training is terminated when the first loss function, the second loss function, the third loss function and the fourth loss function all converge.
[0091] The present invention trains the image classification model by constructing a first loss function, a second loss function, a third loss function and a fourth loss function, which can further improve the classification accuracy of the image classification model.
[0092] Furthermore, constructing a first loss function based on the historical source domain image features includes:
[0093] Inputting the historical source domain image features into the source domain classification layer to obtain a historical source domain image classification score corresponding to the historical source domain image features;
[0094] The first loss function is constructed based on the category label of the historical source domain image and the classification score of the historical source domain image.
[0095] It can be understood that after the historical source domain image features are input into the source domain classification layer, the historical source domain image classification score corresponding to the historical source domain image features can be obtained. Then, based on the classification score and the category label of the historical source domain image, the first loss function is constructed by the following formula to obtain the standard classification loss value. The formula is as follows:
[0096]
[0097] Where, L cls is the standard classification loss value, is the category label, p s Score for classification.
[0098] The present invention obtains the classification scores of historical source domain images through the source domain classification layer, and constructs the first loss function through the category labels of the historical source domain images and the classification scores of the historical source domain images. The image classification model is trained according to the first loss function to further improve the accuracy of the image classification model.
[0099] Furthermore, inputting the historical source domain image features and the historical target domain image features into the feature reconstruction layer to obtain the historical target domain reconstructed features of the historical target domain image includes:
[0100] Obtaining a preset number of source domain visual words from historical source domain image features extracted from the historical source domain image;
[0101] Based on the source domain visual words and the historical target domain image features, obtaining a similarity value of each of the historical target source domain image features;
[0102] A weighted average process is performed on the similarity values to obtain the historical target domain reconstruction features.
[0103] It can be understood that, in this embodiment, K representative source domain visual words V = {V1, V2, ..., V K}(K<<N s ), where N S is the number of source domain samples. After forming the source domain visual words, a memory warehouse is set up to store the source domain visual words, and the source domain visual words are continuously updated in the memory warehouse. The source domain visual words can be updated by the following formula:
[0104] V m =αf s +(1-α)V m
[0105]
[0106] Where V m is the source domain visual word, f s is the historical source domain image feature, V i is the i-th source domain visual word.
[0107] The coefficient α can be obtained according to the following formula:
[0108] α= <f s ,V m >
[0109] Where α is the historical source domain image feature f s and the source domain visual word V m The visual similarity of , <·> represents the cosine similarity, for example T stands for transpose.
[0110] After obtaining the source domain visual words, the similarity value of each historical target source domain image feature is obtained based on the source domain visual words and the historical target domain image features using the following formula:
[0111]
[0112] Where, ω j,k Represents the similarity value between the jth historical target domain image feature and the kth source domain visual word. T1(·), T2(·) and T3(·) are three fully connected layers, V k is the kth source domain visual word, V i is the i-th source domain visual word.
[0113] After obtaining the similarity value of each historical target source domain image feature, the similarity value can be weighted averaged using the following formula to obtain the historical target domain reconstruction feature. The formula is as follows:
[0114]
[0115] Where, Reconstruct features for the historical target domain, ω j,k V represents the similarity between the jth historical target domain image feature and the kth source domain visual word, k is the kth source domain visual word.
[0116] The present invention obtains the similarity value between each historical target source domain image feature and the source domain visual word, and then performs weighted averaging on the similarity value, so as to accurately obtain the historical target domain reconstruction feature, which is beneficial to the training of the image classification model.
[0117] Furthermore, obtaining a preset number of source domain visual words from the historical source domain image features extracted from the historical source domain image includes:
[0118] Clustering is performed on the historical source domain image features extracted from the historical source domain images based on a clustering algorithm to obtain a preset number of the source domain visual words.
[0119] This can be understood as follows: after extracting historical source domain image features from historical source domain images, the extracted historical source domain image features are clustered according to a clustering algorithm. For example, K clusters of historical source domain image features can be obtained. The cluster center is selected from each cluster of historical source domain image features as the source domain visual word, and K representative source domain visual words can be obtained. After the source domain visual words are formed, a memory warehouse is set up to store the source domain visual words, and the source domain visual words are continuously updated in the memory warehouse. The source domain visual words can be updated using the following formula:
[0120] V m =αf s +(1-α)V m
[0121]
[0122] Where V m is the source domain visual word, f s is the historical source domain image feature, V i is the i-th source domain visual word.
[0123] The coefficient α can be obtained according to the following formula:
[0124] α= <f s ,V m >
[0125] Where α is the historical source domain image feature f s and the source domain visual word V mThe visual similarity of , <·> represents the cosine similarity, for example T stands for transpose.
[0126] The present invention can accurately select representative target historical source domain image features from the historical source domain image features extracted from the historical source domain images through a clustering algorithm to form source domain visual words, which is beneficial to the training of the image classification model.
[0127] The image classification device provided by the present invention is described below. The image classification device described below and the image classification method described above can be referenced to each other.
[0128] Figure 2 This is a schematic diagram of the structure of the image classification device provided by the present invention. Figure 2 As shown, the present invention provides an image classification device, which includes a classification module 201, which is used to input the acquired target domain image to be classified into the image classification model to obtain the classification result output by the image classification model;
[0129] The image classification model is trained based on historical source domain images, historical target domain images, and category labels corresponding to the historical source domain images.
[0130] The image classification device provided by the present invention trains an image classification model through historical source domain images, historical target domain images and category labels corresponding to the historical source domain images, and inputs the acquired target domain images to be classified into the trained image classification model to obtain classification results with category labels, thereby achieving accurate classification of images.
[0131] Furthermore, the classification module includes: a feature extraction submodule, which is used to extract source domain image features corresponding to the source domain image and target domain image features corresponding to the target domain image from the source domain image and the target domain image; a source domain classification submodule, which classifies and predicts the source domain image features to obtain a source domain image classification score corresponding to the source domain image; a feature reconstruction submodule, which reconstructs the target domain image features based on the source domain image features to obtain a target domain reconstructed feature corresponding to the target domain image; a target domain classification submodule, which classifies and predicts the target domain reconstructed feature corresponding to the target domain image to obtain a target domain image classification score corresponding to the target domain image; and a numerical classification submodule, which classifies the target domain source domain image classification score and the target domain image classification score to obtain the classification result.
[0132] Furthermore, in order to facilitate training of the image classification model, the image classification device further includes a training module, which includes:
[0133] A historical feature extraction submodule, configured to input the historical source domain image and the historical target domain image into the feature extraction layer, and obtain historical source domain image features corresponding to the historical source domain image and historical target domain image features corresponding to the historical target domain image;
[0134] A first loss function submodule, configured to construct a first loss function based on the historical source domain image features;
[0135] A second loss function submodule, configured to construct a second loss function based on the historical source domain image features and the historical target domain image features;
[0136] A target domain feature reconstruction submodule is used to input the historical source domain image features and the historical target domain image features into the feature reconstruction layer to obtain the historical target domain reconstructed features corresponding to the historical target domain image;
[0137] A third loss function submodule, configured to construct a third loss function based on the historical target domain reconstruction features and the historical target domain image features;
[0138] A feature classification submodule is used to input the historical target domain reconstruction feature into the target domain classification layer to obtain the historical target domain image classification score corresponding to the historical target domain reconstruction feature;
[0139] a fourth loss function submodule, configured to construct a fourth loss function based on the historical target domain image classification score and the initial target domain image classification score corresponding to the historical target domain image feature;
[0140] A training submodule is configured to end the training based on the convergence of the first loss function, the second loss function, the third loss function, and the fourth loss function.
[0141] Furthermore, the first loss function submodule is further used to:
[0142] Inputting the historical source domain image features into the source domain classification layer to obtain a historical source domain image classification score corresponding to the historical source domain image features;
[0143] The first loss function is constructed based on the category label of the historical source domain image and the classification score of the historical source domain image.
[0144] Furthermore, the target domain feature reconstruction submodule is also used to:
[0145] Obtaining a preset number of source domain visual words from historical source domain image features extracted from the historical source domain image;
[0146] Based on the source domain visual words and the historical target domain image features, obtaining a similarity value of each of the historical target source domain image features;
[0147] A weighted average process is performed on the similarity values to obtain the historical target domain reconstruction features.
[0148] Furthermore, the target domain feature reconstruction submodule is also used to:
[0149] Clustering is performed on the historical source domain image features extracted from the historical source domain images based on a clustering algorithm to obtain a preset number of the source domain visual words.
[0150] Figure 3 Schematic diagram of the structure of the electronic device provided by the present invention, such as Figure 3 As shown, the electronic device may include: a processor (processor) 301, a communication interface (Communications Interface) 302, a memory (memory) 303 and a communication bus 304, wherein the processor 301, the communication interface 302, and the memory 303 communicate with each other via the communication bus 304. The processor 301 can call the logic instructions in the memory 303 to execute the image classification method provided by the above-mentioned method embodiments, which method, for example, includes: inputting the obtained target domain image to be classified into the image classification model to obtain the classification result output by the image classification model; the image classification model is trained based on historical source domain images, historical target domain images, and category labels corresponding to the historical source domain images.
[0151] In addition, the logic instructions in the above-mentioned memory 303 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0152] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the image classification method provided by the above-mentioned method embodiments. The method, for example, includes: inputting the acquired target domain image to be classified into the image classification model to obtain the classification result output by the image classification model; the image classification model is trained based on historical source domain images, historical target domain images and category labels corresponding to the historical source domain images.
[0153] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, it is implemented to execute the image classification method provided by the above-mentioned method embodiments. The method, for example, includes: inputting the acquired target domain image to be classified into the image classification model to obtain the classification result output by the image classification model; the image classification model is trained based on historical source domain images, historical target domain images and category labels corresponding to the historical source domain images.
[0154] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.
[0155] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, or of course, by hardware. Based on this understanding, the essence of the above technical solution or the part that contributes to the existing technology can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or certain parts of the embodiments.
[0156] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.
Claims
1. A method for image classification, characterized in that: include: Input the acquired target domain image to be classified into the image classification model to obtain the classification result output by the image classification model; The image classification model is trained based on historical source domain images, historical target domain images, and category labels corresponding to the historical source domain images; The image classification model includes: A feature extraction layer extracts source domain image features corresponding to the source domain image and target domain image features corresponding to the target domain image from the source domain image and the target domain image; A source domain classification layer performs classification prediction on the source domain image features to obtain a source domain image classification score corresponding to the source domain image; A feature reconstruction layer reconstructs the target domain image features based on the source domain image features to obtain target domain reconstructed features corresponding to the target domain image; A target domain classification layer performs classification prediction on the target domain reconstruction features corresponding to the target domain image to obtain a target domain image classification score corresponding to the target domain image; A numerical classification layer, which classifies the source domain image classification score and the target domain image classification score to obtain the classification result; The training steps of the image classification model are as follows: Inputting the historical source domain image and the historical target domain image into the feature extraction layer, and obtaining historical source domain image features corresponding to the historical source domain image and historical target domain image features corresponding to the historical target domain image; Constructing a first loss function based on the historical source domain image features; constructing a second loss function based on the historical source domain image features and the historical target domain image features; Inputting the historical source domain image features and the historical target domain image features into the feature reconstruction layer to obtain the historical target domain reconstruction features corresponding to the historical target domain image; constructing a third loss function based on the historical target domain reconstruction features and the historical target domain image features; Inputting the historical target domain reconstruction features into the target domain classification layer to obtain the historical target domain image classification score corresponding to the historical target domain reconstruction features; constructing a fourth loss function based on the historical target domain image classification score and the initial target domain image classification score corresponding to the historical target domain image feature; The training is ended based on the convergence of the first loss function, the second loss function, the third loss function and the fourth loss function.
2. The image classification method according to claim 1, characterized in that: The constructing a first loss function based on the historical source domain image features includes: Inputting the historical source domain image features into the source domain classification layer to obtain a historical source domain image classification score corresponding to the historical source domain image features; The first loss function is constructed based on the category label of the historical source domain image and the classification score of the historical source domain image.
3. The image classification method according to claim 1, wherein: Inputting the historical source domain image features and the historical target domain image features into the feature reconstruction layer to obtain the historical target domain reconstructed features of the historical target domain image includes: Obtaining a preset number of source domain visual words from historical source domain image features extracted from the historical source domain image; Based on the source domain visual word and the historical target domain image feature, obtaining a similarity value between the historical target domain image feature and the source domain visual word; A weighted average process is performed on the similarity values to obtain the historical target domain reconstruction features.
4. The image classification method according to claim 3, characterized in that: The obtaining of a preset number of source domain visual words from the historical source domain image features extracted from the historical source domain image comprises: Clustering is performed on the historical source domain image features extracted from the historical source domain images based on a clustering algorithm to obtain a preset number of the source domain visual words.
5. A picture classification device, characterized in that: include: A classification module is used to input the acquired target domain image to be classified into the image classification model to obtain the classification result output by the image classification model; The image classification model is trained based on historical source domain images, historical target domain images, and category labels corresponding to the historical source domain images; The image classification model includes: A feature extraction layer extracts source domain image features corresponding to the source domain image and target domain image features corresponding to the target domain image from the source domain image and the target domain image; A source domain classification layer performs classification prediction on the source domain image features to obtain a source domain image classification score corresponding to the source domain image; A feature reconstruction layer reconstructs the target domain image features based on the source domain image features to obtain target domain reconstructed features corresponding to the target domain image; A target domain classification layer performs classification prediction on the target domain reconstruction features corresponding to the target domain image to obtain a target domain image classification score corresponding to the target domain image; A numerical classification layer, which classifies the source domain image classification score and the target domain image classification score to obtain the classification result; The training steps of the image classification model are as follows: Inputting the historical source domain image and the historical target domain image into the feature extraction layer, and obtaining historical source domain image features corresponding to the historical source domain image and historical target domain image features corresponding to the historical target domain image; Constructing a first loss function based on the historical source domain image features; constructing a second loss function based on the historical source domain image features and the historical target domain image features; Inputting the historical source domain image features and the historical target domain image features into the feature reconstruction layer to obtain the historical target domain reconstruction features corresponding to the historical target domain image; constructing a third loss function based on the historical target domain reconstruction features and the historical target domain image features; Inputting the historical target domain reconstruction features into the target domain classification layer to obtain the historical target domain image classification score corresponding to the historical target domain reconstruction features; constructing a fourth loss function based on the historical target domain image classification score and the initial target domain image classification score corresponding to the historical target domain image feature; The training is ended based on the convergence of the first loss function, the second loss function, the third loss function and the fourth loss function.
6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the image classification method according to any one of claims 1 to 4 is implemented.
7. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the image classification method according to any one of claims 1 to 4 is implemented.
8. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the image classification method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Cross-platform palm print recognition method
CN109800677A
TrAdaboost sample migration aerial image classification method based on particle swarm optimization
CN109886303A
Zero sample training and related classification method based on self-supervised domain sensing network
CN111222471A