Logging Illegal Logging with ML

The global timber market grew to almost one trillion dollars in 2022, and with a compound annual growth rate of 10%, the industry is growing very rapidly. For such a large and advanced industry, you may be surprised to learn that as much as 30% of the global supply of timber is harvested by illegal logging activities, according to the UN Environment Programme. In tropical countries, the percentage of timber harvested illegally is as high as 90%. This massive amount of illegal logging activity has a negative impact on the environment, and the 80% of the world’s land-based biodiversity that call forests their home. It also creates problems for law-abiding timber companies that face unfair competition from illegal loggers that can undercut them.

Catching illegal loggers is notoriously difficult due to the vastness of forested areas — many areas are remote and hard to reach. Given these factors, traditional methods of detecting illegal operations, like ground patrols, are not very effective. The area that needs to be continually monitored is simply too large. To address this problem, satellite imagery is sometimes used to inspect large regions. This solution does not come without its drawbacks, however. Acquiring satellite imagery can be expensive and it is time consuming to analyze the data.

Low-cost hardware for machine learning on the edge

What is needed is a distributed system that can automatically detect illegal logging activities throughout a vast forested region. It would also need to be cost effective so that it could be deployed in the developing world, where the problem is especially prevalent.  The machine learning wizards over at Zalmotek have recently designed a proof of concept device that may fit the bill perfectly. Using an inexpensive development board, they have created a system that can recognize the sounds of illegal logging and send an SMS message to raise an alarm when it is detected.

The team wanted to be able to detect the various types of sounds that can be associated with illegal logging, and under differing conditions, so a machine learning classifier was selected for the job. The Syntiant TinyML Board was chosen to run this algorithm because of its Microchip SAM D21 Cortex-M0+ 32-bit low-power Arm processor, 32 KB of SRAM, and Neural Decision Processor that accelerates machine learning algorithm execution. Using Edge Impulse Studio allowed Zalmotek to design an algorithm that was highly optimized for execution on this edge computing platform. The TinyML Board also comes standard with a highly sensitive onboard microphone that can be used to collect audio samples. An ESP32 microcontroller and a SIM800L module were included in the build to give the device the ability to send SMS messages when suspicious activities are detected. All of the components are highly energy efficient and can be powered by a rechargeable Li-Ion battery.

Preparing the uploaded training data

Before building a machine learning model, the team needed to create a training dataset for it to learn from. For the initial version of the device, the decision was made to detect the sound of chainsaws. Since this type of data is a bit difficult to collect, a publicly available dataset was located and uploaded to Edge Impulse Studio using the data acquisition tool. Samples were uploaded for both a chainsaw class and a normal background noise class. Audio clips for both classes were split into one second segments to make them consistent. A total of approximately 42 minutes of audio data was supplied, which was automatically split into training and test sets.

With the hardware design and data collection complete, it was time to build the machine learning classification pipeline. The impulse started with a step that splits audio samples into windows of precisely 968 milliseconds, which is required by the Neural Decision Processor. These windows of audio data were then fed into a Audio (Syntiant) preprocessing step that computes log Mel-filterbank energy features from the audio signal. Finally, these features are passed into a neural network classifier that is designed to tell the difference between the sound of a chainsaw, and normal background noises.

The training results and clustering of data samples

Before kicking off the training process, the Feature Explorer tool was used to see how well the features of the data are separated between the classes. In this case, everything clustered as would be hoped, but If there were outliers, the Feature Explorer would enable you to track it back to the sample it originated from by just clicking on the data item. But since everything looked good, the hyperparameters of the neural network were adjusted, then training was started with the click of a button. After training finished, the average training accuracy was reported as being 100% — this is not entirely unexpected given how well the data clustered, but it still can be a sign of model overfitting, so the more stringent model testing tool was used as a secondary validation. This test showed an average classification accuracy rate of 99.84%, so with that excellent result, it was time to deploy the Edge Impulse pipeline to the physical device hardware.

The deployment tool in Edge Impulse Studio was used to create an Arduino IDE-compatible library that contained the entire machine learning analysis pipeline. A small tweak was made to the code to put a signal on a GPIO pin when the sound of a chainsaw was detected. This in turn triggered the ESP32 microcontroller to send an SMS message via the SIM800L module. The hardware was all housed inside of a fake stone with a cavity in the middle. This served to not only protect the hardware from the elements, but also camouflage it from illegal loggers that may want to destroy it.

Camouflaging the device in a fake stone

Zalmotek hopes that their proof of concept inspires others to build large networks of similar devices that can monitor forests for signs of illegal logging. The team has provided extensive documentation to help anyone that is interested create their own version. They have even made their machine learning pipeline and training dataset available, so be sure to take advantage of that as you begin designing the perfect tool for your own needs.


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

Subscribe

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

Subscribe to our newsletter