Blog post

Seeking a Solution? Leaf It to Edge ML

Projects
By Nick Bild
Seeking a Solution? Leaf It to Edge ML

With all of the recent turmoil — from supply chain issues to a war in Europe — global food security has taken the center stage in world affairs. The World Bank recently reported that 193 million people were acutely food insecure in 2021, which was up sharply from the previous year. Considering current events, this figure is widely expected to climb sharply again this year. Aside from some of the exceptional situations the world has faced in recent times, the longstanding issues impacting crop yields, like plant diseases, have not let up. These problems only serve to further exacerbate the issue of food insecurity.

Some problems are more difficult to address than others, and solutions to a great many problems may be out of our reach entirely. But by focusing on problems that we can help to correct, we each have the potential to make a big impact in the world. Wamiq Raza exemplified this philosophy in building a machine learning-powered device that can detect certain, highly prevalent plant diseases. By detecting these diseases early, they can be dealt with before large crop losses occur. Through widespread adoption of technologies such as Raza’s, the global food supply could be made more secure.

The Sony Spresense hardware

For the prototype device, the powerful Sony Spresense development board was chosen, with a six-core Arm Cortex-M4F processor to handle running the machine learning algorithms. A Spresense camera was also included to give the device the ability to capture images of its environment. These boards were then attached to a DJI Tello quadcopter drone. This simple-to-program drone gives mobility to the hardware, allowing a single device to scan entire fields for signs of plant diseases in a minimal amount of time, and at a minimal cost.

Raza’s plan was to program the drone to autonomously survey a field of crops, and run the captured images through a machine learning classifier to identify angular leaf spot disease and bean rust disease. These diseases plague bean crops, which are one of the world’s most important sources of food. By using this device to send an early alert when diseases are detected, the idea is that there would be time to deal with it before it spreads any further.

Training data samples

Before a classifier can be trained, example data needs to be collected.  Raza tracked down a set of images: 200 from each of the disease states, and 200 more of healthy plant leaves.  The images were all taken in the fields of Uganda by the Makerere AI Lab. This data was uploaded to Edge Impulse Studio, where it was automatically assigned labels and split into training and testing sets.

With the example data all squared away, attention was turned to designing an impulse for processing and classification. A preprocessing block was selected to resize input images and extract the most important features. This was followed by a transfer learning block that makes use of a MobileNetV1 neural network that is optimized for running inferences on small compute platforms. This model was trained with the previously uploaded data, then quantized for optimal performance and minimal model size. Testing the trained model showed that an average classification accuracy of 76% had been achieved, indicating that it was performing well when classifying previously unseen images.

Assessing the accuracy of the trained classifier

The Sony Spresense board is fully supported by Edge Impulse, so there are multiple options for deploying the model to the board. It is possible to download a custom firmware image, for example, that contains the entire machine learning pipeline. After flashing the board with that image, it will be immediately ready to run classifications.  There is also an option to download the model as a self-contained C++ library, which allows it to be incorporated into a larger software project. This would be useful, for example, in integrating the model with a drone control program that sends wireless alerts based on classification results.

Raza noted that it was very simple to get his system up and running with the help of Edge Impulse, even though there are many technical complexities involved in building a drone that can detect plant diseases. To see how he was able to achieve his goal in more detail, take a look at the project documentation page. If you have an idea that just might help to make the world a better place, be sure to look over the public Edge Impulse project as well – it might help get you on your way to making that idea a reality.


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