Deep Learning-Based Rice Grain Classification with Class Imbalance Handling Using Weighted Sampling and Data Augmentation
DOI:
https://doi.org/10.30871/jaic.v10i3.12930Keywords:
Rice Grain Classification, Class Imbalance, Deep Learning, Fine-Grained ClassificationAbstract
Rice grain quality assessment is important for maintaining product consistency and quality standards in the food industry. Manual inspection is still widely used in practice, but it is often subjective and time-consuming especially in fine-grained classification problems where the visual differences between classes are relatively subtle. Another common challenge in rice grain datasets is class imbalance where the number of normal samples is much larger than the number of defective classes. In this paper, we investigate various imbalance handling strategies for deep learning-based rice grain classification using the GrainSet dataset, which contains 30,962 rice grain images divided into eight quality classes with a highly imbalanced class distribution. The proposed approach combines weighted sampling, data augmentation, and hyperparameter optimization to address class imbalance, while Focal Loss and Class-Balanced Loss are used as comparison methods for performance evaluation. Three deep learning architectures, namely MobileNetV3, ResNet50, and ViT-Small, were evaluated using Accuracy, Macro F1-score, and Weighted F1-score metrics. Experimental results show that the proposed approach achieved the most consistent overall performance. Among the tested models, ResNet50 achieved the best result with 98.87% accuracy and a Macro F1-Score 0.9799. The results also show that convolution-based architectures are more stable than transformer-based models for texture-oriented datasets with limited training data. Furthermore, the combination of sampling-based balancing, augmentation and suitable hyperparameter configuration contributed to better recognition performance on minority classes.
Downloads
References
[1] L. Fan et al., "An annotated grain kernel image database for visual quality inspection," Scientific Data, vol. 10, no. 1, 2023, doi: 10.1038/s41597-023-02660-8.
[2] S. A.-A. Shuvo et al., "Image-based classification of Bangladeshi rice varieties using deep convolutional neural networks," Agricultural Products Processing and Storage, early access, 2024, doi: 10.1007/s44462-026-00061-9.
[3] W. Agustiono et al., "Rice variety identification based on transfer learning architecture using DENS-INCEP," IEEE Access, vol. 13, pp. 78007–78020, 2025.
[4] F. Farahnakian et al., "A comparative study of state-of-the-art deep learning architectures for rice grain classification," Journal of Agriculture and Food Research, vol. 15, 2024.
[5] R. Setiawan and H. Oumarou, "Classification of rice grain varieties using ensemble learning and image analysis techniques," Indonesian Journal of Data and Science, vol. 5, no. 1, pp. 54–63, 2024.
[6] S. S. Hidayat et al., "Determining the rice seeds quality using convolutional neural network," International Journal on Informatics Visualization, vol. 7, no. 2, pp. 527–534, 2023, doi: 10.30630/joiv.7.2.1175.
[7] L. Fan et al., "GrainSpace: A large-scale dataset for fine-grained and domain-adaptive recognition of cereal grains," in Proc. IEEE/CVF Conf. Computer Vision and Pattern Recognition (CVPR), 2022.
[8] P. Xu et al., "Research on maize seed classification and recognition based on machine vision and deep learning," Agriculture, vol. 12, no. 2, 2022.
[9] Y. H. Wang and W. H. Su, "Convolutional neural networks in computer vision for grain crop phenotyping: A review," Agronomy, vol. 12, no. 11, 2022.
[10] Y. Wang et al., "Vision transformers for image classification: A comparative survey," Technologies, vol. 13, no. 1, 2025.
[11] H. Touvron et al., "Training data-efficient image transformers," in Proc. International Conference on Machine Learning (ICML), 2021.
[12] K. He et al., "Deep residual learning for image recognition," in Proc. IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2016.
[13] A. Howard et al., "Searching for MobileNetV3," in Proc. IEEE International Conference on Computer Vision (ICCV), 2019.
[14] A. Dosovitskiy et al., "An image is worth 16×16 words: Transformers for image recognition at scale," in Proc. International Conference on Learning Representations (ICLR), 2021.
[15] Y. LeCun, Y. Bengio, and G. Hinton, "Deep learning," Nature, vol. 521, pp. 436–444, 2015.
[16] H. He and E. A. Garcia, "Learning from imbalanced data," IEEE Trans. Knowl. Data Eng., vol. 21, no. 9, pp. 1263–1284, 2009.
[17] B. Arora et al., "Rice grain classification using image processing and machine learning techniques," in Proc. International Conference on Inventive Computation Technologies (ICICT), 2020.
[18] D. S. Vishnu and D. L. S. Reddy, "Rice classification using deep neural network," in Proc. Int. Conf. Computer Science and Communication Engineering (ICCSCE), Atlantis Press, 2025, doi: 10.2991/978-94-6463-858-5_48.
[19] L. J. Mawarani et al., "Rice identification using convolutional neural network with YOLOv7 and VGG16," IPTEK The Journal of Engineering, vol. 10, no. 3, 2024.
[20] G. Lemaître, F. Nogueira, and C. K. Aridas, “Imbalanced-learn: A Python toolbox to tackle the curse of imbalanced datasets in machine learning,” Journal of Machine Learning Research, vol. 18, no. 17, pp. 1–5, 2017.
[21] T.-Y. Lin, P. Goyal, R. Girshick, K. He, and P. Dollár, "Focal loss for dense object detection," in Proc. IEEE Int. Conf. Comput. Vis. (ICCV), 2017, pp. 2980–2988.
[22] Y. Cui, M. Jia, T.-Y. Lin, Y. Song, and S. Belongie, "Class-balanced loss based on effective number of samples," in Proc. IEEE/CVF Conf. Comput. Vis. Pattern Recognit. (CVPR), 2019, pp. 9268–9277.
[23] M. Buda, A. Maki, and M. A. Mazurowski, "A systematic study of the class imbalance problem in convolutional neural networks," Neural Networks, vol. 106, pp. 249–259, 2018
Downloads
Published
How to Cite
Issue
Section
License
Copyright (c) 2026 Muhammad Aulia Anhar, Nova Rijati

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Authors who publish with this journal agree to the following terms:
- Authors retain copyright and grant the journal right of first publication with the work simultaneously licensed under a Creative Commons Attribution License (Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) ) that allows others to share the work with an acknowledgement of the work's authorship and initial publication in this journal.
- Authors are able to enter into separate, additional contractual arrangements for the non-exclusive distribution of the journal's published version of the work (e.g., post it to an institutional repository or publish it in a book), with an acknowledgement of its initial publication in this journal.
- Authors are permitted and encouraged to post their work online (e.g., in institutional repositories or on their website) prior to and during the submission process, as it can lead to productive exchanges, as well as earlier and greater citation of published work (See The Effect of Open Access).








