Rapid Ecosystem-Driven Deep Learning: On-Device Grain Type Classification and Authentication using iOS Swift and Core ML

Trianggoro Wiradinata

Abstract


The 2025 Indonesian rice scandal highlighted major shortfalls in food security and the pressing need for robust, data-based verification of authenticity. The goal of this work is to design a fast, lightweight, and fully offline rice grain classification and verification system that can run directly on consumer mobile hardware. The basic idea to overcome the technical bottleneck of deploying complex computer vision models on edge devices is to use macOS and Apple’s unified ecosystem as a rapid prototyping and deployment platform. The deliberate avoidance of fragmented and high-latency workflows such as external environments (e.g. TensorFlow or PyTorch) and intermediate formats (e.g. ONNX) is mentioned. The study contributes a streamlined pipeline that incorporates an Image Feature Print V1 feature extractor, natively trained with Create ML on a publicly available dataset of 75,000 balanced images of five rice varieties (Arborio, Basmati, Ipsala, Jasmine, and Karacadag), directly into a native iOS application built with SwiftUI. The novelty of this approach is the usage of native tools like VisionKit and Core ML, which enables the complete elimination of third-party bridging code that normally bloats the binary overhead. The results show excellent edge efficiency on an iPhone 15 with a median prediction rate of 2.75 ms, an initial load time of 0.54 ms and a compilation latency of 3.66 ms. Moreover, the results reveal that by employing aggressive data augmentations, including the addition of visual noise, blur, exposure adjustment, flipping and rotation to ensure robustness, and by deliberately not cropping to preserve absolute grain dimensions, the model achieved a remarkable overall accuracy of 97% with an ultra-compact deployment footprint of only 66 KB. These metrics demonstrate that a fast, fully offline and privacy-preserving verification system is well within reach with modern consumer hardware.


Keywords


SwiftUI; CoreML; CreateML; Rice Grain Classification; Machine Learning; Deep Learning

Full Text:

PDF

References


A. Kusumawardani, B. S. Laksmono, L. Setyawati, and T. E. B. Soesilo, “A policy construction for sustainable rice food sovereignty in Indonesia,” Potravinarstvo Slovak Journal of Food Sciences, vol. 15, pp. 484–496, May 2021, doi: 10.5219/1533.

A. Santoso, “Indonesia flags 212 rice brands over violations,” Antara News. Accessed: Oct. 28, 2025. [Online]. Available: https://en.antaranews.com/news/362421/indonesia-flags-212-rice-brands-over-violations

D. F. Syarahil, “212 Merek Beras Ternyata Oplosan, Salah Siapa?,” ekonomi. Accessed: Nov. 10, 2025. [Online]. Available: https://www.cnnindonesia.com/ekonomi/20250715063054-92-1250711/212-merek-beras-ternyata-oplosan-salah-siapa

E. B. E. Tirta, “Kasus Oplosan Dibongkar, Ekonomi Beras Konglomerat Kembali ke Rakyat,” CNBC Indonesia. Accessed: Nov. 10, 2025. [Online]. Available: https://www.cnbcindonesia.com/research/20250821171035-128-660237/kasus-oplosan-dibongkar-ekonomi-beras-konglomerat-kembali-ke-rakyat

N. P. Putra, “Kronologi Skandal Beras Oplosan Rugikan Masyarakat Rp99 Triliun per Tahun,” liputan6.com. Accessed: Nov. 10, 2025. [Online]. Available: https://www.liputan6.com/news/read/6113903/kronologi-skandal-beras-oplosan-rugikan-masyarakat-rp99-triliun-per-tahun

S. Huang et al., “A Novel Method for Filled/Unfilled Grain Classification Based on Structured Light Imaging and Improved PointNet++,” Sensors, vol. 23, no. 14, p. 6331, Jan. 2023, doi: 10.3390/s23146331.

M. J. Iqbal et al., “On Application of Lightweight Models for Rice Variety Classification and Their Potential in Edge Computing,” Foods, vol. 12, no. 21, p. 3993, Jan. 2023, doi: 10.3390/foods12213993.

P. Jalaparthi, M. Shabbeer, S. Kumar, N. Samala, and A. Hussain, “A fast and intelligent rice quality assessment by combining CNN and Bi-LSTM for accurate rice quality evaluation,” AIP Conf. Proc., vol. 3342, no. 1, p. 030042, Sep. 2025, doi: 10.1063/5.0296679.

