Image classification algorithm based on combination of adaptive comparative learning and federated learning

Through adaptive contrast learning combined with federated learning, the problem of poor accuracy of image classification model under heterogeneous data and noise labels is solved, and the robustness and generalization ability of the model are enhanced, which is suitable for the field of image classification.

CN120543947APending Publication Date: 2025-08-26HARBIN UNIV OF SCI & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510723565.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-31
Publication Date
2025-08-26

AI Technical Summary

Technical Problem

When facing data heterogeneity and label noise problems, the classification accuracy of the image classification model is poor, especially in cross-project collaborative training, it is difficult to effectively adapt to the influence of non-independent and homogeneous data distribution and noise labels.

Method used

Adaptive contrast learning combined with federated learning methods are used to optimize the model's collaborative training under heterogeneous data through data set truncation, channel truncation and image enhancement processing, combined with dynamic temperature adjustment and improved loss function, and enhance the model's robustness and adaptability to data loss.

Benefits of technology

It significantly improves the classification accuracy of the model under heterogeneous data and high noise conditions, improves the generalization ability and robustness of the model, and is suitable for the field of image classification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure FT_1
    Figure FT_1
  • Figure FT_2
    Figure FT_2
  • Figure FT_3
    Figure FT_3
Patent Text Reader

Abstract

The invention belongs to the field of federated learning and image classification, and particularly relates to an image classification algorithm based on combination of self-adaptive comparative learning and federated learning. According to the algorithm, local data of participants are distributed through a data division strategy, and non-uniformity of distributed data in a real scene is simulated; then, the heterogeneity of the data is controlled through Dirichlet distribution, and the flexibility of data division is further enhanced; each participant constructs a local convolutional neural network according to the distributed data, a dynamic temperature adjustment mechanism is introduced in the training process, temperature parameters are dynamically adjusted according to gradient variance and personalized features of clients, sample similarity calculation in the learning process is optimized and compared, and the adaptability of the model to different client data is improved. In addition, efficient and accurate image classification is realized by comparing a learning loss function (such as InfoNCE loss) with knowledge distillation of a historical model pool.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of federated learning and image classification. Background Art

[0002] With the booming development of big data and artificial intelligence, data has become the core factor driving the training and optimization of machine learning models. Deep learning models often show excellent performance when trained on large-scale, representative data sets. However, in real-world scenarios, data is usually stored in different entities (such as enterprises, institutions, mobile devices, etc.). Subject to strict constraints of privacy regulations and data protection policies, these data cannot be collected centrally for model training. This realistic dilemma has led to the emergence of Federated Learning (FL) technology, which allows multiple participants to collaboratively train machine learning models without directly exchanging local data, providing an innovative solution to the problem of data silos.

[0003] Image classification, as a core task in computer vision, is crucial for understanding the visual world and enabling intelligent decision-making. By enabling machines to identify objects, scenes, or abstract concepts within images, image classification has not only driven breakthroughs in artificial intelligence (AI) but has also solved complex problems that humans struggle to efficiently handle in scenarios such as medical diagnosis and autonomous driving. Traditional image classification methods rely primarily on balanced data. However, in real-world applications, data often differs significantly between projects, making the direct application of traditional methods challenging. These challenges include, but are not limited to:

[0004] 1. Data heterogeneity: Data collection standards and methods may differ across projects, leading to differences in data characteristics and distribution, which in turn contributes to data heterogeneity. To address these issues, this paper proposes an image classification algorithm based on adaptive contrastive learning combined with federated learning. This algorithm leverages federated learning to enable collaborative training across multiple data sources. Through dataset truncation, each client is assigned a different data subset, effectively simulating a non-IID data distribution. To enhance the model's robustness to data corruption, we employ channel truncation, setting certain image channels to zero, enhancing the model's robustness to missing data. Through image augmentation and normalization, we significantly improve the model's generalization. To address the challenge of poor classification accuracy when processing non-IID data, this paper introduces model contrastive learning at the algorithmic level. By constraining the alignment of local and global model representations in feature space, this algorithm aligns the update direction of local parameters and mitigates model drift caused by client data heterogeneity. During the federated optimization process, a contrastive regularization term based on global-local representation consistency is introduced to guide client models to converge toward the global feature space, mitigating the negative impact of heterogeneous data on collaborative training.

