Coder Social home page Coder Social logo

cap-ntu / fedreid Goto Github PK

View Code? Open in Web Editor NEW
93.0 6.0 19.0 361 KB

Implementation of Federated Learning to Person Re-identification (Code for ACMMM 2020 paper)

License: MIT License

Python 100.00%
federated-learning person-reidentification federated-learning-application federated-learning-algorithm

fedreid's Introduction

FedReID

Code for ACMMM 2020 oral paper - Performance Optimization for Federated Person Re-identification via Benchmark Analysis

Personal re-identification is an important computer vision task, but its development is constrained by the increasing privacy concerns. Federated learning is a privacy-preserving machine learning technique that learns a shared model across decentralized clients. In this work, we implement federated learning to person re-identification (FedReID) and optimize its performance affected by statistical heterogeneity in the real-world scenario.

Algorithm: Federated Partial Averaging (FedPav)

Prerequisite

  • Install the libraries listed in requirements.txt
    pip install -r requirements.txt
    

Datasets preparation

πŸŽ‰ We are now releasing the processed datasets. (April, 2022)

Please email us (cc this email in case it is filtered as spam) to request for the datasets with:

  1. A short self-introduction.
  2. The purposes of using these datasets.

⚠️ Further distribution of the datasets are prohibited.

We use 9 popular ReID datasets for the benchmark.

Dataset Preprocess From Scratch

You can obtain the datasets from awesome-reid-dataset

Dataset folder structure after preprocessing is provided here

You can follow the following steps to preprocess datasets:

  1. Download all datasets to data_preprocess/data folder.
  2. We provide the Json files for spliting the small datasets. (We haven't officially release the split.json files. Please send an email with short introduction to request for them.)
  3. Run the following script to prepare all datasets:
    python prepare_all_datasets.py
    
  4. Move the data folder to the root directory.
    move data_preprocess/data ./
    
  5. For federated-by-identity scenario:
    python split_id_data.py
    
  6. For federated-by-camera scenario:
    python split_camera_data.py
    
  7. For merging all datasets to do merge training, you can use rename_dataset.py and mix_datasets.py.

Run the experiments

Remember to save the log file for later use!

  • Run Federated Partial Averaging (FedPav):
    python main.py
    
  • Run FedPav with knowledge distillation (KD):
    python main.py --kd --regularization
    
  • Run FedPav with cosine distance weight (CDW):
    python main.py --cdw
    
  • Run FedPav with knowledge distillation and cosine distance weight:
    python main.py --cdw --kd --regularization
    

Citation

@inproceedings{zhuang2020performance,
  title={Performance Optimization of Federated Person Re-identification via Benchmark Analysis},
  author={Zhuang, Weiming and Wen, Yonggang and Zhang, Xuesen and Gan, Xin and Yin, Daiying and Zhou, Dongzhan and Zhang, Shuai and Yi, Shuai},
  booktitle={Proceedings of the 28th ACM International Conference on Multimedia},
  pages={955--963},
  year={2020}
}

@article{zhuang2023fedreid,
  title={Optimizing performance of federated person re-identification: Benchmarking and analysis},
  author={Zhuang, Weiming and Gan, Xin and Wen, Yonggang and Zhang, Shuai},
  journal={ACM Transactions on Multimedia Computing, Communications and Applications},
  volume={19},
  number={1s},
  pages={1--18},
  year={2023},
  publisher={ACM New York, NY}
}

Maintainers

  • Weiming Zhuang, Nanyang Technological University. :octocat:
  • Xin Gan, Nanyang Technological University. :octocat:
  • Daiying Yin, Nanyang Technological University. (Contributor)

fedreid's People

Contributors

dependabot[bot] avatar weimingwill avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

fedreid's Issues

About split.json

I cannot find the split.json in small dataset, if i need to write a new one and how to do it?
Thanks

Using torchreid data loading, I have lower result

Hello,

The code is really clear and easy to read, thanks for sharing!

However, due to the dataset process is not based on the original version(the img name in meta.json is different at least) which makes it a bit hard to follow, I use different data loading processes implemented based on torchreid. And the result I achieve is lower than reported in the paper(around 10 percent on average). I just wonder if the data loading can result in the degradation of the performance.

Thanks for your reply,

Question About the function `cdw_feature_distance`?

Hi!

The work on this article is really great! I hope to learn something from FedReID.

But when read the code, the function cdw_feature_distance is confusing. Although I know Python can do it, why calculate the mean of distance in for loop.

FedReID/optimization.py

Lines 9 to 25 in b63d990

def cdw_feature_distance(self, old_model, old_classifier, new_model):
"""cosine distance weight (cdw): calculate feature distance of
the features of a batch of data by cosine distance.
"""
old_model=old_model.to(self.device)
old_classifier=old_classifier.to(self.device)
for data in self.train_loader:
inputs, _ = data
inputs=inputs.to(self.device)
with torch.no_grad():
old_out = old_classifier(old_model(inputs))
new_out = new_model(inputs)
distance = 1 - torch.cosine_similarity(old_out, new_out)
return torch.mean(distance)

Here's what I think

         distance_lst = []
         for data in self.train_loader: 
             # do something
             distance = 1 - torch.cosine_similarity(old_out, new_out) 
             distance_lst.append(torch.mean(distance))
         return torch.mean(distance_lst)

Your reply will be greatly appreciated.

problem from Prerequisite

hello,when I tried pip install -r requirements.txt
there is an error showed up
err
err1
err2
err3
err4
err5
err6
err7
is there any ways to solve it ?

Split.json File issue

How can I get Json File actually I need it for my research work. Kindly let me know if you can help me

Some confusion in your paper

Thanks for your great job, I am work on federated leraning now. In your paper, in Table 2, the performance comparison of federated-by-camera scenario, federated-by-identity-scenario and local training. My confusion is:
Why the performance in federated-by-identity is better than that in local training on the CUHK03-NP but worse in Market-1501. I cannot found some anlysis in your paper.

Federated by camera

Hi,
Thank you for the great work,
How can we start a training on a single dataset in the federated-by-camera scenario ?
Regards

FileNotFoundError

While running the command "python prepare_all_datasets.py" ,I met a bug that FileNotFoundError: [Errno 2] No such file or directory: 'data/cuhk02\meta.json''. And I can't find the file in the repository, could you please help me? Thanks very much!

Apply for the processed datasets.

Hello.

Thank you for your wonderful paper and code work, and deeply express my admiration.

Recently, I am very interested in your work. However, I do not have the data set processed in the paper. Can you provide the application process of applying for preprocessed datasets? (the original application link has expired)

I use these datasets to run some comparative experiments and reproduce the work of this paper.

Split.json

We are trying to get close to the experiment, but the file "split.json" can't found in the right place. Is that something wrong with it the original code?

FileNotFoundError: [Errno 2] No such file or directory: 'data/cuhk02/pytorch/train'

Hello, I am a graduate student implementing FedReID.
I already got zipped datasets, have a split.json from my colleague who already sent you a mail.

I am in a situation fail to implement main.py.

The reason is "FileNotFoundError: [Errno 2] No such file or directory: 'data/cuhk02/pytorch/train'".

I check that from the cuhk02.zip file, for cuhk02/pytorch, there was only the train_all folder and img.json.

Plese inform me the way how to create pytorch/train for the data/cuhk02.

Thanks.

Log file

How do we generate log files for this and
In what format

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.