Grain Quality Assesment using AI/ML

Grain Quality Assesment using AI/ML


NashTech created an efficient automation classification system using machine learning and AI technologies that identified and aggregated defects in commodities, increasing productivity and financial gains for our client. 


The client in the agriculture commodity business had problems assessing 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 comprehensively, there are scenarios where certain critical physical examinations are insufficient for the purpose. The examinations are done manually by a mix of expert judgment and proper scientific procedures. The current quality process flow took approximately 3 days.

To make the quality assessment processes more lean, efficient, effective and standardised the NashTech 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 create the ability to visualise and evaluate the outcome of the assessment in a user interface with pre-defined metrics. The target was to reduce the turnaround time from three days to around three 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., condition, background, focal distance, and 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 was the 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, and then, using augmentation techniques, some more synthetic data was created and fed into a pretrained Yolo5 model. The grain detection accuracy increased and the model was able to more accurately classify individual grains to the classes along with a bounding box around it. These activities were then replicated for the other classes of grain, and the final model was created, deployed, and integrated with the app.


  • Identification of the grain classes automatically
  • Classification of the defects in the commodity automatically – based on the image analysis by the AI model
  • Aggregation of the classes into the defect % and/or quality grade of the commodity
  • Automation, process improvement and standardisation.
  • Reduction in the cycle time brought immediate productivity and financial benefits to the client.
  • Scalability of the model to accomodate other similar agriculture commodities using Transfer Learning

Let's talk about your project

Our partnerships

Scroll to Top