BloomFLv2 is a lightweight, demo-friendly decentralized federated learning platform for edge-style anomaly detection.
This version is tuned for:
- CSV-driven multi-device simulation
- Deep Residual MLP with SiLU activations
- FP16 optimized inference & training paths
- Zero-config mDNS node discovery
- ECIES & PSK encrypted gossip protocol
- Provenance-aware metrics and dashboards
- Sensor + camera feature fusion
Instead of requiring a heavy real-time multi-camera training setup, BloomFLv2 can read device CSV files, simulate multiple edge nodes, train local models per node, exchange model updates through gossip, and visualize convergence, metrics, and node behavior in a modern dashboard.
BloomFLv2 includes:
- FastAPI backend for metrics, simulation control, node history, config, and data inspection
- Next.js frontend dashboard for simulation, gossip visualization, metrics, convergence, and node-level analysis
- lightweight
sensor_anomalytraining path for local/dev systems - CSV generator for seeded multi-device demo data
- camera-augmented anomaly features for OV7670-style capture workflows
- support for richer inference pages such as YOLO and FastSAM
Each CSV file is treated like one edge device.
For a light simulation run:
- each node reads its own CSV shard
- local features are extracted from sensor windows
- optional camera-derived features are fused into the same training sample
- every node trains locally
- nodes exchange model updates through gossip
- the dashboard shows progress, node state, gossip activity, and convergence
This makes it practical to demonstrate federated learning behavior even when you only have one real hardware unit.
Key folders:
api/— FastAPI backend routes and servicesfrontend/— Next.js dashboardsrc/bloomfl/— core training, node, transport, monitoring, and modelssimulation/— local multi-node simulation runnerscripts/— setup and seed-data utilitiesdata/sensor_devices/— CSV input files for the light simulation profiledata/external/uci_occupancy_detection/— bundled UCI occupancy source files used to prepare seeded CSVs
- Deep Residual Classifier: Uses a residual block architecture with SiLU (Sigmoid Linear Unit) activations and LayerNorm for stable convergence on edge data.
- Mixed Precision (FP16): Support for reduced precision computations to minimize memory footprint and increase throughput on edge hardware.
- Adaptive Discovery (mDNS): Automatic node discovery using Multicast DNS, enabling peer-to-peer connectivity without static IP configurations.
- End-to-End Encryption: Secure gossip engine utilizing ECIES for key exchange and PSK-based symmetric encryption for model weight transfers.
- Gossip Impact Analytics: Quantifies the "Gossip Benefit" by comparing local validation ∆ before and after peer synchronization.
- Convergence Forecasting: Real-time linear regression on log-loss to predict the remaining rounds until target accuracy/loss is achieved.
- Anomaly Timeline: Detailed provenance tracking for sensor data, marking 'seeded' vs 'live' samples and providing ground-truth visualization.
- Rich AI Surfaces: Integration with YOLOv12n and FastSAM for multi-modal anomaly confirmation.
The light simulation expects one CSV per device under data/sensor_devices/.
Minimum useful columns:
timestamp,device_id,temperature,humidity,pir,rcwl,anomaly_flagExtended camera-aware columns supported by this repo:
timestamp,device_id,temperature,humidity,pir,rcwl,anomaly_flag,anomaly_label,camera_brightness,camera_motion_score,camera_person_score,camera_capture_fresh,camera_frame_pathNotes:
- older sensor-only CSV files still work
- missing camera fields fall back safely
camera_frame_pathis relative to the sensor CSV directory- one CSV file generally represents one simulated device
From:
C:\d_drive\projects\bloomFLRun:
.\setup.cmd
.\run-dev.cmdThis will:
- create a local Python virtual environment in
.venv - install Python dependencies
- install frontend dependencies
- create
.envfrom.env.exampleif needed - launch backend and frontend in separate PowerShell windows
Default URLs:
- backend:
http://localhost:8000 - backend docs:
http://localhost:8000/docs - frontend:
http://localhost:3000
If you prefer to run things manually:
python -m venv .venv
.\.venv\Scripts\python.exe -m pip install --upgrade pip
.\.venv\Scripts\python.exe -m pip install -r requirements.txt -r api\requirements.txt -e .
npm install --prefix frontendStart backend:
.\.venv\Scripts\python.exe -m uvicorn api.main:app --host 0.0.0.0 --port 8000Start frontend in a second terminal:
cd frontend
$env:NEXT_PUBLIC_API_URL = "http://localhost:8000"
npm run devOption A: use your own hardware-generated CSV files
- place them in
data/sensor_devices/ - keep one file per device, for example:
device-001.csvdevice-002.csvdevice-003.csv
Option B: generate seeded demo data inside the app
- open
http://localhost:3000/data - use the generator controls
- generate multi-device sensor + camera-style demo data
- open
http://localhost:3000/simulation - choose:
- profile:
light - nodes:
3to5 - rounds:
10to30 - transport:
tcp - base port:
50100
- profile:
Useful pages:
/dashboard— overall health, quality, gossip impact/simulation— run control and status/gossip— animated peer-to-peer transfer view/metrics— metrics over time/convergence— convergence and forecast view/nodes— per-node state table/nodes/[nodeId]— detailed node history/data— seeded data generator and anomaly timeline
This repo includes source files from the UCI Occupancy Detection dataset under:
data/external/uci_occupancy_detection/datatraining.txtdata/external/uci_occupancy_detection/datatest.txtdata/external/uci_occupancy_detection/datatest2.txt
You can prepare CSV device files from that dataset with:
.\.venv\Scripts\python.exe scripts\prepare_uci_sensor_seed_data.py --num-devices 5 --rows-per-device 800Windows helpers included in this repo:
setup.cmd/setup.ps1run-dev.cmd/run-dev.ps1
Helpful variants:
.\run-dev.cmd -ApiPort 8001 -FrontendPort 3001.\run-dev.ps1 -Reload.\run-dev.ps1 -InstallIfNeededThe light profile is intentionally optimized for local machines.
It uses:
- CSV-backed sensor anomaly training
- repo-local simulation paths under
.sim/ - short rounds
- lightweight model updates
- loopback networking for local node communication
This is the best mode for:
- demos
- professor presentations
- proof-of-concept runs
- laptops without strong GPU support
The current lightweight CSV path supports camera-derived features and labels such as:
camera_confirmed_intrusioncamera_occupancy_mismatchcamera_motion_hotspotcamera_heat_signatureenvironmental_spike
This is useful when you have a separate collector program that already writes combined sensor and camera data into CSV files.
Common checks:
.\.venv\Scripts\python.exe -m pytest tests\test_second_pass.py -qcd frontend
npm run buildFor many demos, the most reliable workflow is:
- use one real ESP32-based hardware collector as proof of concept
- save real sensor/camera output into CSV
- create additional seeded CSV files to represent more devices
- run BloomFLv2 on those CSVs
- show federated learning and gossip behavior in the dashboard
That keeps the demo honest, reproducible, and much lighter than trying to run a fully live multi-device deployment on one machine.
Run the manual install commands from the setup section above. The Python and frontend dependencies can be installed separately.
Launch with different ports:
.\run-dev.cmd -ApiPort 8001 -FrontendPort 3001That can be valid. A completed run may finish without converging under the configured threshold. The dashboard now distinguishes between:
- still tracking
- not enough evaluation data
- finished but not converged
- converged at a specific round
Use the light profile. That is the intended profile for local/dev/demo use.
- Python
- FastAPI
- Pydantic
- PyTorch
- Next.js
- React
- Recharts
- Flower-compatible local training interfaces
- custom gossip-based peer exchange
MIT