[0005] 2. Data label noise problem: The consistency and accuracy of annotations in different projects may vary greatly, and errors are inevitable in the process of data collection, resulting in the generation of erroneous labels and noise, which increases the difficulty of model training. In order to solve these problems, the present invention proposes an image classification algorithm based on adaptive contrastive learning combined with federated learning. The algorithm innovatively designs a dynamic temperature adjustment mechanism on the basis of ordinary contrastive learning, and optimizes the calculation of sample similarity by adjusting the temperature parameters in contrastive learning. In the presence of label noise, appropriate temperature adjustment can help the model better distinguish between samples of different categories. During the training process, the temperature parameters are dynamically adjusted according to the gradient variance and the personalized characteristics of the client. Through dynamic temperature adjustment, the model can better adapt to the data distribution of different clients and reduce the impact of noise labels on model training. Summary of the Invention

[0006] This invention aims to address the problem of poor classification model accuracy caused by data heterogeneity and label noise in image classification datasets. Based on the federated learning framework, it uses adaptive contrastive learning in the local learning phase to reduce the distance between the representation learned by the local model and the representation learned by the global model. It also increases the distance between the representation learned by the local model and the representation learned by the previous local model, and designs a technology that dynamically adjusts the temperature parameter based on the gradient variance and the client's personalized characteristics, so that the model can better adapt to heterogeneous data distribution.

[0007] The image classification algorithm based on adaptive contrastive learning combined with federated learning described in the present invention includes:

[0008] Step 1: Apply dataset truncation to each participant's local data. This method not only supports data segmentation in distributed training, but also effectively simulates scenarios with non-independent and identically distributed (Non-IID) data.

[0009] Step 2: In terms of image data preprocessing, we introduced channel truncation and image transformation techniques. The truncate_channel method can set certain channels of the image (such as the green and blue channels) to zero, thereby simulating data corruption and enhancing the model's robustness to data loss. In addition, using the transform parameter, we perform augmentation processing (such as random cropping and flipping) and normalization operations on the image data, improving the model's generalization ability.

[0010] Step 3: The dataset is distributed to different participants (clients) according to the specified partitioning strategy (such as non-independent and identically distributed (Non-IID) or independent and identically distributed (IID)). The partitioning strategy is implemented through the partition_data function, which supports the use of Dirichlet distribution to control data heterogeneity. In each iteration, a fixed number of samples with different characteristics are randomly selected as the public dataset to adjust the model alignment knowledge distribution of each participant during the collaborative learning phase, and to initialize the untrained local convolutional neural network model.

[0011] Step 4: An improved loss function combining cross-entropy loss and contrastive loss is used. By integrating the advantages of supervised learning and self-supervised learning, the problems of data heterogeneity and model drift in federated learning are effectively addressed. Contrastive loss enhances the discriminability of the representation space by introducing negative samples (such as representations of other clients or historical global models), forcing the model to learn more generalizable features. By constraining the similarity between local and global representations, the divergence of local updates is suppressed, thereby reducing conflicts during model aggregation.

[0012] Step 5: Design a dynamic temperature adjustment mechanism to dynamically adjust the temperature parameter based on the gradient variance and the client's personalized characteristics (such as the beta parameter of the Dirichlet distribution). This helps optimize the sample similarity calculation during the contrastive learning process and improves the model's adaptability to different client data.

[0013] Step 6: Use the training set to train the local model created in step 3 to obtain an image classification model;

