YOLOv8-based fire detection project for real-time fire alerts and monitoring. Utilizes a custom-trained model for detecting fire in video feeds or images, making it suitable for safety and monitoring applications.
# Installing the packages
!pip install ultralytics
!pip install opencv-python
!pip install ultralytics
!pip install roboflow
from roboflow import Roboflow
from ultralytics import YOLO
from IPython.display import Image
from roboflow import Roboflow
rf = Roboflow(api_key="Hm8mdFJnlkZnoorR3Uy8")
project = rf.workspace("-jwzpw").project("continuous_fire")
dataset = project.version(6).download("yolov8")
!yolo task=detect mode=train model=yolov8n.pt data=/content/continuous_fire-6/data.yaml imgsz=640 epochs=10 batch=10 name=fire_detection_model
!yolo task=detect mode=val model=/content/runs/detect/fire_detection_model/weights/best.pt data=/content/continuous_fire-6/data.yaml
model.predict(source=0, save=True,conf=0.5,show=True)
model.predict(source=r'WhatsApp.mp4', save=False, conf=0.5, show=True) /Replace WhatsApp.mp4 with the path of your file
The following charts were produced after training YOLOv8s with input size 640x640 on the fire dataset for 50 epochs.
P Curve | PR Curve | R Curve |
---|---|---|
![]() |
![]() |
![]() |
The fire detection results were fairly good even though the model was trained only for a few epochs. However, I observed that the trained model tends to predict red emergency light on top of police car as fire. It might be due to the fact that the training dataset contains only a few hundreds of negative samples. We may fix such problem and further improve the performance of the model by adding images with non-labeled fire objects as negative samples.
Ground Truth | Prediction |
---|---|
![]() |
![]() |
![]() |
![]() |
Input | Output |
---|---|
![]() |
![]() |
#Fire Detection project by Ahmed Mohammed Saad El-Raggal #Email: Ahmedxd444@gmail.com #Linkedin: Linkedin #Github: Github