Early Detection of Fires in Forest Areas with Artificial Intelligence - Part I
A Quito team develops a YOLOv5 prototype to detect fire in images and explores future drone integration.
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.

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.
I was sceptical at first too. But the idea of spotting signs of fire before it spreads encouraged us to explore what AI could contribute. Here we share our prototype’s development, results and remaining work. We hope it inspires you to become a defender of Pachamama.
First steps
The idea emerged one afternoon during a Saturdays.AI workshop. Luis Marcelo Viteri Aguilar, Danilo Josue Erazo Quinaluisa, Jonathan Alejandro Zambrano Mejía and Wilfredo Martel decided to tackle early wildfire detection.
General Idea
The proposal combines an AI model with a drone equipped with GPS and a camera. The drone would survey forest areas and send an alert to a server when it detected signs of fire. The server would share the image, location and model score with firefighters and nearby communities to support an early response.

Operation diagram
The problem
Wildfires damage ecosystems and displace many species. The scale of this problem motivated our early-detection project.
In Ecuador, mountainous terrain can make it difficult for emergency teams to reach affected areas. Earlier detection of signs of fire could help them organise a response.
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
We organised prototype development into five phases:
- Data collection phase (dataset)
- Research into pretrained AI models
- Retraining and Validation of the model
- Model Deployment
- 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.
Alongside image collection, we researched object detection models and selected Yolo v5. Training it required annotating fire regions with bounding boxes in each image.
In other words, we will explain what using Yolo v5 implies in our dataset:
1. Mark the regions the model should learn to detect. In our case, this means identifying the coordinates of fire regions so YOLOv5 can learn relevant visual patterns. For more on the annotation process, see this link for details.
2. We used an annotation tool called HyperLabel available through this link.
3. Once the annotations were ready as XML files containing image coordinates, we converted them into YOLOv5 format using the GitHub code from ai-coodiantor.
With images and annotations ready, we could train the model on our own dataset.
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 was used to run inference on test images. The next planned step, after further testing, was to deploy it on an Nvidia Jetson TX2 board aboard a drone and send alerts to firefighters and nearby communities.
Below, Illustration 2 shows the code which was used to train the fire detection model.

Yolov5 Training Model
3. Model deployment
We built a small Python application using Flask to serve the fireModel.pt model. Its API receives an image and returns detected fire regions and their confidence scores. Figure 3 shows the implementation.
app.py

Link to 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
We built a landing page where users can upload an image for server-side processing. Once inference finishes, the page displays detected fire regions and their confidence scores.
The tools used for the website are:
1. Angular 2+
2. Angular Material
We used canvas to draw bounding boxes over the uploaded image. Because its display size could differ from the original image size, we scaled the coordinates accordingly. Figure 5 shows the code.

Function for mapping YOLOv5 coordinates to the interface
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
Initial tests were promising for a small dataset. The team reported a result of 71% in the evaluation shown. We detected fire in all daytime fire images in the described test, but still needed to test night-time images and a wider range of situations, including images without fire.
Confusion matrix
Figure 1 shows the performance of our algorithm with a prediction of the 71% of success.

Confusion matrix
Precision–recall (PR) curve
The precision–recall curve summarises the trade-off between detection precision and the proportion of cases found. The project material reports an AP (average precision) of 0.5. This initial result must be interpreted alongside the evaluation dataset and the criterion used to count a detection as correct.

PR curve of the tuned model
Conclusions
- More computing resources would allow us to explore additional configurations and training runs. They do not guarantee better results on their own; improvements must be verified through suitable evaluation.
- Observed inference times were short, which is promising for drone deployment but still needs testing on the intended hardware.
- The experiments encourage further work on fire detection, with broader data and testing before any operational use.
“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!
Saturdays.AI makes AI more accessible through shared learning and projects with a social purpose. Our motto is AI4ALL IS AI4GOOD.
Meet the Saturdays.AI community
Written by
Wilfredo Martel
I am a very curious and sometimes adventurous person. I love learning and building new things.
Saturdays.AI
Saturdays.AI is an open community for learning artificial intelligence, collaborating and building projects with social impact.
Article references
A story from the Saturdays.AI community. Originally published on Nov 19, 2021.
← More community stories



