Giter VIP home page Giter VIP logo

fire-detection-from-images's Introduction

fire-detection-from-images

The purpose of this repo is to demonstrate a fire detection neural net model. In use this model will place a bounding box around any fire in an image.

Best results

Object detection: After experimenting with various model architectures I settled on Yolov5 pytorch model owing to its being SOTA (state of the art), relatively fast to train, and the availability of a well documented and easy to use notebook. After a few hours of experimentation I generated a model of [email protected] of 0.657, Precision of 0.6, Recall of 0.7, trained on 1155 images (337 base images + augmentation).

Classification: I have yet to train my own model, but 95% accuracy is reported using the ResNet50 with the Monk tensorflow library.

Motivation and challenges

Traditional smoke detectors work by detecting the physical presence of smoke particles. However they are prone to false detections (e.g. from toasters) and do not localise the fire particularly well. In these situations a camera solution could complement a traditional detector, in order to improve response times or to provide additional metrics such as the size and location of a fire. With the location and nature of the fire identified, an automated intervention may be possible, e.g. via a sprinkler system or drone. Also data can be sent to fire services to provide otherwise non-existent situational awareness. Particular locations I am interested in are: kitchens & living rooms, garages and outbuildings, and areas where fires might already be present but spreading outside a desired zone e.g. fire pit.

There are a couple of significant challenges & open questions:

  • For fast edge model what is 'best' architecture? Yolo3 is very popular for commecrial applications and can be implemented in keras or pytorch, baseline Yolov5 as it is currently SOTA and has deployment guide to Jetson.
  • Can the architecture be optimised since we are detecting only a single class?
  • Baseline object detection, but is there benefit to classifier or using both? Obj models train on mAP and Recall metrics but for our application bounding box accuracy may not be top priority? However classification models work best on a nice shot containing only the target object but in real life fire scenarios the scene will not be as simple as this scenario.
  • Tensorflow + google ecosystem or Pytorch + NVIDIA/MS? Tensorflow suffers from tf1 legacy
  • Is a single 'super' model preferable, or several specialised models? Typical categories of fire include candle flame, indoor/outdoor, vehicle
  • Gathering or locating a comprehensive, representative and balanced training dataset
  • Handling different viewpoints, different camera manufacturers and settings, and different ambient lighting conditions.
  • Since fires are so bright they can often wash out images and cause other optical disturbances, how can this be compensated for?
  • Since we expect the model will have limitations, how do we make the model results interpretable?

Ideas:

  • Preprocessing images, e.g. to remove background or apply filters
  • Classifying short sequences of video, since the movement of fire is quite characteristic
  • Simulated data, identify any software which can generate realistic fires and add to existing datasets
  • Augmentations to simulate effect of different cameras and exposure settings
  • Identify any relevant guidance/legislation on required accuracy of fire detection techniques

Approach & Tooling

  • Frames will be fed through neural net. On positive detection of fire metrics are extracted. Ignore smoke for MVP. Try various architectures & parameters to establish a 'good' baseline model.
  • Develop a lower accuracy but fast model targeted at RPi and mobile, and a high accuracy model targeted at GPU devices like Jetson. Yolo present both options, yolo4 lite for mobile and yolo5 for GPU. Alternatively there is mobilenet and tf-object-detection-api. Higher accuracy GPU model is priority.
  • Use Google Colab for training and Roboflow for image dataset curation as allows easy export into common formats e.g. tfrecord. Once we get serious can use sagemaker or google equivalent (Deep Learning VM), and weights & biases
  • For cloud serving use Amazon SageMaker, e.g. Serving PyTorch models in production with the Amazon SageMaker native TorchServe integration
  • LabelImg for Labeling

Articles & repos

Datasets

Fire safety references

  • Locate reference covering the different kinds of fires in the home, common scenarios & interventions
  • Safety/accuracy standards for fire detectors, including ROC characteristics

Fires in the home

  • Common causes including cigarettes left smouldering, candles, electrical failures, chip pan fires
  • A large number of factors affect the nature of the fire, primarily the fuel and oxygenation, but also where the fire is, middle of the room/against a wall, thermal capacity of a room, the walls, ambient temperature, humidity, contaminants on the material (dust, oil based products, emollients etc)
  • To put out a fire a number of retardants are considered - water (not on electrical or chip pan), foam, CO2, dry powder
  • In electrical fires the electricity supply should first be isolated
  • Reducing ventillation, e.g. by closing doors, will limit fire
  • Smoke itself is a strong indicator of the nature of the fire
  • Read https://en.m.wikipedia.org/wiki/Fire_triangle and https://en.m.wikipedia.org/wiki/Combustion

Edge deployment

Our end goal of deployment to an edge device (RPi, jetson nano, android or ios) will influence decisions about architecture and other tradeoffs.

Cloud deployment

We want a solution that could also be deployed to the cloud, with minimal changes vs the edge deployment. A couple of options:

  • Deploy as a lambda function - will memory be and performance issue? Scaling sorted and should be quite simple but we end up maintaining some custom code (probably flask)
  • Deploy on a VM with custom code to handle queuing of requests, e.g. Deepstack. Will scaling be an issue? Are custom endpoints preferable?
  • Use torchserve on sagemaker, runs on EC2 instance. Well documented but AWS specific.
  • Use one of the cloud providers that host custom models, e.g. AWS custom labels. Dont know much about this approach, prefer vendor agnostic.

Image preprocessing and augmentation

Roboflow allows up to 3 types of augmentation per dataset, in addition to basic cropping. If we want to experiment with more augmentations we can checkout https://imgaug.readthedocs.io/en/latest/

Metrics

  • mAP, IoU, precision and recall are all explained well here and here
  • [email protected]: the mean Average Precision or correctness of each label taking into account all labels. @0.5 sets a threshold for how much of the predicted bounding box overlaps the original annotation, i.e. "50% overlap"
  • Precision is the accuracy of the positive predictions (TP / TP + FP) or "If you say it's a fire, what percentage of the time is it really a fire?"
  • Recall is the true positive rate (TP / TP + FN) or "If there's a fire in there, what percentage of the time do you find it?"
  • IceVision returns the COCOMetric, specifically the AP at IoU=.50:.05:.95 (primary challenge metric), from here, typically referred to as the "mean average precision" (mAP)

Comments

  • Firenet is a VERY common name for model, do not use

Discussion

fire-detection-from-images's People

Contributors

robmarkcole avatar

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.