Object Detection Example in Agriculture: Corn Kernel Calculation
Motivation: How Farm Automation Can Help Grow the Business
More and more industries are undergoing digital transformation and seeing substantial results from the adoption of modern technologies. Agriculture and farming are increasingly relying on automation to make farms and cooperatives more efficient, reduce the amount of manual labor and be able to analyze data to model and forecast future production. The advancements in robotics are applied in harvesting, watering, seeding. There have also been interesting experiments with drones, autonomous tractors, and other farming tools.
In addition to decreasing the number of mundane manual tasks for agriculture workers, innovations such as Machine Learning Automation models or Artificial Intelligence can help businesses deal with their data in an efficient way, minimizing operational costs and improving analytics, streamlining processes, and enabling farm owners and administration to focus on the strategic tasks at hand.
The Challenge: Build an Object Detection Tool for Corn Kernel Recognition (PoC)
A Partner of a farming company reached out to MindCraft with a request to develop a Machine Learning Automation model that could count the corn kernels on corn using a 2d photo., Kernels calculation is currently done manually, using a certain algorithm allowing workers to count the corn grains. An automatic solution for corn calculation would help our client automate the tedious manual work of separate departments.
The client has approached us to understand the feasibility of this task and to explore the quality metrics in this case. An interesting fact was that the client had only 1 week to do this research, then, he had to submit the results to his stakeholders.
Pressed for time but excited, our engineering team focused on trying as many approaches as possible under the circumstances. The final results of our research became a solid basis for further work and can be transformed into a full-scale production-ready solution.
During this intense week, we created and analyzed 7 different Machine Learning Automation models, and we’re about to tell you more about them.
Analyzing the DataSet
The client started by sending us several dozens of corn photos taken under different angles, for processing.
Below we’ll provide a few examples of similar photos since we decided not to share our customer’s materials.
Decision: One Day for One ML Model
Our goal was to create a Machine Learning model that would deliver quick results. Even is the results are not perfect, they would still cast some light on our next steps.
Model 1. Yellow Points Calculation
Our first idea for the algorithm was simple – to do a regression from colors and points to single grains. The final result was quick, but the quality rate appeared to be below the quality of manual work.
Model 2: Z-Crossing Analysis
Our second approach was based on the calculation of vertical and horizontal peaks using a Z-crossing analysis. Through the calculation of the number of gradient changes in the vertical and horizontal planes we managed to get an accurate result, but only for the corn grains with no offset between the rows.
Model 3: Calculation of Rows Using 2nd Order Differentials
The averaging of color gradient deflections gave good results. However, corn grains with holes created a problem that couldn’t be solved with this method:
Model 4: Clustering
Our next try was to divide corn grains into clusters, applying a set of adaptive filters to smooth out the shades and the volume. The problem here was that since naturally, the corn grains aren’t homogeneous, their inner holes and imperfections are perceived by the model as additional “grains”.
Model 5: Image Segmentation
This model was a continuation of the previous method. Here we tried to highlight the grains that stuck together when we used remote filters. This method usually works well on similar objects, but not in this case, due to the holes in corn grains. The grains that didn’t have holes in them were segmented quite successfully.
Model 6: Adaptation Analysis of Contours
Here the idea was to locate the peak points (local maximums of the hot-yellow color) and calculate them. This idea largely depended on the smoothing filters and the process of their selection was rather long. We discarded this method for being not compatible with the real-world solution.
Model 7: Classical Object Detection
The last approach that we tried is a well-known classic, rather long but effective. We had to train the model to recognize separate corn grains. It should work perfectly, but only after you invest in the data labeling, as well as training and tuning of the artificial neural network
Thanks to these 7 models we realized that quick methods are quite effective and give a great deal of understanding as to what the next steps would be, how to implement the project and achieve satisfactory results. Coming back to our client’s case, our final recommendation was to concentrate on the Object Detection model, develop the markup, and train the model. Then, the next logical step would be to select the right type and architecture of the Object Detection model among the many available options.
We are glad that in this short period of time, only a week, we managed to thoroughly analyze the problem and provide our customers with detailed feedback, and further recommendations. The partner was satisfied, he provided a report to his stakeholders and now we continue to discuss further steps.
Contact us if you have for personal questions and if you have needs in AI, or you need to set up a Data Science consulting team
Also, review our previous topic about Artificial Intelligence In E-commerce