3.0 KiB
Smoke and Fire YOLO
Ultralytics YOLO training, validation, prediction, and export pipeline for the Smoke-Fire-Detection-YOLO dataset.
Project layout
configs/datasets/smoke_fire.yaml Dataset configuration
models/pretrained/yolo11s.pt Default pretrained model
src/yolo/cli.py Command-line entry point
src/yolo/config.py Training configuration
src/yolo/defaults.py Project defaults
src/yolo/engine.py Train, validate, predict, and export
src/yolo/checkpoints.py Checkpoint discovery and resume support
src/yolo/reporting.py Training result reporting
Setup
uv sync
Commands
Fine-tune from the current best YOLO11s checkpoint:
uv run fire-yolo train
Resume from the newest checkpoint:
uv run fire-yolo train --resume
Validate a trained model:
uv run fire-yolo val --weights runs/detect/<run-name>/weights/best.pt
Run inference:
uv run fire-yolo predict --weights runs/detect/<run-name>/weights/best.pt --source path/to/image-or-video
Export a model:
uv run fire-yolo export --weights runs/detect/<run-name>/weights/best.pt --format onnx
Default training settings
- Model:
runs/detect/smoke_fire_yolo11s_v1-4/weights/best.pt - Dataset:
configs/datasets/smoke_fire.yaml - Epochs: 80
- Image size: 768
- Batch: 24
- Workers: 0
- Optimizer: AdamW
- Initial learning rate: 0.0002
- Mosaic/MixUp: disabled
- Prediction confidence: 0.40
- Checkpoint interval: every 5 epochs
- Output:
runs/detect
Training writes last.pt, best.pt, periodic checkpoints, and best_point.json to the run directory.
Web Detection Service
After training finishes, install the web dependencies and run the integrated frontend and inference API:
uv sync
uv run uvicorn backend.main:app --host 127.0.0.1 --port 8000
Open http://127.0.0.1:8000 to use the fire prevention management platform. It provides a system overview, local-video inspection, alert event handling, a risk register, robot channel status, and effective model settings. The browser plays selected videos locally and sends sequential JPEG frames to POST /api/detect; requests do not overlap.
Management endpoints include GET /api/dashboard, GET /api/events, and PATCH /api/events/{event_id}. Alert events can be marked as pending, acknowledged, or resolved. The current implementation retains the most recent 500 events in process memory, so events are cleared when the API service restarts.
The local .env file contains optional robot settings. Set WECHAT_WEBHOOK_URL for an Enterprise WeChat group robot, FEISHU_WEBHOOK_URL for a Feishu custom group robot, or both. If Feishu signature verification is enabled, also set FEISHU_SECRET. Alerts require three consecutive positive frames by default and use separate 60-second cooldowns for fire and smoke. ALERT_CONFIRM_FRAMES and ALERT_COOLDOWN_SECONDS override these settings. Without a webhook, video detection still works and the UI reports that notifications are disabled.