Early Detection of Fires in Forest Areas with Artificial Intelligence - Part I

Quito. 2021 Do you know how many hectares burn each year due to forest fires? Did you know that as a result of this many species leave their habitat in search of a new home? Would you believe me if I told you that we can use...

A learning project shared by the community. The article documents its team, methods and results; it does not establish that the prototype is ready for real-world use.

Early Detection of Fires in Forest Areas with Artificial Intelligence - Part I

This archive includes automatic translations. Audio, video and text inside images remain in their original language.

Quito. 2021

Do you know how many hectares are burned each year due to forest fires? Did you know that as a result of this, many species leave their habitat in search of a new home? Would you believe me if I told you that we can use technology, especially Artificial Intelligence, to reduce the impact of forest fires? In this article, we will use Artificial Intelligence to detect fires in forest areas early.

Like you, I was a little skeptical at first, but let me tell you how humans can use technology to stop these attacks against Mother Nature. That is why I invite you to read our idea of ​​how to detect fires from their very early stages in order to stop them and thus avoid major disasters. Can you imagine a world where we can minimize these types of forest fires? Well, here we put almost everything you need to carry out this project and become a defender of Pachamama.

First steps

The idea of the project to detect forest fires through Artificial Intelligence began one afternoon in the workshop we were doing at Saturday AI and with our colleagues: Luis Marcelo Viteri Aguilar, Danilo Josue Erazo Quinaluisa, Jonathan Alejandro Zambrano Mejía and Wilfredo Martel; We decided to face this problem.

General Idea

The idea of the Early Detection of Forest Fires project is to use Artificial Intelligence with the help of a Drone composed of a GPS and a camera to scan forest areas and if a fire is detected, send the alarm to a main server that will be responsible for notifying the firefighters and surrounding communities, informing them with a photo of the sector, the position on a map and the percentage estimate in order to prevent the fire from spreading and destroying the flora and fauna of the sector.

Operation diagram

Problematic

In 2020, more than 5.5 million of hectares were devastated by forest fires worldwide, having a great impact on the wild flora and fauna that inhabited this area.

In Ecuador, in the same year approximately 23.462 hectares and due to the mountainous structure of the places it is difficult for firefighters to arrive on time. The devastating fire devoured everything in its surroundings and it took weeks in the best of cases to mitigate the fire and in the worst of cases months.

Faced with this alarming problem with social and environmental impact, solutions were thought of that would help detect forest fires in time. This is how the idea of fusing Artificial Intelligence (from now on A.I.) with a drone for the early detection of fires in the forest areas of our country emerged. The idea is to train an A.I. model. (detect fire on any surface) that interacts with the drone which will have a camera and a GPS, Therefore, in real time the position of the fire will be known and an alarm will be sent to the firefighters for mitigation.

Execution Phase

To carry out the execution of this great prototype, whose benefits can already be seen from a distance, it was carried out in five phases:

  1. Data collection phase (dataset)
  2. Previous research of Pre-trained A.I. model
  3. Retraining and Validation of the model
  4. Model Deployment
  5. Development of a website to present the Prototype

Before continuing, it is clarified that the integration phase with the drone, the server, notification to the communities and firefighters is pending for the second part of this article.

1. Data collection and model research phase for Image Classification

This phase focused on collecting images of forest fires caused around the world and in our country. It was possible to obtain a total of 250 MB of information which will be used as input for learning our model.

Once the dataset was obtained, as a parallel task, an investigation of A.I. models was carried out. image classifiers and the one we chose due to its effectiveness was Yolo v5. This in turn means that an annotation process has to be carried out that consists of giving the coordinates of the segment to be characterized within an image.

In other words, we will explain what using Yolo v5 implies in our dataset:

1. The segments to be learned must be noted or indicated within the image. In our case they are to put the coordinates where there is fire and in this way the Yolo V5 tool can learn and obtain differentiation patterns. To know more about the Yolo v5 annotation process, it is recommended to read this enlace to clear your doubts.

2. For the annotation process, a very helpful tool called HyperLabel that we find it in enlace.

3. Once the annotations have been obtained, which is basically an xml file that refers to the image with its coordinates, a file for the Yolo v5 format is generated. For this process the github code was followed ai-coodiantor.