[0014] Step 7: Use the test set to test the image classification model and perform performance evaluation.

[0015] Furthermore, in the present invention, in step 1, the process of preprocessing each participant's local data using the data set truncation technology is as follows:

[0016] Step 1: The image data owned by each participant often has distribution differences compared to the data of other participants. By specifying the dataidxs parameter, you can selectively intercept some samples from the dataset, thereby allocating different data subsets to each client, simulating the data distribution differences between clients in distributed training and improving the generalization ability of the model.

[0017] Steps 1 and 2: To meet the requirements for loading custom datasets, we designed the ImageFolder_custom class, which inherits from DatasetFolder. This class supports loading data from custom image folders and flexibly selects samples through the dataidxs parameter, further enhancing the flexibility and versatility of data preprocessing.

[0018] Furthermore, in the present invention, in step 2, the process of applying channel truncation and image conversion technology to each processed local data set is as follows:

[0019] Step 2: Using the truncate_channel method, some channels of the image (such as the green and blue channels) can be set to zero, thereby simulating data corruption and enhancing the model's robustness to data loss.

[0020] Step 2: Using the transform parameter, we augmented the image data (such as random cropping and flipping) and normalized it, adjusting the pixel value range to [0, 1] or [-1, 1], significantly improving the model's generalization capabilities. Furthermore, using the target_transform parameter, we performed necessary processing on the target labels, such as converting the category labels from strings to integers to ensure data format consistency.

[0021] Furthermore, in the present invention, in step 3, the partitioning strategy is implemented by the partition_data function and the process of controlling the heterogeneity of the data by using the Dirichlet distribution is as follows:

[0022] Step 3.1. According to the partition parameter, select different data partitioning methods. When it is Non-IID data partitioning, divide it according to the category label to ensure that the data of each client is non-independent and identically distributed in the category distribution. First initialize the index list idx_k of each category and randomly shuffle it. Use Dirichlet distribution to generate the partition proportions for each category, simulate the non-uniform distribution of data, and distribute samples of each category to different clients according to the proportion. If the amount of data for a client is insufficient, readjust the proportion and redistribute it until the amount of data for each client meets the minimum requirement. Finally, randomly shuffle the sample indexes assigned to each client to ensure the randomness of the data;

[0023] Step 32: In each local training, randomly select samples with different features from the participating clients, and set the feature size to the same size as the local dataset, and organize them into a three-dimensional tensor;

[0024] Step 3. Create a local convolutional neural network model, ResNet-50, adapted to the three-dimensional tensor of the feature dimension. The structure is as follows: the input layer is followed by a 7×7 convolutional layer, followed by a ReLU activation function. After the convolutional layer, the network has a max pooling layer for downsampling. Next, the network contains four residual block groups, each group contains multiple residual blocks. Each residual block consists of two 3×3 convolutional layers and a skip connection to alleviate the vanishing gradient problem. Finally, a global average pooling layer is used to compress the feature map into a one-dimensional vector. The classification result is then output through a fully connected layer, and the final category prediction is made using a Softmax classifier.

[0025] Furthermore, in step 4 of the present invention, the loss function used is a combination of cross entropy loss and contrast loss, an improved Bootstrap Loss. This improvement not only combines the precise guidance advantage of supervised learning, but also introduces the powerful generalization ability of self-supervised learning. The process of optimizing the model architecture and federated learning to improve the model's noise resistance and increase robustness is as follows:

[0026] Furthermore, in step 4, the mathematical expression of the model contrast loss is:

[0027]

[0028] where z glob represents the representation extracted from the tth round of the global model, and z prev Representations extracted from the t-1th local model.

[0029] Furthermore, in the present invention, in step 5, adaptive contrastive learning is introduced to perform knowledge exchange, replacing the traditional knowledge exchange between the global model and the local model. The process of improving the model performance is as follows:

