/Vit_FL

Primary LanguagePython

FedVit is a transformer based pipeline for federated learning research!

Quick Start 🚀

We provide an end-to-end example for users to start running a medical vit!.

Step 1. Installation📚

First of all, users need to clone the source code and install the required packages (we suggest python version >= 3.9).

git clone https://github.com/erfandarzi/Vit_FL.git
cd Vit_FL

Use Conda

We recommend using a new virtual environment to install Medscale:

conda create -n Vit_FL python=3.9
conda activate Vit_FL

If your backend is torch, please install torch in advance (torch-get-started). For example, if your cuda version is 11.3 please execute the following command:

conda install -y pytorch=1.10.1 torchvision=0.11.2 torchaudio=0.10.1 torchtext=0.11.1 cudatoolkit=11.3 -c pytorch -c conda-forge

For users with Apple M1 chips💻:

conda install pytorch torchvision torchaudio -c pytorch

Finally, after the backend is installed, you can install our repository from source:

From source
pip install .

Now, you have successfully installed the minimal version of our repository. (Optinal)

Example Usage: Federated lung cancer classification

medscale-logo

Downloading Lung cancer dataset📋

You can download lung cancer dataset from kaggle and put it in data/lung directory.

Running training script

To run a federated learning example with FedOPT algorithm, for unbalanced dataset run:

python medscale/main.py --cfg scripts/my_configs/FedOPT_Lung_cancer.yaml

All adjustable parameters can be found in the second cell. Careful with the BATCH_SIZE, as we are using it to parallelize head and time chunk calculations.

License

Our work is under MIT license. Credits to Federated Scope for their amazing pipeline.