Here is the implementation of Federated Deep Learning Architecture for object detection using Flask framework and containerized it using Gunicorn server. It has transfer learning on pre-trained MobileNet model which is a lightweight deep neural network with fewer parameters and higher classification accuracy.
For further details, A Demonstration of Smart Doorbell Design Using Federated Deep Learning.
Requirements
- Python 3.7
- tensorflow
- keras
- matplotlib
- Scikit-learn
- OpenCV
- Flask
- Gunicorn
Arrange your Training Datset in the following directory structure:
- Navigate to device1 directory and run Device 1 using
gunicorn --bind localhost:8001 --timeout 600 wsgi1:app
- Navigate to device2 directory and run Device 2 using
gunicorn --bind localhost:8002 --timeout 600 wsgi2:app
- Navigate to main_server directory and run Main Server using
gunicorn --bind localhost:8000 --timeout 600 wsgi3:app
This will start the Gunicorn servers for Device 1 ,Device 2 and Main Server
- Main Server -
http://localhost:8000/
- Device 1 -
http://localhost:8001/
- Device 2 -
http://localhost:8002/
-
First a model is trained locally on the device. Click on the
Model Training (Locally)
button to start model training. This button will sendhttp://localhost:8001/modeltrain
andhttp://localhost:8002/modeltrain
requests respectively to train models locally. -
Once the models are trained, click on
Send Model to Federated Server
button. This will send the client models trained on the local devices to the main server usinghttp://localhost:8001/sendmodel
anhttp://localhost:8001/sendmodel
requests respectively. -
The trained models sent by the local devices are stored on the Main Server. Now click on
Aggregate Local Models
button that sendshttp://localhost:8000/aggregate_models
request to start model aggregation of the locally trained models. -
Now, once the model aggregation is done, click on
Send Aggregated Models to Federated Clients
button that sendshttp://localhost:8000/send_model_clients
request to send the global aggregated model back to the local devices. -
Once the complete iteration is finished go back to step one for the next iteration of model training and aggregation to improve the aggregated model.