[0030] Step 5.1: In the model aggregation phase, the system does not use the traditional global model aggregation method, but instead implements a federated learning method based on adaptive contrastive learning to learn from each other. The core idea of ​​model contrastive learning is to reduce the distance between the representation learned by the local model and the representation learned by the global model, and increase the distance between the representation learned by the local model and the representation learned by the previous local model. In this way, it can effectively prevent the local model from deviating too much from the global model, suppress client drift, and thus improve the classification accuracy and model generalization ability;

[0031] Step 5.2: τ is a key hyperparameter in contrastive learning. It balances the relationship between the global model (positive samples) and the previous local model (negative samples). Fixed parameter values ​​can cause the model to focus too early on difficult samples and neglect global feature learning during early training. Fixed values ​​(such as 0.5) can inhibit robustness to noisy data and exacerbate overfitting. To address this issue, we designed a dynamic adaptive temperature parameter that dynamically adjusts based on gradient variance and client heterogeneity.

[0032] Furthermore, in step 52, the mathematical expressions of the gradient variance adaptive term and the client heterogeneity adjustment factor are:

[0033]

[0034] where σ 2 Represents the current batch gradient variance, T is the variance threshold (hyperparameter), α is the scaling factor (0.2 in the code), and the role of the tanh function is to compress the variance effect to the [-1, 1] interval. i is the Dirichlet distribution parameter of the i-th client, and β is the average heterogeneity of all clients.

[0035] Furthermore, in the present invention, in step six, the local model of the participant is trained using the training set to obtain an image classification model.

[0036] Furthermore, in the present invention, in step seven, the image classification model is tested using a test set.

[0037] The present invention designs and verifies an image classification algorithm based on adaptive contrastive learning combined with federated learning, aiming to address the data heterogeneity and noise problems existing in the field of image classification. By leveraging the advantages of distributed and collaborative learning and adaptive contrastive learning of federated learning, the system strengthens data privacy protection, reduces data bias, and improves the generalization ability of the model, effectively addressing the core problem of low accuracy in cross-project image classification. Experimental results show that the accuracy of image classification has been significantly improved, especially in the face of high label noise and data heterogeneity. In addition, the adaptive contrastive learning method is used to replace the traditional knowledge exchange between the global model and the local model, thereby improving the performance of the model. The present invention has achieved good accuracy on heterogeneous data sets of varying degrees, is suitable for the field of image classification, and has robust and noise-tolerant performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1 This is a flowchart of an image classification algorithm based on adaptive contrastive learning combined with federated learning in the method of the present invention.

[0039] Figure 2 It is a block diagram of the image classification algorithm based on adaptive contrastive learning combined with federated learning in the method of the present invention.

[0040] Figure 3 This is a visualization result diagram comparing the method of the present invention with different loss functions. DETAILED DESCRIPTION

[0041] The technical solutions in the embodiments of the present invention will be described clearly and completely below with reference to the accompanying drawings in the embodiments of the present invention.

[0042] The image classification algorithm based on adaptive contrastive learning combined with federated learning in this specific implementation is as follows: Figure 1 As shown, the following steps are included:

[0043] Step 1: Apply dataset truncation to each participant's local data. This method not only supports data segmentation in distributed training, but also effectively simulates scenarios with non-independent and identically distributed (Non-IID) data.

[0044] Step 1: The image data owned by each participant often has distribution differences compared to the data of other participants. By specifying the dataidxs parameter, you can selectively intercept some samples from the dataset, thereby allocating different data subsets to each client, simulating the data distribution differences between clients in distributed training and improving the generalization ability of the model.

[0045] Steps 1 and 2: To meet the requirements for loading custom datasets, we designed the ImageFolder_custom class, which inherits from DatasetFolder. This class supports loading data from custom image folders and flexibly selects samples through the dataidxs parameter, further enhancing the flexibility and versatility of data preprocessing.

