@sony-ai/fedscene
flwr new @sony-ai/fedsceneFedScene: Federated Camera Fleet Scene Classification
FedScene is a federated learning application built with PyTorch and Flower, simulating a fleet of distributed edge cameras collaboratively learning a shared scene classification model.
Each client represents an independent camera (e.g., retail store, campus building, smart-city intersection) that trains locally on its own data. The global model is aggregated using FedAvg, without sharing raw images.
This application uses:
- ResNet-18 for scene classification
- Flower Datasets (FDS) for partitioning
- A lightweight subset of Places365
- Flower’s Simulation or Deployment Engine
Fetch the App
Install Flower:
pip install flwr
Fetch the app:
flwr new @sony-ai/fedscene
This will create a new directory called fedscene with the following structure:
fedscene ├── fedscene │ ├── __init__.py │ ├── client_app.py # Defines your ClientApp │ ├── server_app.py # Defines your ServerApp │ └── task.py # Defines your model, training and data loading ├── pyproject.toml # Project metadata like dependencies and configs └── README.md
Run the App
You can run your Flower App in both simulation and deployment mode without making changes to the code. If you are starting with Flower, we recommend you using the simulation mode as it requires fewer components to be launched manually. By default, flwr run will make use of the Simulation Engine.
Run with the Simulation Engine
TIP
Check the Simulation Engine documentation to learn more about Flower simulations, how to use more virtual SuperNodes, and how to configure CPU/GPU usage in your ClientApp.
Install the dependencies defined in pyproject.toml as well as the fedscene package.
cd fedscene && pip install -e .
Run with default settings:
flwr run .
You can also override some of the settings for your ClientApp and ServerApp defined in pyproject.toml. For example:
flwr run . --run-config "num-server-rounds=5 learning-rate=0.05"
Run with the Deployment Engine
To run this App using Flower's Deployment Engine we recommend first creating some demo data using Flower Datasets. For example:
# Install Flower datasets pip install "flwr-datasets['vision']" # Create dataset partitions and save them to disk flwr-datasets create dpdl-benchmark/places365-mini-sample-hard --num-partitions 2 --out-dir demo_data
The above command will create two IID partitions of the Places365 dataset and save them in a demo_data directory. Next, you can pass one partition to each of your SuperNodes like this:
flower-supernode \ --insecure \ --superlink <SUPERLINK-FLEET-API> \ --node-config="data-path=/path/to/demo_data/partition_0"
Finally, ensure the environment of each SuperNode has all dependencies installed. Then, launch the run via flwr run but pointing to a SuperLink connection that specifies the SuperLink your SuperNode is connected to:
flwr run . <SUPERLINK-CONNECTION> --stream
TIP
Follow this how-to guide to run the same app in this example but with Flower's Deployment Engine. After that, you might be interested in setting up secure TLS-enabled communications and SuperNode authentication in your federation.