This repository contains the code for tracking and detecting fires and smokes in real-time video using YOLOv8. The project uses a pre-trained YOLOv8 model to identify the presence of fire and smoke in a given video frame and track it through subsequent frames.
demo.mp4
ultralytics
roboflow
CUDA (if using GPU for acceleration)
- Install YOLOv8
- CLI Basics
- Inference with Pre-trained COCO Model
- Roboflow Universe
- Preparing a custom dataset
- Custom Training
- Validate Custom Model
- Inference with Custom Model
Used roboflow to annotate fire and smoke images. Sample notebook show how we can add the Roboflow workflow project using API to download the annotated dataset to train the model. Use the below code to download the datset:
from roboflow import Roboflow
rf = Roboflow(api_key="xxxxxxxxxxxxxxxx")
project = rf.workspace("custom-thxhn").project("fire-wrpgm")
dataset = project.version(8).download("yolov8")
The below chart show the loss , mAP (mean Average Precision) score for the train, test,validation set.
Run the model using below command:
!yolo task=detect mode=predict model=<path to weight file> conf=0.25 source=<path to source image or video> save=True
The --source argument is required to specify the path to the input video. the above command save your weight in run/predict, which will contain the annotated frames with fire and smoke detections.
The project can detect fire and smoke in real-time video with high accuracy. The detection and tracking performance can be improved by fine-tuning the YOLOv8 model on a custom dataset. It can be used as a starting point for more advanced projects and can be easily integrated into a larger system for fire and smoke monitoring.