[0046] Step 2: In terms of image data preprocessing, we introduced channel truncation and image transformation techniques. The truncate_channel method can set certain channels of the image (such as the green and blue channels) to zero, thereby simulating data corruption and enhancing the model's robustness to data loss. In addition, using the transform parameter, we perform augmentation processing (such as random cropping and flipping) and normalization operations on the image data, improving the model's generalization ability.

[0047] Step 2: Use the runcate_channel method to set certain channels of the image (such as the green and blue channels) to zero, thereby simulating data corruption and enhancing the model's robustness to data loss.

[0048] Step 2: Using the transform parameter, we augmented the image data (such as random cropping and flipping) and normalized it, adjusting the pixel value range to [0, 1] or [-1, 1], significantly improving the model's generalization capabilities. Furthermore, using the target_transform parameter, we performed necessary processing on the target labels, such as converting the category labels from strings to integers to ensure data format consistency.

[0049] Step 3: The dataset is distributed to different participants (clients) according to the specified partitioning strategy (such as non-independent and identically distributed (Non-IID) or independent and identically distributed (IID)). The partitioning strategy is implemented through the partition_data function, which supports the use of Dirichlet distribution to control data heterogeneity. In each iteration, a fixed number of samples with different characteristics are randomly selected as the public dataset to adjust the model alignment knowledge distribution of each participant during the collaborative learning phase, and to initialize the untrained local convolutional neural network model.

[0050] Step 3.1. According to the partition parameter, select different data partitioning methods. When it is Non-IID data partitioning, divide it according to the category label to ensure that the data of each client is non-independent and identically distributed in the category distribution. First initialize the index list idx_k of each category and randomly shuffle it. Use Dirichlet distribution to generate the partition proportions for each category, simulate the non-uniform distribution of data, and distribute samples of each category to different clients according to the proportion. If the amount of data for a client is insufficient, readjust the proportion and redistribute it until the amount of data for each client meets the minimum requirement. Finally, randomly shuffle the sample indexes assigned to each client to ensure the randomness of the data;

[0051] Step 32: In each local training, randomly select samples with different features from the participating clients, and set the feature size to the same size as the local dataset, and organize them into a three-dimensional tensor;

[0052] Step 3. Create a local convolutional neural network model, ResNet-50, adapted to the three-dimensional tensor of the feature dimension. The structure is as follows: the input layer is followed by a 7×7 convolutional layer, followed by a ReLU activation function. After the convolutional layer, the network has a max pooling layer for downsampling. Next, the network contains four residual block groups, each group contains multiple residual blocks. Each residual block consists of two 3×3 convolutional layers and a skip connection to alleviate the vanishing gradient problem. Finally, a global average pooling layer is used to compress the feature map into a one-dimensional vector. The classification result is then output through a fully connected layer, and the final category prediction is made using a Softmax classifier.

[0053] Step 4: An improved loss function combining cross-entropy loss and contrastive loss is used. By integrating the advantages of supervised learning and self-supervised learning, the problems of data heterogeneity and model drift in federated learning are effectively addressed. Contrastive loss enhances the discriminability of the representation space by introducing negative samples (such as representations of other clients or historical global models), forcing the model to learn more generalizable features. By constraining the similarity between local and global representations, the divergence of local updates is suppressed, thereby reducing conflicts during model aggregation.

[0054] Step 5: Design a dynamic temperature adjustment mechanism to dynamically adjust the temperature parameter based on the gradient variance and the client's personalized characteristics (such as the beta parameter of the Dirichlet distribution). This helps optimize the sample similarity calculation during the contrastive learning process and improves the model's adaptability to different client data.

[0055] Step 5.1: During the model aggregation phase, the system does not use traditional global model aggregation methods. Instead, it implements a federated learning approach based on adaptive contrastive learning. The core idea of ​​model contrastive learning is to reduce the distance between the representation learned by the local model and the global model, and increase the distance between the representation learned by the local model and the representation learned by the previous local model. This effectively prevents the local model from deviating excessively from the global model, suppresses client drift, and thus improves classification accuracy and model generalization.

