Grain Quality Analysis using ML

Case Overview

Can Computer Vision help detect quality of produce for farmers and arm them with a quality assessment ? This will allow farmers to negotiate better deals from grain procurers.


Gramheet is an organization committed to building an ecosystem where every farmer cultivates with dignity and feeds the world with pride. Gramheet assists farmers with a wide range of services from warehouse storage to credit availability and quality analysis.
Gramheet's objective is to transform agriculture into the most dignified profession.


The business challenge is to assist Gramheet's teams that manually inspect grains for quality and put quality analysis of produce directly in the hands of the farmer.

Can a farmer obtain a quality report by simply uploading the picture of their produce? This can also educate the farmer on better produce quality and provide them with the information needed to get the best price for it.


The solution was to build an easy to use mobile application with a feature to upload pictures of the produce. In addition, we envisioned a cost-effective device to mount a mobile phone so that pictures of produce are uniform in nature as well as have proper lighting.

Working with the Gramheet team, our ML team first prepared the data set to build the object-detection model. For each crop, i.e. soybean, wheat, red gram etc, images were captured in order to train an Object Detection neural network model.

  • Each training image has a mixture of good grains, bad grains, damaged material, and so on, depending on the requirements for that particular crop.
  • Training images are then annotated with labels for different object classes (damaged, clod, wood etc).
  • Train the model with sufficient variations of the training images by introducing noise, blur effects and other image manipulations that make the model more robust in dealing with variables in real-life situations.
  • Given a new image, the model identifies the instances of grains present in the image. Based on the count of good grains, damaged grains and foreign material, we compute their percentage values.
  • Finally, we take an average of this distribution across several images in order to come up with the final grain quality report.

The mobile application would first be used by Gramheet employees to iron out user experience and usage issues. Post user-acceptance, the app can then be rolled out to the farmers in phases. Gramheet’s extensive on the ground presence will provide training and hand-holding to farmers who need the help.

We also designed an innovative way to collect image data while the app was being piloted by combining a manual as well as automated way of responding to the API calls made to the backend. This allows us to collect data while simultaneously responding to the quality report requests made by farmers. Curated image data will then go back to the training set to increase model accuracy over time.


This set of ML models will deliver highly accurate grain quality reports to the network of Gramheet farmers. This is expected to impact incomes of thousands of farmers who are currently marginalized and are taken advantage of. The app along with outreach will allow these farmers to become more aware of prevailing rates and even the playing ground where produce prices are negotiated.

About Gramheet

Gramheet provides holistic services to farmers at their farm-gate. By providing affordable storage for grains near the farm locations, it allows farmers to store and wait for a suitable time to sell their produce to maximize profits.

Gramheet provides post-harvest credit to the farmers immediately on depositing produce at the storage location to allow farmers to deploy the earnings sooner and take advantage of a year-round cycle for maximizing returns.

Gramheet also connects farmers to wholesalers and producers that need access to the produce. Using grain quality analysis and forecasting, Gramheet influences the best prices paid for the produce.



Provide a cost-effective solution to gauge quality of produce that farmers can use to obtain a third-party assessment. The solution should scale to support thousands of farmers simultaneously.


Indexnine and Gramheet delivered an API supported by a Computer Vision ML model that accurately identifies Good Quality, Damaged, Clod and Wood pieces in a sample. Designed a cost-effective way to take uniform pictures of the produce to utilize the model for object identification and classification. This solution will benefit thousands of farmers that can now get an accurate picture of their produce quality.