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 comprehensively, there are scenarios where certain critical physical examinations are insufficient for the purpose. The examinations are done manually and 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 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, 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 labeled 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 got 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 classesog grain, and the final model was created, deployed, and integrated with the App.