[0056] Step 52: Design a dynamic adaptive temperature parameter, which is dynamically adjusted based on the gradient variance and client heterogeneity, to optimize the sample similarity calculation during the contrastive learning process and improve the model's adaptability to different client data.

[0057] Step 6: Use the training set to train the local model of each participant to obtain an image classification model. The maximum number of training rounds for global collaboration is 100 rounds, and the number of local model update rounds is 10 rounds;

[0058] Step 7: Use the test set to test the image classification model.

[0059] In order to verify the advantages and robustness of the present invention in processing heterogeneous and noisy data sets, experiments were conducted at different levels of heterogeneity and in comparison with different heterogeneous algorithms. The results are shown in Tables 2 and 3 below.

[0060] Table 1 Experimental results when combining CIFAR-10, CIFAR-100 and Tiny-imagenet datasets

[0061]

[0062] Table 2 Experimental results of CIFAR-100 dataset with different degrees of heterogeneity

[0063]

[0064] As can be seen from the results in Tables 1 and 2, our method achieves good accuracy for heterogeneous data across different datasets. It can be concluded that the accuracy of this method remains stable across data with varying degrees of heterogeneity. Even increasing the degree of heterogeneity from 3 to 0.1 (a smaller β value indicates a higher degree of heterogeneity) does not significantly affect accuracy. This demonstrates that our method is highly robust for joint learning with heterogeneous data, even at varying degrees of heterogeneity, and has high practical value in practical applications of noisy heterogeneous image classification.

Claims

1. Image classification algorithm based on adaptive contrastive learning combined with federated learning, characterized by: The following steps are involved: Step 1: Apply dataset truncation to each participant's local data. This method not only supports data segmentation in distributed training, but also effectively simulates scenarios with non-independent and identically distributed (Non-IID) data. Step 1: The image data owned by each participant often has distribution differences compared to the data of other participants. By specifying the dataidxs parameter, you can selectively intercept some samples from the dataset, thereby allocating different data subsets to each client, simulating the data distribution differences between clients in distributed training and improving the generalization ability of the model. Steps 1 and 2: To meet the requirements for loading custom datasets, we designed the ImageFolder_custom class, which inherits from DatasetFolder. This class supports loading data from custom image folders and flexibly selects samples through the dataidxs parameter, further enhancing the flexibility and versatility of data preprocessing. Step 2: In terms of image data preprocessing, we introduced channel truncation and image transformation techniques. The truncate_channel method can set certain channels of the image (such as the green and blue channels) to zero, thereby simulating data corruption and enhancing the model's robustness to data loss. In addition, using the transform parameter, we perform augmentation processing (such as random cropping and flipping) and normalization operations on the image data, improving the model's generalization ability. Step 2: Using the truncate_channel method, some channels of the image (such as the green and blue channels) can be set to zero, thereby simulating data corruption and enhancing the model's robustness to data loss. Step 2: Using the transform parameter, we augmented the image data (such as random cropping and flipping) and normalized it, adjusting the pixel value range to [0, 1] or [-1, 1], significantly improving the model's generalization capabilities. Furthermore, using the target_transform parameter, we performed necessary processing on the target labels, such as converting the category labels from strings to integers to ensure data format consistency. Step 3: The dataset is distributed to different participants (clients) according to the specified partitioning strategy (such as non-independent and identically distributed (Non-IID) or independent and identically distributed (IID)). The partitioning strategy is implemented through the partition_data function, which supports the use of Dirichlet distribution to control data heterogeneity. In each iteration, a fixed number of samples with different characteristics are randomly selected as the public dataset to adjust the model alignment knowledge distribution of each participant during the collaborative learning phase, and to initialize the untrained local convolutional neural network model. Step 3.

