This repository contains the full implementation of the experiments described in the article:
“Collaborative Traffic Event Recognition with Federated Learning: A Blockchain-Oriented Framework.”
It includes:
- Centralized training code (baseline)
- Federated Learning experiments using Flower (FLwr)
- A Dockerized environment with GPU support
- Scripts to run, manage, and connect to containers
- Configuration files for running multi-client FL experiments
├── centralised/ # Centralized training experiments
│ ├── entrenamiento.py # Main training script
│ └── ...
├── fl-blockchain/ # Flower Federated Learning project
│ ├── pyproject.toml # FL client/server config & experiment parameters
│ ├── ...
├── Dockerfile # GPU-enabled Docker image
├── run.sh # Script to launch a new Docker container
├── connect.sh # Script to connect to an existing container
└── README.md
This environment uses a GPU-enabled Docker configuration.
To build the Docker image, run:
docker build --build-arg USERNAME=$(whoami)-docker \
--build-arg USER_UID=$(id -u) \
-t <image_name>:latest .Replace:
- <image_name> → name of your image (e.g., flblockchain)
Use the provided script:
./run.sh <gpu_device> <container_name> <image_name>Examples:
Use a specific GPU
./run.sh 4090 mycontainer flblockchain
# In our setup we have both NVIDIA RTX 4090 and NVIDIA TITAN so you should adjust the `run.sh` file to meet your set up Use all GPUs (recommended for servers with 2+ GPUs)
./run.sh all mycontainer flblockchainIf the container is already running:
./connect.sh <container_name>Example:
./connect.sh mycontainerAfter building the Docker image, Flower requires an update to your ~/.bashrc.
Inside the running container, run:
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrcThis ensures Flower commands and Python local binaries work correctly.
The centralized baseline code lives in the centralised directory.
Move to that folder:
cd centralisedThen run the training:
python3 entrenamiento.pyThis will execute the centralized CNN model used as a baseline in the article.
The fl-blockchain directory contains the complete Flower project.
Navigate to the folder:
cd fl-blockchainTo run the FL experiments, follow Flower’s official deployment guide: 👉 Flower Documentation
Important notes:
- The number of clients, rounds, FL parameters, and experiment variables are set in:
fl-blockchain/pyproject.toml- Changing the number of clients in
pyproject.tomlmust match the number of worker services you deploy using Flower. - You may launch clients and server in separate terminals inside the Docker environment (or separate containers, depending on your setup).
All dependencies are already baked into the Docker image.
Key frameworks include:
- Flower (FLwr)
- TensorFlow 2.19
- Keras
- Docker + NVIDIA Container Toolkit
- Python 3.10
- GPU acceleration (CUDA)
Contributions, pull requests, and issue reports are welcome. Please feel free to extend or adapt the FL experiments.
This work was supported by:
- 🇪🇸 Spanish Research Agency (AEI), Project Serverless4HPC (PID2023-152804OB-I00)
- 🇪🇺 Generalitat Valenciana, CIACIF/2022/176, co-funded by European Social Fund Plus (ESF+)
For technical issues or collaboration proposals, this are the authors contact information:
Tamai Ramírez-Gordillo 📧 tamai.ramirez@ua.es
Francisco A. Pujol 📧 fpujol@ua.es
Adriana Morejón 📧 adriana.morejon@ua.es
Higinio Mora 📧 hmora@ua.es
🏫 University of Alicante
🌐 https://www.cloudlab.ua.es