Rice is a strategic food commodity whose quality is assessed based on the visual appearance of the grains, including the presence of unhusked rice as an undesirable element in piles of milled rice. Manual inspection is subjective, time-consuming, and prone to errors, necessitating a more objective automated approach. To address this issue, this study applies a MobileNetV2-based Convolutional Neural Network with transfer learning to classify unhusked grains as visual anomalies in rice piles into two classes: normal rice and anomalous grains. In terms of methodology, the dataset consists of 1,000 self-acquired images stratified into three groups with a 70:15:15 ratio. Image preprocessing was performed via background removal using the rembg library and random background simulation with five background color variations. Training was conducted in two phases: Phase 1 (transfer learning with a frozen base model) and Phase 2 (fine-tuning by opening the last 30 layers of the base model). The evaluation results on the test data showed an accuracy of 90.67%, a macro precision of 0.9213, a macro recall of 0.9067, and a macro F1-score of 0.9058. The false positive rate across all tests was 0. Phase 1 was selected as the best model because it produced more stable performance compared to Phase 2. Grad-CAM visualizations confirmed that the model focuses its attention on the visual features of the objects, not background patterns. These findings demonstrate that a combination of preprocessing, transfer learning, and data augmentation is effective for binary image classification when dealing with limited datasets.
Copyrights © 2026