K. Kiratiratanapruk et al., “Development of Paddy Rice Seed Classification Process using Machine Learning Techniques for Automatic Grading Machine,” Journal of Sensors, vol. 2020, no. 1, p. 7041310, 2020, doi: 10.1155/2020/7041310.

M. Koklu, I. Cinar, and Y. S. Taspinar, “Classification of rice varieties with deep learning methods,” Computers and Electronics in Agriculture, vol. 187, p. 106285, Aug. 2021, doi: 10.1016/j.compag.2021.106285.

R. Singh and S. Chaudhury, “A cascade network for the classification of rice grain based on single rice kernel,” Complex Intell. Syst., vol. 6, no. 2, pp. 321–334, Jul. 2020, doi: 10.1007/s40747-020-00132-9.

P. Nagamani, S. Yacoob, G. L. S. Sneha, S. Mahesh, and B. Godavarthi, “SmartRiceQC: Integrating CNN and Bi-LSTM for Precise Rice Quality Analysis,” in Smart Computing Paradigms: Advanced Data Mining and Analytics, M. Simic, V. Bhateja, A. T. Azar, and E. L. Lydia, Eds., Singapore: Springer Nature, 2025, pp. 267–277. doi: 10.1007/978-981-96-1981-8_21.

F. Farahnakian, J. Sheikh, F. Farahnakian, and J. Heikkonen, “A comparative study of state-of-the-art deep learning architectures for rice grain classification,” Journal of Agriculture and Food Research, vol. 15, p. 100890, Mar. 2024, doi: 10.1016/j.jafr.2023.100890.

R. Guerra, B. Angira, M. Kongchum, and A. N. Famoso, “Phenotypic and genotypic characterization of grain quality in US and Latin American rice and implications for breeding,” Journal of the Science of Food and Agriculture, vol. 105, no. 13, pp. 7159–7168, 2025, doi: 10.1002/jsfa.14428.

T. T. K. Nga, T. V. Pham, D. M. Tam, I. Koo, V. Y. Mariano, and T. Do-Hong, “Combining Binary Particle Swarm Optimization With Support Vector Machine for Enhancing Rice Varieties Classification Accuracy,” IEEE Access, vol. 9, pp. 66062–66078, 2021, doi: 10.1109/ACCESS.2021.3076130.

C. Kurade et al., “An Automated Image Processing Module for Quality Evaluation of Milled Rice,” Foods, vol. 12, no. 6, Mar. 2023, doi: 10.3390/foods12061273.

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, Mar. 2024, doi: 10.56705/ijodas.v5i1.129.

C. Thangavel and D. Sakthipriya, “Machine Learning Ensemble Classifiers for Feature Selection in Rice Cultivars,” Applied Artificial Intelligence, vol. 38, no. 1, p. 2394734, Dec. 2024, doi: 10.1080/08839514.2024.2394734.

H. Zareiforoush, S. Minaee, M. Alizadeh, and A. Banakar, “Potential Applications of Computer Vision in Quality Inspection of Rice: A Review,” Food Engineering Reviews, vol. 7, Jan. 2015, doi: 10.1007/s12393-014-9101-z.

Y. Zhang et al., “Rice quality recognition method based on multimodal model,” Food Control, vol. 181, p. 111691, Mar. 2026, doi: 10.1016/j.foodcont.2025.111691.

T. Wiradinata, T. R. D. Saputri, R. E. Sutanto, and Y. S. Soekamto, “Online Measuring Feature for Batik Size Prediction using Mobile Device: A Potential Application for a Novelty Technology,” Journal of Applied Data Sciences, vol. 4, no. 3, Art. no. 3, Sep. 2023, doi: 10.47738/jads.v4i3.121.

R. Wang et al., “Food defect detection technologies based on deep learning and prospects in detection of unsound wheat kernels,” Food Chemistry, vol. 496, p. 146910, Dec. 2025, doi: 10.1016/j.foodchem.2025.146910.




DOI: https://doi.org/10.47738/jads.v7i3.1414

Refbacks

  • There are currently no refbacks.



Barcode

Journal of Applied Data Sciences

ISSN : 2723-6471 (Online)
Publisher : Bright Publisher
Website : http://bright-journal.org/JADS
Email : taqwa@amikompurwokerto.ac.id (principal contact)
    support@bright-journal.org (technical issues)

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0