Giter Site home page Giter Site logo

yolov8-fire-and-smoke-detection's Introduction

Fire and Smoke Tracking and Detection using YOLOv8

Introduction

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

The following packages are required to run the code

ultralytics
roboflow
CUDA (if using GPU for acceleration)

Steps to train on custom dataset

  1. Install YOLOv8
  2. CLI Basics
  3. Inference with Pre-trained COCO Model
  4. Roboflow Universe
  5. Preparing a custom dataset
  6. Custom Training
  7. Validate Custom Model
  8. Inference with Custom Model

Custom data

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")

Evaluation

The below chart show the loss , mAP (mean Average Precision) score for the train, test,validation set.

alt text

confusion Matrix :

alt text

Inference

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.

Result

alt text

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.

References

yolov8-fire-and-smoke-detection's People

Contributors

abonia1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

yolov8-fire-and-smoke-detection's Issues

Does not run with custom model

the code does not run with a custom model. it throws this error: ` File "predict.py", line 127, in predict
predictor()
File "/Users/iosph/miniforge3/envs/ml/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "/Users/iosph/Documents/FireDetectionYOLOv8/ultralytics/yolo/engine/predictor.py", line 164, in call
model = self.model if self.done_setup else self.setup(source, model)
File "/Users/iosph/Documents/FireDetectionYOLOv8/ultralytics/yolo/engine/predictor.py", line 121, in setup
model = AutoBackend(model, device=device, dnn=self.args.dnn, fp16=self.args.half)
File "/Users/iosph/Documents/FireDetectionYOLOv8/ultralytics/nn/autobackend.py", line 73, in init
model = attempt_load_weights(weights if isinstance(weights, list) else w,
File "/Users/iosph/Documents/FireDetectionYOLOv8/ultralytics/nn/tasks.py", line 303, in attempt_load_weights
ckpt = torch.load(attempt_download(w), map_location='cpu') # load
File "/Users/iosph/miniforge3/envs/ml/lib/python3.8/site-packages/torch/serialization.py", line 712, in load
return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
File "/Users/iosph/miniforge3/envs/ml/lib/python3.8/site-packages/torch/serialization.py", line 1049, in _load
result = unpickler.load()
File "/Users/iosph/miniforge3/envs/ml/lib/python3.8/site-packages/torch/serialization.py", line 1042, in find_class
return super().find_class(mod_name, name)
AttributeError: Can't get attribute 'IterableSimpleNamespace' on <module 'ultralytics.yolo.utils' from '/Users/iosph/Documents/FireDetectionYOLOv8/ultralytics/yolo/utils/init.py'>

Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.`

In most frames, Bbox cover all frame

After testing the model on the frames of video or images, it was observed that most of the bounding boxes cover most of the width and height of the frame. In other words, the size of the output bounding box is too big.
Is this because of the YOLO 8 algorithm itself or not?

Capture

Pre-trained model?

Interesting repo. How can I try your pre-trained model as the video shows? Can you share it?

Exclude the "default" class?

My detections all have a "default" class that messes with the actual Fire class. Is there any ways to exclude them?

Demo video

Hi @Abonia1
Thank your project
Can you provide me with the original video demo.mp4?
Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.