Abstract:
Cinnamon is a vital component of Sri Lanka's agriculture, internationally recognized for its flavor, aroma, and medicinal properties. Despite its significance, traditional cinnamon quality grading relies on manual visual inspections, which are subjective, time-consuming, and inconsistent. Also, misclassification of cinnamon bark’s highest obtainable grade can lead to improper grading decisions and suboptimal processing, reducing its potential value. Previous research has focused primarily on species identification or post-processing quality assessment, leaving a gap in grading cinnamon bark before processing. This study introduces a machine learning model to detect the highest grade obtainable from cinnamon bark, ensuring its optimal utilization. A four-stage deep learning pipeline: Data Collection, Preprocessing, Segmentation, and Classification was developed. A dataset of over 1,500 high-resolution cinnamon bark images, captured in a 4:3 aspect ratio using phone cameras under controlled lighting conditions, was prepared. These images were labeled into four predefined quality classes: Extra Special High Quality, High Quality, Medium Quality, and Low Quality, by industrial experts. Class imbalance was addressed using augmentation techniques, blurriness detection, image resizing, normalization, and CLAHE (Contrast Limited Adaptive Histogram Equalization) to enhance clarity and texture. Segmentation was performed using the U-Net architecture integrated with attention and residual blocks, achieving an IoU (Intersection over Union) of 0.87 and a Dice Coefficient of 0.90, outperforming basic models such as thresholding and edge detection. Classification was carried out using a fine-tuned ResNet101 CNN with transfer learning, achieving an accuracy of 92%, recall of 0.89, and an F1-score of 0.89. The model was integrated into a mobile application, allowing farmers to submit bark images for instant grading. Model’s reliance on controlled lighting and lack of generalization to other types of cinnamon bark, remain as limitations of the study. Nevertheless, this research offers an efficient, scalable solution for cinnamon quality detection, reducing human error, improving grading accuracy, and paving the way for broader AI adoption in the cinnamon industry.