Skip to content

i-anubhav-anand/Fed_learning_flower

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Federated learning Using Flower Framework

This Project is based on the Deep Learning with PyTorch that uses the custom data of Coivd and Normal Patient to predict if the patient is having covid or not.

Introduction

How Flower can be used to build federated learning use cases based on existing machine learning projects.

Project Setup

containing files:

dataset.zip
   |__covid19
        |__ *.jpg (all image files)
   |__normal
         |__ *.jpg (all image files)
 --client.py
 --client2.py
 --covid.py
 --covid_prediction.py
 --server.py
 --README.md
 --requiremtns.txt

Hosting server.py on cloud(EC2) and adding port 8080 in security group.

1. Log into the AWS Management Console.
  1. Scroll down the left navigation panel and choose "Security Group" under "Network & Security".

image

  1. Select the "EC2 Security Group" that needs to be verified.

image

  1. Scroll down the bottom panel and choose "Inbound". Choose "Custom TCP rule" in the dropdown.Then you will be able to change the port to 8080.

image

  1. Click on the "Save" button to make the necessary changes.

image

Now, Connect to your EC2 instance.

Clone the contents of the Repo into this EC2 instance using SSH.

(Note: The ‘.’ at the end of the command is to put the contents of the repository into the current directory)
$ git clone https://github.com/i-anubhav-anand/Fed_learning_flower .

Go to the (Fed_learning_flower) folder and install all the dependencies

    $ pip install -r requirements.txt  

After installation run

    $ python3 server.py

Now that the server is running and waiting for clients, we can start two clients that will participate in the federated learning process. To do so simply open two more terminal windows and run the following commands.

Setting up to run client on your local system

You can simply start the centralized training as described

Start by cloning the example project.

$ git clone https://github.com/i-anubhav-anand/Fed_learning_flower

Create virtual env.

  $ python -m venv venv

Activate virtual env.

$ # Linux/macOS
$ source venv/bin/activate  
$ # Windows
$ venv\Scripts\activate 

Installing all the dependencies

    $ pip install -r requirements.txt.

Before running client.py/client2.py make sure to replace localhost with the public ip address of EC2 instance.

image

which looks like this

image

Start client 1 in the first terminal:

  $ python client.py

Start client 2 in the second terminal:

    $ python client2.py

You are now training a PyTorch-based CNN image classifier on Chest X-ray(Custom Data), federated across two clients.

Snapshot

image

Working Demo

Federated_Learning_Working_Demo.mp4

Single/Batch Prediction

Once after you're done with the training the path weights get saved locally

To run single/Batch Prediction make sure you pass the right arguments

    $ python .\covid_prediction.py  {single/batch}  {location}

where arg1 take 'single' for Single Image Prediction and 'batch' for Batch Prediction arg2 which is the location the image/dir respectively

For Example

For Single Image Prediction

    $ python .\covid_prediction.py single 'dataset\dataset\covid19\person3_bacteria_13.jpeg'

Output

image

For Batch Prediction

    $ python .\covid_prediction.py batch 'dataset\dataset'   

Output

image

Working Demo of Single/Batch Predicition

Single_Batch_Prediction_Working_Demo_Trim.mp4

Dataset Description

Info Count
Train Images 5232
Test Images 1046
Validation Images 525
Classes 2

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages