Knoldus Inc

Grain Quality Assesment using AI/ML



The client, in the agriculture commodity business, had problems accessing the quality of wheat grains and being able to determine the pricing of the commodity. Though a range of chemical and physical tests are applicable based on the type of grain to ascertain the quality in a comprehensive way there are scenarios where certain important and critical physical examinations are not sufficient for the purpose. The examinations are done manually and mix of expert judgement and proper scientific procedures. The current quality process flow took approximately 3 days.

To make the quality assessment processes more lean, efficient, effective and standardized Knoldus team was asked to conduct a Proof of Concept(POC) and provide a solution. The objective of this proof of concept was to detect, classify and count wheat grains using Computer Vision and Deep Learning algorithms integrated with an App and the ability to visualize and evaluate the outcome of the assessment in a user interface with pre-defined metrics. The target was to reduce the turnaround time from 3 days to around 3 seconds.


The client provided images of different classes of grains; healthy, broken, Immature, Potiya Moist etc in different folders taken in different scenarios e.g. light condition, background, focal distance, different cameras. Using this dataset our team had to train machine learning models to be able to detect, classify and count the grains and also be able to calculate the weight of a given amount of grain.

Our team had to detect individual grains from a given set to be able to calculate the count and subsequently classify from among the given classes and calculate the final weight.

These detection and classification models had to be integrated with an application with certain performance benchmarks i.e. response time, latency and throughput.


Our team started with analyses of the data and observed that the images provided had a lot of noise e.g. images were taken on top of tables and the background were same as the images; thereby extraction of features was difficult and the quality of images also varied for different classes due to varied conditions in which they were taken. Our team had to clean and remove some of the images.

Our team built custom programs in python to remove the noise from the images and make them more consistent which included cropping the pictures, enlarging them, changing resolutions etc.

We first started with image classification and trained a custom CNN model to classify a given set of grains to a specific class but found that the accuracy levels were very low less than 20%-30%. We then used data augmentation techniques to generate some more data from the existing data and then used it in the same model. The accuracy for some classes increased but the overall results were not satisfying since the results were not consistent for the different classes.

We then used a new way wherein our team labelled individual grains from a given set. This was done for some of the classes of grains. A data annotation tool was used to label individual grains, then using augmentation techniques some more synthetic data was created which was then fed into a pretrained Yolo5 model. The grain detection accuracy

got increased and the model was able to more accruately classify individual grains to the clases along with a bounding box around it. These activities were then replicated for the other classesog grain and the final model was created, deployed and integrated with the App.


Download the detailed version of the case study:

    Get In Touch:

    Looking for similar or other solution for the healthcare industry? Get in touch or send us an email at We are proven, experienced Certified Lightbend Partner, available for partnering to make your product a reality.

    Follow our thinking:

    Share this successful story: