This project showcases the application of Federated Learning using Flower to train a Convolutional Neural Network (CNN) for yoga pose classification. The model is trained on distributed datasets across multiple clients, enabling collaborative learning while preserving data privacy.
-
Python 3.x
-
TensorFlow
-
Flower
-
Scikit-learn
-
Pillow
-
Streamlit (for running the demo)
-
data/Resized_images1/
: Contains the training data for clients, organized into class folders. -
data/ImageFolder/
: Contains test images for the demo. -
client1.py
andclient2.py
: Flower client scripts that load and preprocess the data, define the model architecture, and participate in the federated learning process. -
server.py
: Flower server script that coordinates the federated learning process and saves the aggregated model weights after each round. -
test.py
: A Streamlit app for testing the trained model on new images. -
README.md
: This file.
pip install -r requirements.txt
python server.py <server_port>
Replace <server_port> with the desired port number for the server.
Open two separate terminal windows and run the following commands in each window:
python client1.py <server_port>
python client2.py <server_port>
Replace <server_port> with the same port number used for the server. This will start the federated learning process, with the clients training the model on their local data and sending updates to the server after each round.
After the federated learning process is complete, you can test the trained model using the Streamlit app:
streamlit run test.py
This will open a web interface where you can upload an image, and the app will classify the yoga pose.
- To use your own dataset, replace the data/Resized_images1/ folder with your own data, organized into class folders.
- Modify the client1.py and client2.py scripts to adjust the model architecture, hyperparameters, or data preprocessing steps as needed.
- Customize the server.py script to change the federated learning strategy or other server configurations.
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
This project is licensed under the MIT License.