According to the International Coffee Organization, Brazil is the world's largest coffee producer and this is an important commodity for the country. Identify and treat diseases in the early stages is crucial to an effective production and high quality of the coffee beans.
Generally, the analysis of coffee leaves is made by specialists, but due to similarities and bias that are introduced, the task is complicated to execute and expensive. Small coffee producers don't have access to these specialists which leads to an ineffective production and higher expenses.
By creating a system that can identify and classify diseases, it's possible to increase productivity while lowering the costs.
Data AcquisitionIn this project, a dataset with coffee leaves and custom images taken in a farm in Brazil were used, totalizing more than 15000 images.
- Data Augmentation
To increase the amount of data available to train, Data Augmentation was used. The dataset used keras to do it, and Roboflow was used to the images taken with the board. Saturation, rotation and brightness were changed to create "new" images from the same source.
For training the models, we used the aXeleRate framework in addition to Google Colab. The MobileNet feature extractor with alpha = 0.5 was used. In the end, we got a.kmodel file to be embedded in the board. The workflow of the system is simillar from this project:
Two stages were used to classify the diseases, the first one classifies between: Healthy, Rust, Brown Spots or Sooty Molds. The second stage classifies between: Cercospora, Phoma, Leaf Miner or Red Spider Mite. Initially the image goes to the first model, if this model classifies the image in the "Brown Spots" category it goes to the second model.
In the end, we obtained the confusion matrix for the first and second stage.
And the following classification report:
The Colab script used to train the first model with aXeleRate can be found in this link and for the second model in this link.
Embedding- The Board
Inside the Maix Bit board there's a K210 processor, which is an AI capable dual core 64-bit RISC-V processor, designed for machine vision, it is equipped with a powerful dual core 64 bit RISC-V processor, a KPU, which is a high performance Convolutional Neural Network (CNN) hardware accelerator that allows to run small optimized CNN with up to Real Time performance.
The Maix Bit board costs around $14, and if we compare it with the OpenMV Cam M7 that costs around $65, we could build about 4 systems if we used the Maix Bit rather than the OpenMV Cam.
This study shows the power consumption of the board and compares it with other AI boards such as the Google Coral when running a MobileNetV1 with alpha = 0.75 application.
The final hardware setup looks like this:
- The Firmware
First we need to save our models in the flash memory of the Maix Bit board, to do this we'll use KFlash and we need to create a custom firmware for the board. We will use the MaixPy Firmware Online Compilation to do it.
After you created your .bin file with the firmware you can save it and the models in your board.
To embed those models in our board we'll use the MaixPy IDE, and MicroPython to program.
The first test was made using images:
The second test used real coffee leaves:
We were able to see the performance of the board in some real cases and, as seen in the pictures above, the results were very satisfactory. The system could work better if we used more custom data, that is, more pictures taken in farms with the board itself. Nevertheless, despite the lower accuracy results obtained with the actual coffee leaves, in comparison to the accuracy of the images, the results were pretty good and could be helpful when using in real world applications.
Comments