Fire Segmentation
Upload a photo, or pick one of 50 samples, and the app highlights the fire, shows how much of the image is on fire, and lets you download the mask. A U-Net running on CPU from a 23 MB ONNX file.
- Fields
- AI / ML
- Stack
- Python
- PyTorch
- U-Net
- ONNX Runtime
- Streamlit
- VPS

01 / Problem
The first model (v1) was trained on grayscale video frames with no fire-free examples, so it learned that anything bright is fire and flagged sunsets, lamps and bright skies.
02 / How it works
- Upload or pick a photo.
- The image is resized and normalised.
- The U-Net gives every pixel a fire probability.
- Pixels above the threshold become the fire mask.
- The app shows the overlay and how much of the image is on fire.
03 / Tech & why
- Hard negatives in the data
- 2,683 video frames plus 226 BoWFire photos (sunsets, lamps) and 320 fire-free photos, so the model learns what is not fire.
- PyTorch U-Net + EfficientNet-B0 encoder
- RGB input and an ImageNet-pretrained encoder (6.3M parameters) instead of grayscale, so colour helps tell fire from bright light.
- Whole-video holdout
- Entire videos stay out of training, so near-duplicate frames cannot leak into validation.
- ONNX Runtime + Streamlit
- The app needs no deep-learning framework and runs on CPU; the same app is on Streamlit Community Cloud and on my VPS (fire.farisznafis.my.id).
04 / Results
- Fire IoU on unseen photos: 0.18 → 0.81.
- False alarms on fire-free photos: 58% → 0%.
05 / Evaluation
v1 vs v2 on unseen data
- Fire IoU (BoWFire)
- 0.18 → 0.81
- Precision / recall
- 0.28 / 0.32 → 0.92 / 0.88
- False alarms, fire-free photos
- 58% → 0%
- Model size
- 23 MB ONNX, CPU only