1. According to the partition parameter, select different data partitioning methods. When partitioning Non-IID data, divide it according to the category label to ensure that the data of each client is non-independent and identically distributed in the category distribution. First initialize the index list idx_k of each category and randomly shuffle it. Use Dirichlet distribution to generate the partition proportions for each category, simulate the non-uniform distribution of data, and distribute samples of each category to different clients according to the proportion. If the amount of data for a client is insufficient, readjust the proportion and redistribute it until the amount of data for each client meets the minimum requirement. Finally, randomly shuffle the sample indexes assigned to each client to ensure the randomness of the data; Step 32: In each local training, randomly select samples with different features from the participating clients, and set the feature size to the same size as the local dataset, and organize them into a three-dimensional tensor; Step 3. Create a local convolutional neural network model, ResNet-50, adapted to the three-dimensional tensor of the feature dimension. The structure is as follows: the input layer is followed by a 7×7 convolutional layer, followed by a ReLU activation function. After the convolutional layer, the network has a max pooling layer for downsampling. Next, the network contains four residual block groups, each group contains multiple residual blocks. Each residual block consists of two 3×3 convolutional layers and a skip connection to alleviate the vanishing gradient problem. Finally, a global average pooling layer is used to compress the feature map into a one-dimensional vector. The classification result is then output through a fully connected layer, and the final category prediction is made using a Softmax classifier. Step 4: An improved loss function combining cross-entropy loss and contrastive loss is used. By integrating the advantages of supervised learning and self-supervised learning, the problems of data heterogeneity and model drift in federated learning are effectively addressed. Contrastive loss enhances the discriminability of the representation space by introducing negative samples (such as representations of other clients or historical global models), forcing the model to learn more generalizable features. By constraining the similarity between local and global representations, the divergence of local updates is suppressed, thereby reducing conflicts during model aggregation. Step 5: Design a dynamic temperature adjustment mechanism to dynamically adjust the temperature parameter based on the gradient variance and the client's personalized characteristics (such as the beta parameter of the Dirichlet distribution). This helps optimize the sample similarity calculation during the contrastive learning process and improves the model's adaptability to different client data. Step 5.1: During the model aggregation phase, the system does not use traditional global model aggregation methods. Instead, it implements a federated learning approach based on adaptive contrastive learning. The core idea of ​​model contrastive learning is to reduce the distance between the representation learned by the local model and the global model, and increase the distance between the representation learned by the local model and the representation learned by the previous local model. This effectively prevents the local model from deviating excessively from the global model, suppresses client drift, and thus improves classification accuracy and model generalization. Step 52: Design a dynamic adaptive temperature parameter, which is dynamically adjusted based on the gradient variance and client heterogeneity, to optimize the sample similarity calculation during the contrastive learning process and improve the model's adaptability to different client data. Step 6: Use the training set to train the local model created in step 3 to obtain an image classification model; Step 7: Use the test set to test the image classification model. An image classification algorithm based on adaptive contrastive learning combined with federated learning, characterized by: As described in step 1, the dataset truncation technique is used for each participant's local data. The system specifies the dataidxs parameter to selectively truncate some samples from the dataset. This algorithm effectively simulates the data distribution differences between clients in distributed training. It not only supports data segmentation in distributed training, but also effectively simulates scenarios with non-independent and identically distributed (Non-IID) data, facilitating the study of the algorithm's performance under complex data distributions. An image classification algorithm based on adaptive contrastive learning combined with federated learning is characterized in that the image classification dataset containing heterogeneous data is preprocessed in step 2, and channel truncation and image conversion techniques are used to ensure the consistency of data format and improve the generalization ability of the model. This step not only optimizes the quality of input data, but also simplifies the computational complexity of the model, making the model between different nodes more unified and efficient; finally, data corruption is simulated to enhance the model's robustness to data missing. This strategy strengthens the management of data heterogeneity and improves the stability and reliability of the model in practical applications. This image classification algorithm, based on adaptive contrastive learning combined with federated learning, features the dataset partitioning method in step 3 and the creation of a public dataset. The partitioning is implemented using the partition_data function and supports the use of a Dirichlet distribution to control data heterogeneity. A convolutional neural network model is created for a three-dimensional tensor adapted to the feature dimension, with an input image size of 32×32×3. First, the input image passes through a 7×7 convolutional layer with 64 output channels, a stride of 2, and padding of 3, resulting in an output size of 16×16×64. Subsequently, the input image passes through a 3×3 max pooling layer with a stride of 2 and padding of 1, bringing the output size to 8×8×64. Next, the input data enters four residual block groups: The first residual block group contains three residual blocks, each of which contains two 3×3 convolutional layers with 64 output channels and a stride of 1, maintaining the output size at 8×8×64. The second residual block group consists of four residual blocks, with 128 output channels and a stride of 2, resulting in an output size of 4×4×128. The third residual block group consists of six residual blocks, with 256 output channels and a stride of 2, resulting in an output size of 2×2×256. The fourth residual block group consists of three residual blocks, with 512 output channels and a stride of 2, resulting in an output size of 1×1×512. Finally, a global average pooling layer averages the feature maps of each channel, outputting a one-dimensional vector of length 512. This vector passes through a fully connected layer, outputting predicted probabilities for 100 categories. Finally, a softmax classifier is used to convert these predicted probabilities into final classification results for each category. This ensures that the output can be directly used to calculate the cross-entropy loss and contrastive loss. This neural network architecture achieves efficient and accurate classification performance. This image classification algorithm, based on adaptive contrastive learning combined with federated learning, features a modified loss function described in step 4 that combines the cross-entropy loss with the contrastive loss. This improvement not only combines the precise guidance advantages of supervised learning but also incorporates the powerful generalization capabilities of self-supervised learning. Specifically, the contrastive loss significantly enhances the discriminability of the representation space by incorporating negative examples, such as representations from other clients or historical global models. This mechanism forces the model to proactively explore more generalizable features during learning, rather than relying solely on labeled data, thereby better adapting to the diversity of different client data. Furthermore, by constraining the similarity between local and global representations, this method effectively suppresses the divergence of local model updates. This constraint ensures that the direction of local model updates is consistent with the global optimization objective, significantly reducing potential conflicts during model aggregation and improving the stability and accuracy of the global model. By implementing these strategies within a federated learning framework, the system significantly improves image classification performance while ensuring data privacy, adapting to heterogeneous data environments from multiple projects, and effectively addressing a range of challenges in image classification. This approach not only enhances the generalization ability of the model, but also ensures the efficiency and reliability of the model in practical applications by optimizing the global learning process of the model and improving the accuracy of local model training. The image classification algorithm based on adaptive contrastive learning combined with federated learning is characterized in that the system described in step five adopts an innovative aggregation strategy that does not rely on the traditional global model. After completing local training, each participating node does not simply aggregate and update to a central model, but instead adopts a federated learning method based on adaptive contrastive learning to learn from each other. This method constrains the alignment of the representation of the local model and the global model in the feature space and corrects the update direction of the local parameters to alleviate the model drift caused by the heterogeneity of client data. In the federated optimization process, a contrast regularization term based on global-local representation consistency is introduced to guide the client model to converge to the global feature space and reduce the negative impact of heterogeneous data on collaborative training. Through this improved method, the performance and reliability of cross-project software image classification are significantly improved, especially the adaptability and robustness when dealing with large-scale distributed data sources. An image classification algorithm based on adaptive contrastive learning combined with federated learning is characterized in that, in step 6, the local model of each node is trained using the training set to obtain an image classification model; The image classification algorithm based on adaptive contrastive learning combined with federated learning is characterized in that the trained federated learning model is tested using the test set as described in step seven.