Contributing¶
Thanks for helping make construction sites safer. Bug reports, feedback from real sites, dataset ideas, docs fixes and code are all welcome.
Development setup¶
git clone https://github.com/VoxDroid/ppe-guard.git
cd ppe-guard
python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
# Pick the PyTorch build for your machine first (https://pytorch.org/get-started/locally/), e.g.
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu128 # NVIDIA GPU
# pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu # CPU only
pip install -e ".[dev,e2e,docs]"
playwright install chromium # for the browser tests
ppe-guard doctor
Run the dashboard against a scratch data folder while you work:
The dashboard is plain HTML, CSS and JavaScript modules in src/ppe_guard/server/static/, with
no build step: edit and reload.
Before opening a pull request¶
ruff check src tests scripts # lint
pytest --ignore=tests/e2e # unit and API tests: CPU only, no model weights needed
pytest tests/e2e # browser tests (Playwright + Chromium)
python scripts/gen_reference.py # if you changed CLI options or settings
mkdocs serve # preview the docs at http://127.0.0.1:8000
- Keep pull requests focused: one fix or feature each.
- Add or update tests for behaviour changes.
tests/test_compliance.pyandtests/test_zones.pyshow how to drive the compliance engine with synthetic detections and a fake clock;tests/helpers.pyhas a fake detector and a synthetic video maker for end-to-end tests. - Update the docs in
docs/andCHANGELOG.mdwhen you change user-facing behaviour.docs/reference/cli.mdanddocs/reference/configuration.mdare generated; CI fails if they are stale. - Don't commit datasets, model weights, videos or anything under
data/,runs/ormodels/.
Where things live¶
| Path | What it is |
|---|---|
src/ppe_guard/compliance.py |
Per-worker PPE association, zones, temporal smoothing and the violation lifecycle |
src/ppe_guard/detector.py |
YOLO + tracker wrapper and frame annotation |
src/ppe_guard/camera.py |
Per-camera capture and processing threads, snapshots and clips |
src/ppe_guard/storage.py |
SQLite: violations, snapshots, clips, worker-time and analytics |
src/ppe_guard/analysis.py |
Uploaded photo and video analysis |
src/ppe_guard/auth.py |
Password, sessions and API tokens |
src/ppe_guard/video.py |
Video writing with codec fallback, clip recording |
src/ppe_guard/alerts.py |
Webhook alerts |
src/ppe_guard/server/ |
FastAPI app, routes and the dashboard (static/) |
src/ppe_guard/cli.py |
The ppe-guard command |
docs/ |
The MkDocs site, including the browser demo in docs/demo/ |
training/ |
Dataset config, the original notebook and published training results |
scripts/ |
gen_reference.py (docs) and stress.py (load test) |
Training improvements¶
If you train a better model, open an issue or PR with:
- the exact
ppe-guard train ...command (or notebook changes), ppe-guard val --split valand--split testoutput,results.csvand the confusion matrix from the run.
Please report test-split numbers. Validation numbers alone flatter a model that was selected on them.
Load testing¶
scripts/stress.py starts a server with many cameras, a large database, API clients, stream
viewers and WebSocket clients, and reports frame rates, latencies and memory: