Blog post

Is There a Flame in the Frame?

Projects
By Nick Bild
Is There a Flame in the Frame?

Fire detection systems play a pivotal role in safeguarding lives, property, and the environment by providing early warning against the outbreak of fires. The scope of the problem is vast, as fires can occur in various settings, including residential buildings, commercial establishments, industrial facilities, and natural landscapes. The devastating impact of fires is evident in the loss of human lives, destruction of property, and the disruption of critical infrastructure. Beyond the immediate physical consequences, fires can also lead to severe financial burdens, increased insurance premiums, and significant economic losses for individuals, businesses, and communities.

In residential settings, fire detection systems are crucial for ensuring the safety of occupants, especially during nighttime when people are most vulnerable and might not be immediately aware of a fire. In commercial and industrial spaces, these systems are essential to protect valuable assets, maintain business continuity, and prevent production downtime. The cost of fire-related incidents goes beyond the destruction of property and often includes emergency response expenses, medical bills, and the expense of rebuilding or replacing structures and equipment.

And with the wildfires that have been raging in Canada this summer and causing air quality issues hundreds of miles away, we are all keenly aware of the need for rapid detection of forest fires. If these blazes are dealt with early, they can be controlled. But once they spread, there is much less that can be done.

Creating synthetic data with NVIDIA Omniverse Replicator

Vision-based fire detectors are particularly promising because they can watch large areas and monitor for signs of a fire. Monitoring large areas with a single sensor can be very cost effective, and it can even make it practical to provide early alerts about wildfires in vast forested regions. Such systems generally rely on machine learning algorithms like object detectors to locate fires, but training these systems can be challenging. For a model to be highly accurate and well-generalized, such that it can work under varying environmental conditions, it must be trained on a very large and diverse dataset.

But sufficiently large and diverse datasets are often hard to come by, and it may be impractical to create that dataset manually. Embedded engineer Shakhizat Nurgaliyev recently decided to build a fire detector of his own but ran into this exact problem. Rather than throwing in the towel, he did some research and found a path forward that would allow him to build a highly accurate fire detection algorithm without tracking down an existing dataset (or becoming an arsonist).

Nurgaliyev came across a tool created by NVIDIA called the Omniverse Replicator. This platform offers photorealistic rendering and dynamic scene creation, enabling the generation of highly realistic scenarios with varying environmental factors such as light, color, background, and more. With just a little bit of configuration, Omniverse Replicator can generate as much synthetic data as one needs to train an accurate machine learning model.

A sample from the synthetic dataset

After generating the data, the Grounding DINO object detector was used to assist in labeling the flames in each frame, which is required before the flame detector can be trained. To keep things simple, Nurgaliyev decided to use Edge Impulse to build the machine learning analysis pipeline to create this device. And since the annotation files that were produced are compatible with Edge Impulse, they were uploaded, along with the original images, to a project in Edge Impulse Studio using the Data Acquisition tool.

This tool automatically splits the data into training and test datasets, and allows one to examine the images to confirm that the labeling is accurate. With the data all squared away, everything was in place to design the impulse. Built using a graphical interface, the impulse specifies exactly how data will be processed, from the moment it comes off the sensor until a prediction is made by the machine learning model.

In this case, the impulse started with a pair of preprocessing steps to reduce the size of the input images, then extract the most informative features from them. These steps not only reduce the amount of computational resources that will be required downstream, but they also make the resulting model more accurate by helping to ignore less important aspects of the data. These features were then forwarded into Edge Impulse’s ground-breaking FOMO™ algorithm that brings real-time object detection to microcontrollers.

A FOMO object detection impulse in Edge Impulse Studio

FOMO was a great choice for the hardware selected by Nurgaliyev, the Arduino Nicla Vision. With a dual-Cortex-M7/M4 processor, 1 MB of RAM, and 2 MB of flash memory, this device is more than powerful enough to run a FOMO object detector, which generally requires less than 200 KB of RAM. Factoring in the built-in camera and the low price tag, the Nicla Vision is an ideal option for large-scale deployments, which is Nurgaliyev’s vision for the future of his fire detector.

After making a few small tweaks to the model hyperparameters, the training process was kicked off. A short time later, training had completed and metrics were presented to help assess how well the model was performing. An average accuracy score of 86.8% was achieved, which is quite good for a proof of concept. The false positive rate could use a bit of improvement before deploying the device in a real-world scenario, but that should be a simple matter of training the model on a bit more data (and with Omniverse Replicator, that is not a problem).

Arduino Nicla Vision

When you have a sufficiently powerful edge computing platform available, there is no reason to have a dependency on cloud computing resources or wireless communications channels, so the model was deployed from Edge Impulse Studio as an OpenMV library. The Nicla Vision could then be programmed with the OpenMV IDE, and as an added bonus, this IDE also allows one to easily test their device. Nurgaliyev ran some experiments by putting flames within view of the camera, and the fire detector was found to do a great job of recognizing it, as would be expected based on the training results.

There is a great write-up describing this project over at Hackster.io that is well worth the read. If you are newer to machine learning, you may be surprised to learn how easy it can be to build a device like this fire detector. But you don’t have to take my word for it — just head over to Edge Impulse Studio and start building your own embedded machine learning models today.


Want to see Edge Impulse in action? Schedule a demo today.

Comments

Subscribe

Are you interested in bringing machine learning intelligence to your devices? We're happy to help.

Subscribe to our newsletter