With these steps already executed, personalized training with our own dataset is ready.

2. Retraining and Validation of the model

For the training part of the pre-trained model, Google Colab Pro with GPU v100 was used and an estimated time of 12 hours for completion. At the end of the process, an inference model with a .pt extension was obtained as a result of the training. In our case, our file fireModel.pt which will serve as input to infer on test images. Before moving forward, it must be clarified that this model, once it passes all the tests, will be placed on a drone using an Nvidia Jetson TX2 board for real-time processing, where when any sign of a forest fire is detected, the alarm will be sent to institutions such as: Firefighters, surrounding communities, etc.

Below, Illustration 2 shows the code which was used to train the fire detection model.

Yolov5 Training Model

3. Model deployment

Once the fireModel.pt model was obtained, a small application was created in Python using Flask as an application server. That is, in Flask there will be an API that will receive the image to be inferred and the fireModel.pt model will return the result and the section where the fire has been detected in the photo with its respective prediction percentage. Next, Illustration 3 shows the code that performs the previous description.

app.py

Enlace of the code.

Below, Figure 4 shows the testing of the model using Postman.

Inference result of the trained model

4. Development of a website to present the Prototype

For our prototype, a Landing Page was developed that allows loading an image which will be sent to the server for processing so that once the image inference is finished, the results are sent to the client with the positions of where the fire has been detected and the prediction percentage.

The tools used for the website are:

1. Angular 2+

2. AngularMaterial

On the other hand, to paint the results of the inference, canvas was used to later draw the coordinates within the loaded image. It is worth mentioning that, when painting the coordinates, because the dimensions are not the same, it had to be adapted in such a way that they all have the same dimensions. The code is shown in Illustration 5 below.

Coordinate transformation function from yolo v5 to front

Finally, the following illustration shows the Landing Page and the results of the model.

Landing page for demoday presentation

Model inference on a test image

5. Training Result

The results obtained during training are very encouraging despite having worked with a not so large dataset. A prediction percentage of the 71% which is acceptable. In addition, the tests carried out with images with forest fires, the fire could be detected in absolutely all of them. These images contained fires in sunlight, tests would need to be carried out with images containing nighttime forest fires.

confusion matrix

Figure 1 shows the performance of our algorithm with a prediction of the 71% of success.

confusion matrix

Recovery Precision (PR) Curve

The PR curve was used to evaluate the performance of our model. The Figure shows that the AP (Average Precision) is 0.5, a normal precision level to begin with. For general knowledge, if this value is closer to 1 the result will be much better. precision level of our model.

PR curve of the tuned model

Conclusions

  • Greater computational power is required to train models that take more than 12 hours to complete the learning process and have a good percentage of confidence in the prediction.
  • The model has a short response time for inference and this is useful once it is mounted on the drone for forest surveillance.
  • After carrying out several experiments with the model, we see enormous potential that can be exploited for fire detection of all types.

“You never reach the total truth, nor are you ever totally away from it.” Aristotle (384 AC-322 AC)

Repository

In the following repository you will find the code used to develop that application: https://github.com/SaturdaysAI/Projects/tree/master/Quito/2021/deteccion-temprana-de-incendios\_main

More artificial intelligence!

The mission of Saturdays.ai is to make artificial intelligence more accessible (#ai4all) through intensive courses and programs where projects for good are carried out (#ai4good).

Explore our AI master’s programme at https://saturdays.ai/master-ia-online/

If you want to learn more about artificial intelligence join our community at community.saturdays.ai or visit us on our website www.saturdays.ai Join us! Saturdays.AI

WRITTEN BY

Wilfredo Martel

I am a very curious and sometimes an intrepid person. I love learning and build new things.

Saturdays.AI

Saturdays.AI

Saturdays.AI is an impact-focused organization on a mission to empower diverse individuals to learn Artificial Intelligence in a collaborative and project-based way, beyond the conventional path of traditional education.

FROM CURIOSITY TO PRACTICE

Your next step starts here.

Put an idea into practice or find people to continue learning with.

Receive new stories in your RSS reader ↗

A history of the Saturdays.AI community. Originally published on Nov 19, 2021.

← More community stories