Contrast learning-based federated few-shot image classification model training method, classification method and device
By employing a contrastive learning approach and utilizing strong data augmentation and dynamic update mechanisms, the problems of complex training and poor model aggregation in federated few-shot learning are solved, achieving high-accuracy image classification in non-independent and identically distributed scenarios.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-03
- Publication Date
- 2026-03-31
AI Technical Summary
Existing federated few-shot learning methods are complex to train, have poor aggregation effects of shared models, and are not suitable for non-independent and identically distributed scenarios.
A contrastive learning-based approach is adopted, which constructs training and query sets by performing strong data augmentation and feature map stitching on the client side, and uses embedding and relational networks for feature extraction and classification. The final image classification model is generated by combining mean squared error loss and exponential moving average update mechanism.
It achieves high accuracy and scalability in non-independent and identically distributed scenarios, and is suitable for data sharing and privacy protection across multiple clients.
Smart Images

Figure CN116229172B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and in particular to a training method, classification method and device for a federated few-shot image classification model based on contrastive learning. Background Technology
[0002] Federated learning is widely used for data privacy protection in smart devices such as smartphones, laptops, and wearables, for collaboratively optimizing shared models, such as user habit prediction, wireless network optimization, and personalized recommendations. In a federated learning framework, multiple clients collaborate to optimize a shared model through weight aggregation rather than local data exchange, thus protecting client user privacy. However, existing federated learning methods heavily rely on high-quality labeled data. For example, users using photo classifier applications are often unwilling to provide specific annotations for privacy-sensitive images. Learning shared models from scattered, unlabeled image data while preserving privacy is an important but overlooked problem. Few-shot learning methods can work well with a small number of labels per class, leading many researchers to investigate federated few-shot learning.
[0003] Federated few-shot learning learns from a small amount of labeled data from multiple clients while protecting data privacy. Low label availability is a long-standing problem in machine learning. While regularization and data augmentation methods can alleviate overfitting, they cannot solve this problem. Therefore, existing few-shot methods learn transferable knowledge through feature embedding or representation learning, and then fine-tune it on downstream targets, but this requires complex training mechanisms and expensive communication protocols. Furthermore, because users always have different habits and usage frequencies, data across multiple devices is often non-independent and identically distributed, leading to degraded performance of shared models. Therefore, while federated few-shot learning methods are effective, they are not suitable for non-independent and identically distributed scenarios. Summary of the Invention
[0004] In view of this, embodiments of the present invention provide a training method, classification method and device for a federated few-shot image classification model based on contrastive learning, so as to eliminate or improve one or more defects in the prior art, and solve the problems that existing federated few-shot learning methods are complex to train, have poor aggregation effect of shared models and are not applicable to non-independent and identically distributed scenarios.
[0005] On the one hand, this invention provides a method for training a federated few-shot image classification model based on contrastive learning, characterized in that the method is executed on each client and includes the following steps:
[0006] Obtain a local dataset and perform strong data augmentation on the local dataset; the local dataset contains multiple classes, each class contains multiple samples, and each sample contains one image; randomly select a first preset number of classes from the local dataset, and randomly select a second preset number of samples from each class to construct a training set, with the remainder used as a query set; add real class labels to the training set;
[0007] Obtain an initial model; the initial model includes an embedding network and a relation network; input a single sample from the training set and a single sample from the query set into the embedding network in pairs to extract feature maps of the training set samples and the query set samples; concatenate the feature maps of the training set samples and the query set samples to generate a concatenated feature map; input the concatenated feature map into the relation network to generate a first preset number of similarity scores, and output the corresponding category of the training set sample based on the similarity scores;
[0008] The initial model is trained using the local dataset, and the mean squared error loss between the category output by the relation network and the true category label is constructed. The parameters of the initial model are iterated using the mean squared error loss to obtain the initial image classification model.
[0009] The model parameters of the initial image classification model are sent to the global server to generate a shared model; the shared model is obtained by the global server through weighted aggregation of the initial image classification model parameters of each client; the parameters of the shared model are received, and the initial image classification model is updated using an exponential moving average to obtain the final image classification model.
[0010] In some embodiments of the present invention, a local dataset is acquired and strong data augmentation is performed on the local dataset. The strong data augmentation includes at least one or more combined operations of spatial transformation cropping, rotation, color dithering, brightness change, and grayscale change.
[0011] In some embodiments of the present invention, the embedded network includes three convolutional blocks and two max pooling layers, and each convolutional block further includes one convolutional layer, one batch normalization layer and one ReLU nonlinear layer;
[0012] The relational network includes two convolutional blocks, two max pooling layers, a first fully connected layer, and a second fully connected layer; the first fully connected layer further includes a ReLU nonlinear layer; the second fully connected layer further includes a Sigmoid nonlinear layer.
[0013] In some embodiments of the present invention, the spliced feature map is input into the relation network to generate a first preset number of similarity scores, wherein the similarity scores are calculated as follows:
[0014] s i,j =f η (Concat(f θ (x i ),f θ (x i )),i=1,2,…,C;
[0015] Among them, s i,j f represents the similarity score; η The relation function represents the relational function of the relational network; Concat(·) represents the depth vector concatenation algorithm; f θ Denotes the embedding function of the embedded network; x i x represents the i-th sample in the training set; j Let J represent the j-th sample in the query set; C represents the first preset quantity class.
[0016] In some embodiments of the present invention, outputting the corresponding category of the training set samples based on the similarity score further includes:
[0017] The similarity score is input into a preset Sigmoid nonlinear layer. A set of floating-point vectors is obtained based on the Sigmoid function mapping. The maximum value in the floating-point vector is obtained and used as the output of the initial model to obtain the category of the training set samples.
[0018] In some embodiments of the present invention, the mean squared error loss between the categories output by the relation network and the true category labels is constructed, and the mean squared error loss is calculated as follows:
[0019]
[0020] Where L represents the mean squared error loss; m represents the number of samples input to the initial model; n represents the number of samples in the query set; s i,j Represents the similarity score; y i Indicates the category of the output of the relational network; y j This represents the actual category label.
[0021] In some embodiments of the present invention, the parameters of the shared model are received, and the initial image classification model is updated using an exponential moving average, calculated as follows:
[0022]
[0023]
[0024] Where, θ g and η gθ represents the parameters of the shared model; θ represents the decay rate; η represents the update threshold; t represents the aggregation of the shared model parameters in the t-th round; μ represents the preset threshold; ξ represents the weights of the parameters of the initial image classification model and the parameters of the shared model in the update.
[0025] In some embodiments of the present invention, the method further includes:
[0026] The model divergence of the initial image classification model during training is calculated. When the model divergence is greater than the preset threshold, the client updates the model using the weights of the shared model. When the model divergence is less than or equal to the preset threshold, the client updates the model using a combination of the weights of its initial image classification model and the shared model.
[0027] On the other hand, the present invention also provides a federated few-shot image classification method based on contrastive learning, characterized in that the method is executed on the client side and includes the following steps:
[0028] Obtain the image to be classified;
[0029] The image is input into the image classification model obtained by the federated few-shot image classification model training method based on contrastive learning as described above, so as to obtain the category of the image.
[0030] On the other hand, the present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the methods mentioned above.
[0031] The beneficial effects of the present invention are at least as follows:
[0032] This invention provides a training method, classification method, and device for a federated few-shot image classification model based on contrastive learning. The method includes: acquiring local datasets from each client and performing strong data augmentation on these datasets to learn a robust classifier with clear decision boundaries; constructing training and query sets based on the local datasets and adding true class labels to the training set; obtaining an initial model, which includes an embedding network and a relational network, and using these networks to classify samples based on image feature similarity, effectively performing few-shot learning; training the initial model using the local datasets and constructing a mean squared error loss to obtain an initial image classification model; considering the non-independent and identically distributed characteristics of the data, designing a dynamic update mechanism to calculate the weight divergence degree of the initial image classification model for each client; and updating the initial image classification model for each client based on the weight divergence degree and shared model parameters to obtain the final image classification model. The image classification model obtained based on the training method provided by this invention has high accuracy and scalability, can achieve accurate image classification, and is suitable for non-independent and identically distributed scenarios.
[0033] Additional advantages, objects, and features of the invention will be set forth in part in the description which follows, and will also become apparent in part to those skilled in the art upon studying the description, or may be learned by practice of the invention. The objects and other advantages of the invention can be realized and obtained by means of the structures specifically pointed out in the description and drawings.
[0034] Those skilled in the art will understand that the objectives and advantages achievable with the present invention are not limited to those specifically described above, and that the above and other objectives achievable with the present invention will become clearer from the following detailed description. Attached Figure Description
[0035] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, are not intended to limit the scope of the invention. In the drawings:
[0036] Figure 1 This is a schematic diagram illustrating the steps of a federated few-shot image classification model training method based on contrastive learning in one embodiment of the present invention.
[0037] Figure 2 This is a flowchart illustrating a federated few-shot image classification model training method based on contrastive learning in one embodiment of the present invention. Detailed Implementation
[0038] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the embodiments and accompanying drawings. Here, the illustrative embodiments and descriptions of this invention are used to explain the invention, but are not intended to limit the invention.
[0039] It should also be noted that, in order to avoid obscuring the invention with unnecessary details, only the structures and / or processing steps closely related to the solution according to the invention are shown in the accompanying drawings, while other details that are not closely related to the invention are omitted.
[0040] It should be emphasized that the term "including / comprises" as used herein refers to the presence of a feature, element, step, or component, but does not exclude the presence or addition of one or more other features, elements, steps, or components.
[0041] It should also be noted that, unless otherwise specified, the term "connection" in this article can refer not only to a direct connection, but also to an indirect connection involving an intermediary.
[0042] In the following description, embodiments of the invention will be illustrated with reference to the accompanying drawings. In the drawings, the same reference numerals represent the same or similar parts, or the same or similar steps.
[0043] It should be emphasized here that the step markers mentioned below are not a limitation on the order of the steps, but should be understood as meaning that the steps can be executed in the order mentioned in the embodiments, or in a different order than in the embodiments, or several steps can be executed simultaneously.
[0044] To address the problems of complex training, poor aggregation performance of shared models, and inapplicability to non-independent and identically distributed scenarios in existing federated few-shot learning methods, this invention provides a federated few-shot image classification model training method based on contrastive learning, such as... Figure 1 As shown, the method includes the following steps S101 to S104:
[0045] Step S101: Obtain the local dataset and perform strong data augmentation on it. The local dataset contains multiple classes, each class contains multiple samples, and each sample contains one image. Randomly select a first preset number of classes from the local dataset, and randomly select a second preset number of samples from each class to construct the training set. The remaining samples are used as the query set. Add true class labels to the training set.
[0046] Step S102: Obtain the initial model; the initial model includes an embedding network and a relational network; input a single sample from the training set and a single sample from the query set into the embedding network in pairs to extract feature maps of the training set samples and the query set samples; concatenate the feature maps of the training set samples and the query set samples to generate a concatenated feature map; input the concatenated feature map into the relational network to generate a first preset number of similarity scores, and output the corresponding category of the training set samples based on the similarity scores.
[0047] Step S103: Train the initial model using the local dataset, construct the mean squared error loss between the category output by the relation network and the true category label, and iterate the parameters of the initial model using the mean squared error loss to obtain the initial image classification model.
[0048] Step S104: Send the model parameters of the initial image classification model to the global server to generate a shared model; wherein, the shared model is obtained by the global server through weighted aggregation of the initial image classification model parameters of each client; receive the parameters of the shared model and update the initial image classification model using an exponential moving average to obtain the final image classification model.
[0049] This invention proposes a federated few-shot learning framework based on contrastive networks, which relies on traditional distributed learning architectures and deep neural network frameworks for model training. The deep neural network framework can be PyTorch, TensorFlow, etc.
[0050] In step S101, the local datasets of each client are obtained. Considering the overfitting problem mentioned in the background art, this invention performs strong data augmentation on the local datasets. Strong data augmentation, as opposed to weak augmentation, includes random resizing, pruning, or flipping. The same augmentation strategy is used for each client in the federated learning framework, and the optimal strategy is not searched on different datasets.
[0051] In some embodiments, strong data augmentation includes at least one or more combined operations such as spatial transformation pruning, rotation, color dithering, brightness alteration, and grayscale adjustment. Based on the design of strong data augmentation, federated learning can achieve robust classifiers with well-defined decision boundaries.
[0052] From the local dataset, a first preset number of classes are randomly selected, and a second preset number of samples are randomly selected from each class to construct a training set. The remaining samples are used as the query set, and true class labels are added to the training set. For example, the first preset number is denoted as C, the training set as S, and the query set as Q; where the i-th sample in the training set is denoted as x. i ∈S; the j-th sample in the query set is denoted as x. j ∈Q.
[0053] In step S102, each client obtains an initial model from the global server. This initial model includes an embedding network and a relational network. The embedding network consists of a neural network with weights θ, which learns an embedding function f. θ It maps the input image into an embedded feature vector; the relational network learns a relational function f. η To calculate the relationship score with the true category label.
[0054] In some embodiments, the embedded network includes three convolutional blocks and two 2×2 max-pooling layers. Each convolutional block further includes one 3×3 convolutional layer, one batch normalization layer, and one ReLU nonlinear layer. The number of channels in the convolutional layers is 64.
[0055] In some embodiments, the relational network includes two convolutional blocks, two 2×2 max-pooling layers, a first fully connected layer, and a second fully connected layer. The structure of the convolutional blocks is the same as that of the convolutional blocks in the embedded network. The first fully connected layer has 8 units, including one ReLU nonlinear layer; the second fully connected layer has 8 units, including one Sigmoid nonlinear layer.
[0056] like Figure 2 The diagram shows the overall process of the initial model based on federated few-shot learning. Specifically, it involves processing a single sample x from the training set... i and a single sample x of the query set j Paired input embedding network to extract feature maps f from training set samples θ (xi ) and query set sample feature map f θ (x j The training set sample feature map and the query set sample feature map are concatenated to generate a concatenated feature map, Concat(f). θ (x i ), f θ (x j The concatenated feature map is input into the relational network to generate a first preset number C similarity scores s. i,j It outputs the corresponding category of the training set samples based on the similarity score.
[0057] In some embodiments, the similarity score is calculated as shown in formula (1):
[0058] s i,j =f η (Concat(f θ (x i ), f θ (x j ))), i=1, 2,...,C; (1)
[0059] Among them, s i,j f represents the similarity score; η Represents the relation function of a relational network; Concat(·) represents the depth vector concatenation algorithm; f θ The embedding function represents the embedding network; x i x represents the i-th sample in the training set; j Let J represent the j-th sample in the query set; C represents the first preset quantity class.
[0060] In some embodiments, outputting the corresponding category of the training set samples based on the similarity score further includes the following steps:
[0061] A Sigmoid non-linear layer is preset in the relationship network. The similarity score is input into the preset Sigmoid non-linear layer. A set of floating-point vectors is obtained based on the Sigmoid function mapping. The maximum value in the floating-point vector is obtained and used as the output of the initial model to obtain the category of the training set samples.
[0062] In step S103, the initial model is trained using the local dataset, and the mean squared error loss between the category output by the relation network and the true category label is constructed. The parameters of the initial model are iterated using the mean squared error loss to obtain the initial image classification model.
[0063] In some embodiments, the mean squared error loss is calculated as shown in formula (2):
[0064]
[0065] Where L represents the mean squared error loss; m represents the number of samples input to the initial model; n represents the number of samples in the query set; s i,j Represents the similarity score; y i Indicates the category of the relational network output; y j This represents the actual category label.
[0066] In step S104, inspired by the divergence of weights caused by non-independent and identically distributed data, this invention designs a dynamic update mechanism to dynamically update the parameters of the initial image classification model based on the divergence of weights.
[0067] In one round of training, after training the initial image classification model for each client based on the local dataset, each client sends the parameters of its own model to the global server, where the global server... Figure 2 In this context, a cloud server is used. The global server obtains the parameters from each client's model, performs weighted aggregation to construct a shared model, and sends the parameters of the shared model to each client. Each client receives the parameters of the shared model and updates its initial image classification model using an exponential moving average to obtain the final image classification model.
[0068] In some embodiments, the initial image classification model is updated using an exponential moving average, as shown in formulas (3) and (4):
[0069]
[0070]
[0071] Where, θ g and η g ξ represents the parameters of the shared model; θ represents the decay rate; η represents the update threshold; t represents the aggregation of shared model parameters in the t-th round; μ represents the preset threshold; ξ represents the weights of the parameters of the initial image classification model and the parameters of the shared model in the update.
[0072] θ of the initial image classification model c and η c Updates are based on a shared model, utilizing... and This is used to measure the model divergence of the initial image classification model during training.
[0073] In some embodiments, after calculating the model divergence of the initial image classification model during training, if the model divergence is greater than a preset threshold, the client updates the model using the weights of the shared model; if the model divergence is less than or equal to the preset threshold, the client updates the model using a combination of the weights of its initial image classification model and the shared model.
[0074] The present invention also provides a federated few-shot image classification method based on contrastive learning, the method comprising the following steps S201 to S202:
[0075] Step S201: Obtain the image to be classified.
[0076] Step S202: Input the image into the image classification model obtained by the federated few-shot image classification model training method based on contrastive learning as described above, in order to obtain the image category.
[0077] The present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of a training method for a federated few-shot image classification model based on contrastive learning and a federated few-shot image classification method based on contrastive learning.
[0078] Corresponding to the above method, the present invention also provides an apparatus comprising a computer device, the computer device including a processor and a memory, the memory storing computer instructions, the processor executing the computer instructions stored in the memory, and when the computer instructions are executed by the processor, the apparatus performs the steps of the method as described above.
[0079] This invention also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the aforementioned edge computing server deployment method. The computer-readable storage medium can be a tangible storage medium, such as random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, floppy disks, hard disks, removable storage disks, CD-ROMs, or any other form of storage medium known in the art.
[0080] In summary, this invention provides a training method, classification method, and device for a federated few-shot image classification model based on contrastive learning. The method includes: acquiring local datasets from each client and performing strong data augmentation on these datasets to learn a robust classifier with clear decision boundaries; constructing training and query sets based on the local datasets and adding true class labels to the training set; obtaining an initial model, which includes an embedding network and a relational network, and using these networks to classify samples based on image feature similarity, effectively performing few-shot learning; training the initial model using the local datasets and constructing a mean squared error loss to obtain an initial image classification model; considering the non-independent and identically distributed characteristics of the data, designing a dynamic update mechanism to calculate the weight divergence degree of the initial image classification model for each client, and updating the initial image classification model for each client based on the weight divergence degree and shared model parameters to obtain the final image classification model. The image classification model obtained based on the training method provided by this invention has high accuracy and scalability, can achieve accurate image classification, and is suitable for non-independent and identically distributed scenarios.
[0081] Those skilled in the art will understand that the exemplary components, systems, and methods described in conjunction with the embodiments disclosed herein can be implemented in hardware, software, or a combination of both. Whether implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this invention. When implemented in hardware, it can be, for example, electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this invention are programs or code segments used to perform the desired tasks. The programs or code segments can be stored in a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried in a carrier wave.
[0082] It should be clarified that the present invention is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present invention is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of the present invention.
[0083] In this invention, features described and / or illustrated for one embodiment may be used in the same or similar manner in one or more other embodiments, and / or combined with or in place of features of other embodiments.
[0084] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, various modifications and variations of the embodiments of the present invention are possible. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A federated few-shot image classification model training method based on contrastive learning, characterized in that, The method is executed at each client and includes the following steps: Obtain a local data set and perform strong data augmentation on the local data set; the local data set contains multiple classes, each class contains multiple samples, and each sample contains an image; randomly select a first preset number of classes from the local data set, randomly select a second preset number of samples in each class, construct a training set, and the rest as a query set; add a true class label to the training set; Obtain an initial model; the initial model includes an embedding network and a relationship network, the embedding network includes three convolutional blocks and two max-pooling layers, each convolutional block further includes one convolutional layer, one batch normalization layer and one ReLu nonlinear layer; the relationship network includes two convolutional blocks, two max-pooling layers, a first fully connected layer and a second fully connected layer; the first fully connected layer further includes one ReLu nonlinear layer; the second fully connected layer further includes one Sigmoid nonlinear layer; input a single sample of the training set and a single sample of the query set into the embedding network in pairs to extract training set sample feature maps and query set sample feature maps; splice the training set sample feature maps and the query set sample feature maps to generate spliced feature maps; input the spliced feature maps into the relationship network to generate the first preset number of similarity scores, and output the corresponding classes of the training set samples according to the similarity scores; Train the initial model using the local data set to construct the mean square error loss between the classes output by the relationship network and the true class label, and iteratively update the parameters of the initial model using the mean square error loss to obtain an initial image classification model; Send the model parameters of the initial image classification model to a global server to generate a shared model; the shared model is obtained by the global server according to the weighted aggregation of the initial image classification model parameters of each client; receive the parameters of the shared model and update the initial image classification model using an exponential moving average to obtain a final image classification model.
2. The federated few-shot image classification model training method based on contrastive learning according to claim 1, characterized in that, Obtain a local data set and perform strong data augmentation on the local data set, which at least includes one or more combined operations of spatial transformation cropping, rotation, color jittering, changing brightness, and grayscale.
3. The federated few-shot image classification model training method based on contrastive learning according to claim 1, characterized in that, Input the spliced feature maps into the relationship network to generate the first preset number of similarity scores, and the calculation formula of the similarity scores is: ; in, This represents the similarity score; Represents the relational function of the relational network; This represents the depth vector concatenation algorithm; Represents the embedding function of the embedded network; The training set represents the first... One sample; Represents the first query set One sample; This indicates the first preset quantity class.
4. The federated few-shot image classification model training method based on contrastive learning according to claim 1, characterized in that, According to the similarity scores, output the corresponding classes of the training set samples, which further includes: Input the similarity scores into a preset Sigmoid nonlinear layer, map a group of floating point vectors based on the Sigmoid function, obtain the maximum value in the floating point vector, and take it as the output of the initial model to obtain the classes of the training set samples.
5. The federated few-shot image classification model training method based on contrastive learning according to claim 1, characterized in that, Construct the mean square error loss between the classes output by the relationship network and the true class label, and the calculation formula of the mean square error loss is: ; wherein, denotes the mean squared error loss; denotes the number of samples input to the initial model; denotes the number of samples in the query set; denotes the similarity score; denotes the class output by the relation network; denotes the true class label.
6. The federated few-shot image classification model training method based on contrastive learning according to claim 1, characterized in that, Receive the parameters of the shared model and update the initial image classification model using an exponential moving average, and the calculation formula is: ; ; wherein, and are parameters of the shared model; denotes a decay rate, denotes an update threshold; denotes a first round of the shared model parameter aggregation; denotes a preset threshold; denotes weights of the parameters of the initial image classification model and the parameters of the shared model in the update, respectively.
7. The federated few-shot image classification model training method based on contrastive learning according to claim 6, characterized in that, Further includes: calculating a model divergence of the initial image classification model during training, when the model divergence is greater than the preset threshold, the client updates using the shared model weight; when the model divergence is less than or equal to the preset threshold, the client updates using the combination of the initial image classification model and the shared model weight.
8. A federated few-shot image classification method based on contrastive learning, characterized in that, The method is executed on a client and comprises the following steps: obtaining an image to be classified; inputting the image into the image classification model obtained by the federated few-shot image classification model training method based on contrast learning according to any one of claims 1 to 7 to obtain the class of the image.
9. A computer readable storage medium having stored thereon a computer program, characterized in that, The program is executed by a processor to implement the steps of the method according to any one of claims 1 to 8.