Abstract
Manual classification of rice grain defects remains a persistent challenge in the Peruvian rice industry, as it relies heavily on human inspection, leading to variability, inconsistency, and reduced efficiency when processing large volumes of product. This study evaluates the effectiveness of transfer learning and convolutional neural networks (CNNs) for the automatic classification of four rice grain categories relevant to quality assessment: Whole, Stained, Broken, and Chalky. A dataset comprising 6599 RGB images was employed. To ensure a reliable evaluation protocol, the dataset was first partitioned into training (70%), validation (15%), and test (15%) subsets, after which data augmentation was independently applied within each partition to balance class distributions. Five pretrained CNN architectures were evaluated: MobileNetV2, EfficientNetB0, ResNet50, DenseNet121, and InceptionV3, all of which share a common classification head. Models were trained using transfer learning and early stopping based on validation loss. Performance was assessed using accuracy, precision, recall, F1-score, confusion matrices, 95% confidence intervals, and pairwise McNemar statistical tests. The results showed that ResNet50 achieved the highest classification accuracy (84.71%), followed by EfficientNetB0 (83.60%) and DenseNet121 (83.20%). Statistical analysis indicated that performance differences among the top-performing architectures were relatively small, with significant differences observed only for selected model pairs. Across all evaluated models, the discrimination between Whole and Chalky grains remained the most challenging classification task due to their high visual similarity. Overall, the findings demonstrate that transfer learning-based CNNs provide an effective and scalable approach for automated rice grain defect identification and quality assessment in agricultural environments.
1. Introduction
Agriculture is a cornerstone of global food security. It provides staple crops such as rice, corn, and wheat to more than half of the world’s population. In this context, food quality is key to ensuring healthy and competitive products. This requires rigorous controls from production to marketing [1,2]. The agricultural sector provides approximately 90% of the world’s food calories and 80% of its protein and fat. Its role is essential to meeting multiple Sustainable Development Goals (SDGs), such as zero hunger and poverty eradication [3,4,5,6].
Since rice accounts for around one-fifth of human caloric intake, its production worldwide is essential to food security [7]. Several hundred million tons of milled rice are produced worldwide each year, mostly in Asia, with China and India leading the way. As a result, there is a significant dependence on the productive balance of these regions [8]. In recent decades, production growth has slowed due to stagnating yields across various rice-growing systems, while demand continues to rise amid population growth. This scenario is exacerbated by the crop’s high water requirements, soil quality limitations in large production areas [9], and increasing exposure to the effects of climate change and extreme events, factors that increase the vulnerability of the system and reinforce the need to improve production efficiency and quality management in the rice supply chain [10].
There are several obstacles to rice cultivation, especially in Peru and other Latin American nations. These include high production costs, dependence on traditional systems, and high water consumption [11]. The classification and quality of rice vary according to industrial and culinary attributes and are adapted to market demands. Post-harvest losses and quality issues, such as broken, stained, or chalky grains, directly affect profitability and food safety. These problems are exacerbated by a lack of supporting technologies and deficiencies in the value chain [1].
The limitations of traditional inspection have driven the use of automated approaches based on computer vision. Instead of relying on human observation, this field focuses on the systematic analysis of digital images, allowing the objective identification of objects or defects from the available visual information [12]. From another perspective, deep learning has emerged as one of the most robust approaches in this field; through multi-layered neural networks, it can build complex representations of data and learn classification patterns directly from inputs, without the need for explicit prior processing [13].
In commercial rice production, grain defects directly influence product quality, market value, and consumer acceptance. Defects such as broken, stained, and chalky grains reduce the commercial grade of rice and may indicate problems during cultivation, harvesting, storage, or processing [14]. Traditional quality assessment is typically performed through manual inspection, which is time-consuming, labor-intensive, and subject to operator variability [15]. Consequently, automated vision-based systems have become increasingly attractive for improving consistency, scalability, and efficiency in rice quality control processes [16].
In advanced image processing, convolutional neural networks (CNNs) are among the most widely used architectures. Their capabilities rely on filters applied via convolutional layers, which generate feature maps and detect complex patterns such as edges and textures [17]. Thanks to this approach, CNNs have replaced traditional manual feature extraction methods, becoming a more effective alternative for image classification in the agricultural sector [18,19].
Although transformer-based architectures such as Vision Transformers (ViTs) and Swin Transformers have recently demonstrated strong performance in large-scale image classification tasks [20], convolutional neural networks remain highly competitive for agricultural applications involving relatively small datasets and limited computational resources [21,22]. Furthermore, pretrained CNN architectures such as EfficientNet, DenseNet, and MobileNet continue to provide favorable trade-offs between accuracy, computational efficiency, and deployment feasibility in real-world agricultural environments [23]. For these reasons, the present study focuses on a comparative evaluation of representative CNN-based transfer learning architectures.
This study focuses on the automatic classification of rice grains from the Peruvian Rice Dataset. The goal is to identify defects by comparing several deep learning algorithms. This work makes several contributions to automated agricultural quality assessment. First, it evaluates deep learning models for rice defect classification using a real-world Peruvian dataset characterized by high visual variability. In addition, it provides a systematic, reproducible comparison of five convolutional neural network architectures under identical experimental conditions. The study also provides an in-depth analysis of classification challenges, particularly the confusion between visually similar classes such as Whole and Chalky grains. Finally, it offers a reproducible framework supported by publicly accessible data and a well-defined experimental configuration.
The document presents several sections, starting with Section 2, which reviews the current state of the art in grain classification. The theoretical foundations, the specific software environment, the dataset properties, and the proposed method, which provide the necessary context for the systematic training approach, are detailed in Section 3. Experimental findings and their corresponding statistical analysis are presented in Section 4. A critical interpretation of these results is presented in Section 5. Finally, Section 6 summarizes the primary contributions of the work and suggests potential avenues for future technical improvements in Section 7.
2. Related Works
Automated grain classification through computer vision and machine learning has been an active research area over the past decade. The literature can be broadly organized into three thematic groups: variety identification and general quality assessment, defect detection and structural damage classification, and real-time or edge-deployable detection systems. Currently, many researchers are focusing on improving the quality of seed detection and classification using machine learning. However, few studies have focused on detecting defects in Peruvian rice using two-dimensional RGB images.
Koklu et al. [24] established one of the most widely cited benchmarks for rice variety recognition using deep learning. The authors collected a dataset of 75,000 images, evenly distributed across five Turkish rice varieties (Arborio, Basmati, Ipsala, Jasmine, and Karacadag), capturing each grain against a uniform black background under controlled illumination. Several convolutional neural network architectures were evaluated, including ResNet50, InceptionV3, and custom CNN models, all trained with transfer learning from ImageNet weights. Performance metrics (accuracy, precision, recall, and F1-score) were computed across all five classes, and the best models achieved classification accuracies approaching 100%. Despite the methodological rigor, the study is entirely oriented toward varietal identification: all five target classes are intact grain varieties distinguished by morphological traits such as length, width, and aspect ratio. No defect categories were included in the experimental design, so the benchmark cannot be directly applied to quality control or sorting tasks.
Razavi et al. [25] evaluated multiple ResNet configurations (ResNet34, ResNet50, and a fine-tuned version of ResNet50 via transfer learning) for the joint tasks of rice variety classification and quality detection across several Asian cultivars. Their transfer-learning variant of ResNet50 achieved 99.8% classification accuracy, outperforming both shallower architectures and dictionary-learning baselines. However, the concept of quality detection in this work refers to cultivar-level quality grades, not to labeling individual physical defects. The dataset consisted exclusively of Asian grain varieties under controlled imaging conditions, and neither class imbalance nor imaging variability was addressed.
The theoretical underpinnings of residual learning used in the above architectures have been analyzed by [26], who examined how residual skip connections address the degradation problem in deep networks, where increased depth paradoxically raises training error due to vanishing gradients, by reformulating each layer as a residual mapping relative to its input. Their analysis, conducted on the ImageNet benchmark with architectures up to 152 layers, confirms that ResNet models are substantially easier to optimize than plain deep CNNs of comparable depth. This theoretical foundation is directly relevant to understanding why ResNet-based transfer learning generalizes effectively in domain-specific tasks such as grain classification, as demonstrated by [25].
Farahnakian et al. [20] conducted one of the most systematic architectural comparisons to date for rice grain classification. Using the same 75,000-image dataset introduced by [24], the authors evaluated four state-of-the-art architectures (ResNet, VGG, EfficientNet, and MobileNet), each trained from scratch and also fine-tuned via transfer learning from ImageNet weights.
EfficientNet, whose family of models was originally designed around a compound scaling strategy that jointly increases network depth, width, and input resolution through a single coefficient [27], achieved the highest classification accuracy at 99.76%, while MobileNet delivered the fastest inference. The study confirms that deep learning models are more scalable than handcrafted feature pipelines for large-scale grain datasets. Nevertheless, two limitations restrict the direct applicability of these findings to the present context: the benchmark consists exclusively of intact grains from five varieties with large inter-class morphological differences, making the classification problem structurally simpler than discriminating between defect subtypes within a single species; and the experimental protocol does not account for class imbalance, a characteristic challenge of defect datasets where conforming grains vastly outnumber defective ones.
In [28], the authors proposed a complementary strategy for improving classification performance without increasing model complexity. Rather than scaling a single network, the authors revisited the concept of ensembling by training two EfficientNet-B0 models on disjoint data subsets (bagging), then learning an adaptive combination layer via fine-tuning. This approach reduced parameter count by 5 to 60 times relative to single-model baselines while achieving a mean accuracy improvement of approximately 0.5% on standard benchmarks, including ImageNet and CIFAR. Although the work is not applied to agricultural grain classification, the lightweight ensemble strategy it proposes is methodologically relevant to scenarios where hardware constraints limit the deployment of large single models, such as edge-based grain inspection systems.
For quality grading of milled rice, [29] proposed a pipeline based on morphological features extracted from binary (thresholded) images. The authors acquired images of Thai milled rice under controlled conditions, applied a binarization step to isolate individual grain silhouettes, and then computed a set of geometric descriptors including area, perimeter, aspect ratio, eccentricity, and compactness. These features were subsequently fed into Random Forest, SVM, and decision tree classifiers, with cross-validation used to select hyperparameters. The best model (Random Forest) successfully classified four grain quality categories with an accuracy exceeding 99%. The work is notable because it demonstrates that a carefully engineered set of morphological features, without any deep feature learning, can achieve competitive performance in controlled conditions. However, the pipeline is tightly coupled to the binary-image acquisition process; the binarization step requires a uniform, high-contrast background, and the geometric features lose discriminative power when illumination varies, or the background is complex, as is common in standard RGB photography. Additionally, the four quality categories evaluated correspond to grade levels of milled rice, not to individual physical defect types such as chalky endosperm, brown-stain contamination, or mechanical breakage.
The study [30] provided an earlier, methodologically relevant precursor by examining the multiclass classification of seven dry bean varieties using computer vision combined with classical machine learning. The authors extracted 16 morphological, shape, and color features from grain images and evaluated SVM, Random Forest, k-NN, neural networks, and logistic regression. SVM and Random Forest achieved the highest accuracies, both exceeding 95%. While the study established the discriminative power of handcrafted feature pipelines for seed classification, it addresses an inter-species problem, distinguishing between visually distinct bean varieties, rather than an intra-species defect classification problem. In the latter case, defect categories such as chalky and intact grains from the same cultivar may differ only in surface texture or opacity, making the classification boundary considerably harder to learn from geometric descriptors alone.
Kurade et al. [31] developed a low-cost, automated quality evaluation module for milled rice using a Raspberry Pi-based image acquisition setup, from 3081 images of eight rice varieties captured under controlled conditions, the authors extracted structural and geometric features (perimeter, area, solidity, roundness, compactness, and shape factor)and evaluated seven classification algorithms including logistic regression, decision tree, Random Forest, MLP, and SVM with linear, polynomial, RBF, and sigmoid kernels. Random Forest yielded the best classification accuracy at 77%, while SVM with an RBF kernel was competitive. The study is valuable as a low-cost deployment reference, but its objective is variety-level identification rather than defect labeling at the grain-level. Furthermore, the modest accuracy obtained, relative to deep learning benchmarks, suggests that geometric features alone are insufficient when inter-class variability is subtle.
In [32], the authors explored a fundamentally different sensing modality by combining near-infrared hyperspectral imaging (NIR-HSI) with deep convolutional neural networks for rice seed variety identification. The NIR-HSI system captured spectral information across hundreds of wavelengths beyond the visible range, enabling the model to exploit internal grain properties, such as protein content distribution and moisture gradients, that are entirely invisible to conventional RGB cameras. The authors applied principal component analysis for dimensionality reduction before training a CNN on the resulting spectral features, achieving variety-identification accuracies exceeding 99%. While the results are impressive, the reliance on specialized hyperspectral hardware that costs several orders of magnitude more than a standard RGB camera makes this approach impractical for the milling and trading environments targeted in the present study, where image acquisition is performed with consumer-grade RGB sensors.
The structural damage classification problem was addressed more directly by [21] than most works in this group. The authors built a custom dataset of 8,084 high-magnification images of milled rice grains, annotated across seven damage categories. Five memory-efficient deep CNN architectures were evaluated, with EfficientNet-B0 achieving the best performance at 98.37% accuracy and a prediction time of 0.122 s per image. The high spatial resolution of microscopy-grade images is a critical enabling factor: it eliminates defocus blur, background variation, and shadow effects that are ubiquitous in standard photography, simplifying the feature learning task considerably. The boundary between defect classes, for instance, between a lightly cracked and a heavily cracked grain, is therefore cleaner in microscopy images than in conventional RGB captures. While [21] represents the closest antecedent to the present study in terms of task definition, this methodological gap limits the transferability of their results to standard inspection pipelines that rely on commodity cameras.
Industries are seeking practical solutions, which has led to a growing interest in contemporary studies on the development of real-time detection systems for defects and diseases in rice grains.
NAM-EfficientNetV2 was proposed by [33], a lightweight fully convolutional segmentation model targeting rice grain and grain-impurity discrimination during combine harvesting. The key architectural innovation was replacing the standard Squeeze-and-Excitation (SE) attention mechanism in EfficientNetV2 with a Normalized Attention Mechanism (NAM), which reduces parameter count while maintaining feature discriminability by normalizing attention weights across channels. Additionally, shallow-layer multi-scale features were fused into the upsampling path to preserve pixel-level spatial detail, enabling accurate boundary delineation between grain and impurity regions. The proposed model achieved F1-scores of 95.26% for rice grains and 93.27% for impurities, with GPU inference times of 0.103 s and CPU inference times of 0.301 s per image, demonstrating practical deployment potential on edge hardware. However, the task formulation is binary segmentation (grain versus non-grain material) rather than multiclass defect classification within individual grains.
TCLE-YOLO was introduced by [34], a detection and counting model built on a modified YOLOv5 backbone. The architecture incorporated a Coordinate Attention (CA) module into the backbone to enhance spatial feature representation for small, tightly-clustered targets, a Transformer Encoder in the neck module to expand the effective receptive field, and an additional detection head specialized for small-target feature maps. An additional refinement was the adoption of EIoU loss, which improves bounding-box regression accuracy for irregularly shaped objects. On a self-built dataset of rice grain images with varying degrees of adhesion (grains partially overlapping with their neighbors), TCLE-YOLO achieved precision, recall, and mAP@0.5 of 99.20%, 99.10%, and 99.20%, respectively, outperforming Faster R-CNN, EfficientDet, SSD, and YOLOv7 baselines. Despite these strong results, the model was designed and evaluated exclusively for grain localization and counting in support of thousand-grain weight measurements. No per-grain defect annotation was included, and the class vocabulary consists of a single grain class without any quality or damage subtype distinction.
Deng et al. [35] addressed a closely related problem: automated counting of individual grains on rice panicles, which presents the additional difficulty of dense packing, partial occlusion by stems and leaves, and highly variable scale across the panicle. The authors used a convolutional detection network trained on panicle images acquired under field conditions and obtained high counting accuracy across multiple rice genotypes. The work is methodologically relevant as evidence that detection networks can handle significant intra-image scale variation and occlusion in agricultural settings. However, like [34], the task remains purely enumerative: the output is a count, not a per-grain defect label, and the visual appearance of each grain is not examined beyond its detectability as an object.
In [36], the author evaluated Faster R-CNN for the detection of rice leaf diseases under real-time constraints. The authors used a dataset of leaf images annotated with four disease categories and reported high localization accuracy for disease regions. Faster R-CNN’s two-stage design, a region proposal network followed by a classification head, provides precise bounding-box regression but incurs a computational cost that limits its frame rate on standard hardware. The authors acknowledged this inference-speed bottleneck as a practical constraint for deployment in field devices, noting that single-stage detectors such as YOLO achieve comparable accuracy with substantially lower latency. This speed–accuracy tradeoff is a recurring theme in the deployment-oriented agricultural detection literature.
More recently, YOLOv11-RD, a modified version of the newly released YOLOv11 architecture in [37], specifically optimized for rice disease detection in farmland videos, was proposed. The architectural contributions include an enhanced Large Selective Kernel Attention Convolution (LSKAC) mechanism integrated into the SPPF module for multi-scale feature extraction, a C3k2-CFCGLU block that reduces computational complexity while capturing local texture features characteristic of early-stage lesions, and a C3k2-CSCBAM block in the neck region that improves target saliency against cluttered agricultural backgrounds. A lightweight detection head was also added to improve sensitivity to small disease spots at high resolution. On a dataset derived from agricultural operation videos, YOLOv11-RD improved mAP50 and mAP50-95 by 2.7% and 11.5%, respectively, relative to the baseline YOLOv11n, while simultaneously reducing the parameter count by 4.58 million and the computational load by 1.1 GFLOP. These results confirm that careful architectural engineering can simultaneously improve accuracy and reduce computational footprint, a balance directly relevant to industrial grain inspection scenarios.
YOLO and EfficientNet are lightweight models that enable high-speed, accurate, real-time detection, as mentioned in [33,34,35,36,37]. The great thing about these architectures is that they can be used on devices with limited hardware, such as the Jetson Nano or Raspberry Pi, reaching a balance between performance and efficiency. They focus primarily on general disease detection and not on our approach to classifying specific defects in floury rice grains, such as spots or breaks, as outlined in our research.
Architectures such as EfficientNet, ResNet, Inception, and MobileNet achieve better results than classical machine learning for classifying rice defects and varieties, with accuracy typically exceeding 98% across the reviewed studies. Algorithms such as Random Forests or SVMs can still offer advantages when manually designed morphological features are used; a gap remains in the multiclass classification of defects in Peruvian rice. This specific problem combines class imbalance with the acquisition of uncontrolled images with high visual variability, a factor not addressed in the current literature. Therefore, a comparative evaluation adapted to the local context is warranted, employing both classical and deep learning approaches to define a reproducible framework for analyzing defects in Oryza sativa grains. A summary of the main findings from the works studied is presented in Table 1.
Table 1.
Summary and comparison of related works on rice and grain classification using computer vision and machine learning.
3. Materials and Methods
3.1. Theoretical Foundations
Visual defects must be considered to determine the quality of rice grains. A whole grain of rice has an intact structure. A broken grain of rice shows clear fractures. A chalky grain of rice has a white or chalky opacity. A stained grain of rice shows dark discolorations. Automatic classification uses these visual indicators to identify flaws. Accurate recognition of these indicators can ensure the product’s commercial quality [18].
Computer vision imitates human visual perception. This discipline analyzes digital images to extract important information. These systems can recognize objects, faces, and defects, among others. In the agricultural sector, digital processing enables the automation of rice grain inspection, identifying and classifying defective grains with high accuracy [12].
Deep learning is a specialization of machine learning. This technique has reshaped the classification of agricultural images. It uses multi-layered neural networks to learn complex representations. Deep networks develop feature hierarchies from raw data inputs. These networks are trained using backpropagation. This approach outclasses typical methods based on manual features. This permits the automated identification of rice grain defects with high precision [13].
Data augmentation is an approach used in deep learning to scale up datasets. This method generates modified copies of the original images. The transformations used in this technique include, but are not limited to, rotation, flipping, and random zooming. These variations increase the diversity of the training set. The technique improves the model’s robustness and generalizability. In addition, it helps prevent overfitting [38].
Convolutional Neural Networks (CNNs) are crucial for processing images. These networks operate on data with a grid structure. Convolutional layers extract patterns, such as edges and textures. Pooling layers can reduce the network’s dimensionality. The ReLU function introduces the nonlinearity necessary for the network to learn. CNNs have traditionally been used for classifying agricultural images [17].
MobileNetV2 is an architecture designed to be efficient. It is optimized for devices with limited resources. To do so, it uses inverted bottleneck blocks and separable depth convolutions. This structure reduces the number of training parameters without sacrificing performance. This configuration, when used in cloud environments, enables rapid deployment [39].
EfficientNetB0 is the base version of the EfficientNet family. EfficientNetB0 achieves high accuracy with fewer parameters than other models, making it useful for image classification. This architecture uses composite scaling in a structured way. This method consistently scales the network’s depth, width, and resolution, boosting the model’s performance and efficiency. Its calculation efficiency is beneficial in research contexts [27].
ResNet50 is a deep neural network with 50 layers, as the name implies. ResNet50 allows the training of significantly deeper and more complex networks. The main innovation of this architecture is the residual connections. These jump connections allow information to skip layers. The mechanism helps solve the vanishing gradient problem. The model has proven very robust in image classification. It is often used as a high-performance backbone [26].
DenseNet121 is a neural network with, as the name suggests, dense connections. The model directly connects each layer to all following layers inside it. Each layer receives input from all previous layers within the same block, promoting feature reuse. The architecture mitigates gradient fading. DenseNet121 requires fewer parameters compared to other deep networks. The model is effective for accurate image classification [40].
InceptionV3 is a convolutional network model used in deep learning. This model is effective for complex classification tasks. The architecture uses modular blocks called Inception modules. These modules apply convolutions of different sizes simultaneously. The model exploits information across multiple spatial scales. This technique significantly reduces the number of parameters when compared to other models. The model is often used as a backbone in computer vision [41].
This study uses the five previously mentioned CNN architectures. EfficientNetB0 is the base version of a family of models that uses systematic composite scaling. This method consistently scales the depth, width, and resolution to boost the network’s performance and efficiency [27]. MobileNetV2 is an efficient architecture designed to be efficient on devices with limited resources. It employs inverted bottleneck blocks and separable depth convolutions to reduce the number of parameters needed [39].
Deeper architectures are also evaluated. ResNet50 is a 50-layer neural network. Its main innovation is the use of residual or skip connections, which allow information to bypass layers. This mechanism helps solve the vanishing gradient problem, allowing the training of deeper networks [26]. DenseNet121 uses dense connections, in which each layer is directly connected to all subsequent layers within the same block. This feature promotes feature reuse and alleviates gradient fading [40]. InceptionV3 uses Inception modules that apply convolutions of different sizes simultaneously. This allows the model to exploit information across multiple spatial scales [41].
3.2. Tools and Technologies
Experimental development is done in Python v3.12. This programming language is widely adopted in data science. It has a mature ecosystem and is compatible with several scientific libraries [42]. The manipulation, transformation, and preliminary analysis of the information are performed using Pandas v2.2.2 [43]. The tasks of preprocessing, stratified data partitioning, and evaluation of classical models are handled using Scikit-learn v1.6.1 [44]. The graphical representation and visual exploration of the results are carried out using Matplotlib v3.10.0 and Seaborn v0.13.2 [45]. All the tools mentioned are consolidated in analytical and research work.
The implementation, training, validation, and testing of the deep learning models are performed using Keras v3.13.2 [46] operating on the TensorFlow v2.19.0 backend [47]. The source did not provide information on the specific rice cultivars represented in the dataset, yet still allowed access to customization mechanisms and maintained consistency in the experimental configuration.
3.3. Dataset
This study uses the Peruvian Rice Dataset, available on Kaggle [48]. The dataset was obtained from a publicly available collection of Peruvian rice grain images. The source did not provide information regarding the specific rice cultivars represented in the dataset. Consequently, the present study focuses on visual defect classification rather than cultivar identification. Since grain morphology may vary among rice varieties, future studies should evaluate the proposed models using datasets with explicit varietal information and broader genetic diversity.
To ensure full reproducibility, we provide the data preprocessing pipeline and experimental configuration in a public GitHub repository: https://github.com/SantiagoAviles/Rice-Proyect (accessed on 13 April 2026). This resource was created in a mill in Lambayeque, Peru, for use in quality classification projects. The dataset contains 6599 images in PNG format, each with a resolution of pixels. During the initial data inspection, a cleaning phase was performed to identify and remove several corrupted images from the source. This ensures that only valid and readable files are included in the experimental pipeline.
Figure 1 shows the number of images for each of the classes, where a clear imbalance can be seen, illustrates this imbalance. Figure 2 shows representative examples of the four classes considered in the study (Whole, Stained, Broken, and Chalky), highlighting the visual variability characteristic of each category. These images are original samples from the dataset and provide context for the morphological differences that the models must learn to distinguish.
Figure 1.
Original count of the four classes before cleaning and balancing.
Figure 2.
Dataset images: (a) View of the 4 types of rice grains. (b) View of the 4 types of rice grains generated in the augmentation process.
3.4. Proposed Methodology
The proposed methodology was designed to provide a systematic, reproducible framework for rice grain defect classification using deep learning models. As illustrated in Figure 3, the workflow comprises two main stages: dataset partitioning and data augmentation, followed by the training and evaluation process of the selected convolutional neural network architectures. These stages were implemented to establish a balanced dataset, minimize potential sources of bias, and enable a fair comparison of model performance across the four rice grain defect categories.
Figure 3.
Proposed methodology.
3.4.1. Dataset Partition and Data Augmentation
To ensure a rigorous and unbiased evaluation of the deep learning models, a strict stratified hold-out validation strategy was implemented, completely isolating the evaluation phases from the data synthesis process. The original dataset (6599 images) was first partitioned into training (70%), validation (15%), and test (15%) subsets. This critical sequencing guarantees that both the validation and test sets remain completely untainted by synthetic data, preserving an authentic representation of real-world visual distributions for final performance verification. To prevent potential data leakage, all experiments reported in this study were conducted using a split-then-augment strategy, in which dataset partitioning was performed before any augmentation was applied. Consequently, augmented versions of the same original image could not appear across different subsets. All reported results, figures, tables, and statistical analyses are based exclusively on this corrected experimental pipeline.
Following the data split, data augmentation techniques were applied strictly and exclusively to the training set. The original training partition inherently suffered from a severe class imbalance, with conforming grains (Whole) heavily outnumbering the defective subcategories (Stained, Broken, and Chalky). To mitigate this discrepancy and prevent the networks from developing an architectural bias toward the majority class, online data augmentation operations—including random rotations, geometric zooming, shifting, and flipping—were applied solely to the training samples in Keras. This process balanced the training distribution to a total of 9007 images, while the validation and test sets were maintained in their pristine, imbalanced state to serve as a reliable benchmark. The integrity of the images was checked and verified, eliminating any corrupted files. One corrupted image was subsequently removed from the augmented training set (Whole class), resulting in the final counts.
Table 2 summarizes the distributions of the dataset subsets used in the experiment. The total number of images used during the training and evaluation phases was 10,989. Each sample corresponds to an RGB image of a single grain of rice on a uniform background.
Table 2.
Distribution of samples across training, validation, and test sets.
Figure 2a shows representative examples of the four classes considered in the study (Whole, Stained, Broken, and Chalky), highlighting the visual variability characteristic of each category. These images are original samples from the dataset and provide context for the morphological differences that the models must learn to distinguish. Figure 2b shows examples of grains generated during the augmentation process applied to the minority classes within the training set. These synthetic samples reflect the transformations applied, demonstrating how data augmentation helped mitigate class imbalance and improve training effectiveness.
3.4.2. Training and Evaluation Process
The model training step was structured into two distinct sequential phases to optimize the benefits of transfer learning while enabling deep semantic adaptation to the subtle visual boundaries characterizing rice grain defects.
Phase 1: Feature Extraction (Frozen Base): In the initial phase, the convolutional backbones of the five evaluated architectures (MobileNetV2, EfficientNetB0, ResNet50, DenseNet121, and InceptionV3) were loaded using pretrained weights from the ImageNet database. The entire parameters of these core backbones were frozen (trainable = False), serving as static, high-level feature extractors. Optimization was directed exclusively toward a custom classification head consisting of a GlobalAveragePooling2D layer, a Dense layer with 256 units and ReLU activation, Batch Normalization, Dropout (0.4), a second Dense layer with 128 units and ReLU activation, Dropout (0.3), and a final Dense layer with softmax activation. This phase was governed by the Adam optimizer with an initial learning rate of , utilizing categorical cross-entropy as the loss function and a standard batch size of 32. To prevent overfitting, an early stopping callback was incorporated with a patience of 3 epochs monitoring validation loss, up to a maximum limit of 20 epochs.
Phase 2: Fine-Tuning (Uniform Unfreezing): Once the classification head reached initial convergence, a fine-tuning phase was initiated. The last 10 layers of each backbone were selectively unfrozen using a uniform strategy that kept the constraint identical across all five architectures, regardless of their total depth, thereby ensuring a fair comparison. To preserve the foundational edge and texture representations learned from ImageNet, the learning rate was reduced to , permitting subtle, domain-specific adaptations of high-level feature maps to localized geometric fractures and opacity changes of Oryza sativa grains. Phase 2 was bounded by a maximum of 20 epochs, regulated by an early stopping patience of 5 epochs on validation loss. Additionally, class weights inversely proportional to class frequency were applied to penalize misclassification of more challenging minority classes.
The selected architectures (MobileNetV2, EfficientNetB0, ResNet50, DenseNet121, and InceptionV3) were chosen to represent different design paradigms in convolutional neural networks: lightweight models (MobileNetV2), compound scaling approaches (EfficientNetB0), residual learning (ResNet50), dense connectivity (DenseNet121), and multi-scale feature extraction (InceptionV3). This selection enables a comprehensive comparison of architectures with varying computational complexity and feature extraction strategies under the same experimental conditions.
Although the evaluated models are standard architectures, the novelty of this work lies in: (i) the use of a Peruvian rice dataset with real-world variability, (ii) the systematic comparison under controlled and reproducible conditions, and (iii) the analysis of defect-level classification challenges, particularly the confusion between visually similar classes such as Whole and Chalky grains, which has not been sufficiently addressed in previous studies.
The evaluation of the architectures is developed using the transfer learning technique. The MobileNetV2, EfficientNetB0, ResNet50, DenseNet121, and InceptionV3 networks are loaded with ImageNet weights, maintaining the convolutional base without the top layer and freezing its parameters. On this basis, a unified classifier is incorporated, consisting of a GlobalAveragePooling2D layer, a Dense layer with 256 units and ReLU activation, a Batch Normalization layer, a Dropout layer with a rate of 0.4, a second Dense layer with 128 units and ReLU activation, a Dropout layer with a rate of 0.3, and a final Dense layer with softmax activation for the four classes.
Model compilation and training use the categorical cross-entropy loss function and the Adam optimizer. Training is performed with the hyperparameters detailed in Table 3. The hyperparameter configuration presented was selected based on commonly adopted practices in transfer learning for image classification and agricultural computer vision applications. Adam optimizer was employed for its adaptive learning capability and proven effectiveness in training deep neural networks [49]. A learning rate of was chosen as a standard starting value that provides a suitable balance between convergence speed and training stability [23]. The batch size of 32 was selected to balance computational efficiency and gradient estimation reliability while remaining compatible with the available hardware resources [21]. Early stopping based on validation loss was incorporated to reduce the risk of overfitting and to improve model generalization. These settings are consistent with recommendations reported in previous studies involving transfer learning and agricultural image classification tasks. Final performance is determined on the test set using accuracy, precision, recall, F1-score, and the confusion matrix.
Table 3.
Training hyperparameters used. The selected values were based on commonly adopted practices in transfer learning and deep learning reported in the literature [21,23,49].
Training proceeded in two phases applied uniformly across all five architectures. In Phase 1, the convolutional base was fully frozen, and only the classification head was trained for up to 20 epochs. In Phase 2, the last 10 layers of each backbone were unfrozen and retrained with a reduced learning rate of , allowing domain-specific adaptation of high-level features while preserving the lower-level ImageNet representations. This uniform fine-tuning strategy ensures a fair comparison, as all models are subject to identical constraints regardless of their total number of layers. Additionally, class weights, inversely proportional to class frequency, were applied during training to penalize the misclassification of minority classes, particularly Chalky grains.
Model training is performed using the training set, while the validation set guides hyperparameter tuning and early stopping. The final evaluation of model performance is conducted on the independent test set, ensuring an unbiased assessment of generalization capability. This process starts by applying transfer learning to the Peruvian Rice Dataset through a standardized classifier. Each model is trained under identical conditions using balancing and early stopping techniques to ensure objectivity. A single training run was performed for each architecture, and the accuracy of the resulting test set was complemented with 95% confidence intervals estimated using the Wilson score method for binomial proportions to quantify the uncertainty associated with the reported performance. Finally, to assess whether the observed differences in classification accuracy between models were statistically significant, pairwise comparisons were performed using the exact McNemar test at a significance level of . This test assesses disagreements between paired predictions on the same test samples and is particularly suitable for comparing classification models evaluated on the same dataset.
4. Results
The overall diagnostic performance on the independent test set is summarized in Table 4, highlighting clear differences among the evaluated architectures. The results reported correspond to a single training and evaluation run for each architecture. To provide a statistical assessment of the observed classification performance, 95% confidence intervals were computed using the Wilson score interval, which estimates the uncertainty of the accuracy obtained on the test set. Under the two-phase fine-tuning strategy, ResNet50 achieved the best overall results, with a test accuracy of 84.71% and a loss of 0.3765, demonstrating that residual connections combined with domain-specific fine-tuning provide effective feature discrimination for this task. EfficientNetB0 and DenseNet121 followed closely with 83.60% and 83.20%, respectively, confirming that architectures with compound scaling and dense connectivity remain competitive. MobileNetV2 achieved 82.09%, demonstrating that lightweight architectures can achieve reasonable performance under the same fine-tuning constraints. InceptionV3 obtained the lowest accuracy at 80.89%, suggesting that its multi-scale feature extraction strategy may be less suited to the subtle inter-class differences in this dataset. Overall, the results indicate that backbone selection has a meaningful effect on classification performance even under identical training conditions.
Table 4.
Overall performance comparison on the test set, including 95% confidence intervals for classification accuracy.
As shown in Table 5, pairwise comparisons among the evaluated CNN architectures were performed using the exact McNemar test. Among the ten possible comparisons, only three pairs showed statistically significant differences at the 5% significance level: MobileNetV2 versus ResNet50 (), EfficientNetB0 versus InceptionV3 (), and ResNet50 versus InceptionV3 (). No significant differences were detected for the remaining pairs, including the comparisons between ResNet50, EfficientNetB0, and DenseNet121. This finding indicates that the best-performing architectures achieved similar classification behavior on the test set, providing additional statistical evidence to support the comparative analysis beyond accuracy values alone.
Table 5.
Pairwise McNemar exact tests between CNN architectures.
Table 6 presents the class-wise F1-score comparison of the evaluated models on the test set. Overall, the highest performance was observed for the Stained and Broken classes, with F1-scores ranging from 0.8750 to 0.9354 and from 0.8872 to 0.9004, respectively, indicating that these grain categories are more easily distinguishable. In contrast, the Chalky class consistently produced the lowest F1-scores across all architectures, ranging from 0.6362 to 0.7352, highlighting the greater difficulty of identifying this defect type. ResNet50 achieved the highest F1-scores for the Whole (0.8643), Stained (0.9354), and Chalky (0.7352) classes, while EfficientNetB0 obtained the best result for Broken grains (0.9004). The comparatively lower performance for Chalky grains suggests persistent confusion with visually similar categories, particularly Whole grains, indicating that subtle differences in texture, opacity, and surface appearance remain challenging for all evaluated CNN architectures despite their overall effectiveness in rice defect classification.
Table 6.
F1-score per class on the test set.
Figure 4 illustrates the training behavior and classification performance of the MobileNetV2 model. The learning curves show a steady decrease in training loss, while the validation loss stabilizes after the initial epochs, indicating an adequate convergence with slight signs of plateauing. Similarly, the accuracy curves reveal rapid improvement in the early stages of training, followed by gradual stabilization, with training accuracy slightly surpassing validation accuracy, suggesting limited overfitting. The confusion matrix on the test set shows that the model achieves strong performance in classifying Stained and Broken grains, with high accuracy. Overall, the results indicate that MobileNetV2 provides a reasonable balance between performance and efficiency, although its discriminative capability is reduced for classes with subtle visual differences.
Figure 4.
Performance of the MobileNetV2 model. (Rows 1–2): training and validation loss (left) and accuracy (right) curves for Phase 1 (head only) and Phase 2 (fine-tuning). (Bottom): confusion matrix on the independent test set.
Figure 5 presentsthe training dynamics and classification performance of the EfficientNetB0 model. The learning curves show a smooth and consistent decrease in both training and validation loss, with minimal divergence between them, indicating stable convergence and good generalization. The accuracy curves show rapid improvement during the initial epochs, followed by gradual stabilization, with training and validation accuracies closely aligned throughout. The confusion matrix on the test set reveals strong classification performance across most classes, particularly for Stained and Broken grains, where the number of correct predictions is notably high. However, some misclassification persists between the Whole and Chalky classes, as reflected in confusion in both directions, highlighting the difficulty in distinguishing these visually similar categories. Overall, EfficientNetB0 exhibits robust, well-balanced performance, achieving high accuracy and stable learning behavior, supporting its effectiveness for automated rice defect classification.
Figure 5.
Performance of the EfficientNetB0 model. (Rows 1–2): training and validation loss (left) and accuracy (right) curves for Phase 1 (head only) and Phase 2 (fine-tuning). (Bottom): confusion matrix on the independent test set.
Figure 6 illustrates the training behavior and classification performance of the ResNet50 model. The learning curves show a progressive decrease in both training and validation loss, with gradual convergence across epochs. The accuracy curves indicate steady improvement, culminating in the highest test accuracy among the evaluated models at 84.71%. The confusion matrix on the test set shows strong performance for Broken and Stained grains, with high accuracy. Some confusion persists between Whole and Chalky classes, a pattern consistent with all evaluated architectures. Overall, ResNet50 demonstrated the strongest generalization under the two-phase fine-tuning strategy, suggesting that residual connections are particularly effective for adapting to domain-specific defect features.
Figure 6.
Performance of the ResNet50 model. (Rows 1–2): training and validation loss (left) and accuracy (right) curves for Phase 1 (head only) and Phase 2 (fine-tuning). (Bottom): confusion matrix on the independent test set.
Figure 7 shows the training behavior and classification performance of the DenseNet121 model. The learning curves indicate smooth, stable convergence, with both training and validation losses decreasing steadily and remaining closely aligned, suggesting effective learning and minimal overfitting. The accuracy curves exhibit a rapid increase during the initial epochs, followed by gradual stabilization at high values, with only a small gap between training and validation accuracy, indicating strong generalization capability. The confusion matrix on the test set demonstrates high classification performance across most classes, particularly for Stained and Broken grains, where correct predictions are dominant, and misclassifications are minimal. However, some confusion persists between Whole and Chalky classes, as evidenced by misclassification in both directions, highlighting the challenge of distinguishing between visually similar categories. Overall, DenseNet121 achieves a well-balanced performance, combining stable training dynamics with high classification accuracy, making it one of the most effective models evaluated in this study.
Figure 7.
Performance of the DenseNet121 model. (Rows 1–2): training and validation loss (left) and accuracy (right) curves for Phase 1 (head only) and Phase 2 (fine-tuning). (Bottom): confusion matrix on the independent test set.
Figure 8 presents the training dynamics and classification performance of the InceptionV3 model. The learning curves show a consistent decrease in both training and validation loss, although with slight oscillations in the later epochs, suggesting stable convergence with minor variability. The accuracy curves indicate rapid improvement during the initial training stages, followed by a plateau, with a small gap between training and validation accuracy, suggesting reasonable generalization and limited overfitting. The confusion matrix on the test set shows strong classification performance for Stained and Broken grains, with correct predictions dominant. However, as with the other models, notable confusion is observed between the Whole and Chalky classes, highlighting the persistent difficulty in distinguishing between these visually similar categories. Compared to deeper architectures, InceptionV3 achieves competitive but slightly lower performance, indicating that while its multi-scale feature extraction is effective, it may be less capable of capturing the subtle differences required for optimal discrimination in this task. Overall, the model demonstrates stable learning behavior and satisfactory classification performance, although it does not outperform the best-performing architectures.
Figure 8.
Performance of the InceptionV3 model. (Rows 1–2): training and validation loss (left) and accuracy (right) curves for Phase 1 (head only) and Phase 2 (fine-tuning). (Bottom): confusion matrix on the independent test set.
The results suggest that ResNet50 is the optimal architecture under the two-phase fine-tuning configuration, achieving the highest test accuracy of 84.71%. EfficientNetB0 and DenseNet121 follow closely, confirming that architectures with strong feature reuse and scaling strategies remain competitive for this task. The recurring difficulty in separating Whole and Chalky grains persisted across all models, underscoring that this confusion reflects an intrinsic challenge of RGB-based defect classification rather than a limitation of any single architecture.
5. Discussion
Under the transfer learning framework adopted in this study, ResNet50 achieved the highest classification performance, reaching an accuracy of 84.71% on the independent test set, followed by EfficientNetB0 (83.60%) and DenseNet121 (83.20%). The 95% confidence intervals showed substantial overlap among the top-performing architectures, suggesting that their predictive performance was relatively similar despite the observed ranking differences. This observation was further supported by the pairwise McNemar tests, which revealed no statistically significant differences among ResNet50, EfficientNetB0, and DenseNet121. These findings highlight the importance of complementing conventional performance metrics with statistical analyses when comparing deep learning models for agricultural image classification.
The results obtained are consistent with previous studies demonstrating the suitability of convolutional neural networks for rice quality assessment and grain classification. For example, Phukon et al. [50] reported that CNN-based approaches can effectively discriminate visually similar rice categories under varying acquisition conditions. In contrast, Verma et al. [51] highlighted the usefulness of deep learning techniques for automated rice inspection and classification. Likewise, Shah et al. [52] observed that different CNN architectures can achieve competitive performance in rice disease recognition tasks. However, model rankings may vary depending on the dataset characteristics and classification objective. Collectively, these studies support the idea that transfer learning combined with pretrained CNN architectures remains a practical and effective strategy for fine-grained rice image analysis.
Beyond comparing architectures, the results provide valuable insights into the visual characteristics of rice grain defects. Whole and Broken grains were generally classified with higher reliability because their distinguishing features are largely associated with grain morphology and structural integrity, which can be readily captured from RGB images. In contrast, Chalky and Stained grains depend more heavily on subtle differences in texture, opacity, and color distribution, making their discrimination more challenging. Similar observations have been reported in grain quality inspection studies, where defects linked to internal grain properties often exhibit greater visual ambiguity than defects associated with shape alterations [53].
A particularly challenging aspect of the classification task was the distinction between Whole and Chalky grains. Although chalkiness is characterized by opaque regions within the endosperm, chalky grains frequently preserve an external morphology that is very similar to that of whole grains. Consequently, the discriminative information available in RGB images is often limited to localized differences in reflectance, translucency, and surface texture. The observed confusion between these categories across all evaluated architectures suggests that the difficulty arises not only from the models’ learning capacity but also from the intrinsic visual similarity among the grain classes. Similar challenges have been documented in rice quality evaluation studies, where chalkiness is recognized as one of the most difficult grain attributes to assess consistently using image-based methods [54,55,56,57].
From an agricultural perspective, the identification of defective grains has direct implications for post-harvest processing, quality control, and commercial grading systems. Defects such as breakage, staining, and chalkiness are closely associated with market value, processing performance, and consumer acceptance. Therefore, automated systems capable of accurately distinguishing these categories may help reduce manual inspection efforts while increasing consistency and scalability in rice quality assessment. Although the evaluated models do not eliminate all classification errors, the achieved performance demonstrates the feasibility of integrating deep learning-based solutions into practical grain inspection workflows.
The comparative analysis also revealed that model complexity alone does not guarantee superior performance. While EfficientNetB0 and DenseNet121 achieved competitive results, MobileNetV2 and InceptionV3 exhibited lower classification accuracy. Similar observations have been reported by Jiang et al. [58], who found that both network architecture and training strategy substantially influenced performance in wheat disease identification. These findings are consistent with previous comparative studies in agricultural computer vision, in which lightweight architectures often offer computational advantages but may struggle to capture the subtle visual differences required for fine-grained classification tasks [59]. Nevertheless, the relatively small differences observed among the best-performing models suggest that multiple CNN architectures can provide effective solutions when appropriate transfer learning strategies and training procedures are employed.
Compared with related studies on other agricultural products, the present results further support the robustness of CNN-based approaches for defect identification. Similar findings have been reported in coffee bean classification, soybean seed quality assessment, and grain inspection applications, where deep convolutional architectures successfully captured localized visual patterns associated with quality attributes and defects [2,5,60,61]. For instance, Gulzar [62] demonstrated the effectiveness of transfer learning and modified Inception architectures for soybean classification, highlighting the potential of pretrained CNN models for agricultural image analysis beyond rice grains. This consistency across crops suggests that the advantages of deep feature extraction extend beyond rice and may apply to a broader range of agricultural quality-control scenarios.
Overall, the results demonstrate that deep learning models can effectively support automated rice grain defect classification, with ResNet50 providing the highest performance within the experimental conditions evaluated in this study. However, the statistical analyses indicate that the performance differences among the best-performing architectures were relatively small, emphasizing that model selection should consider not only predictive accuracy but also computational requirements, deployment constraints, and application-specific needs. Consequently, the findings should be interpreted as evidence of the effectiveness of CNN-based transfer learning for rice grain defect identification under the present experimental conditions rather than as proof of the universal superiority of a particular architecture.
6. Conclusions
This study evaluated the effectiveness of transfer learning for the automated classification of defective Peruvian rice grains using five pretrained convolutional neural network architectures: MobileNetV2, EfficientNetB0, ResNet50, DenseNet121, and InceptionV3. Following a revised experimental protocol that eliminated potential data leakage by partitioning the dataset before augmentation, all models identified the four grain categories (Whole, Broken, Stained, and Chalky) in RGB images, confirming the suitability of deep learning approaches for rice quality assessment.
Among the evaluated architectures, ResNet50 achieved the highest classification accuracy (84.71%) and the lowest test loss (0.3765), while EfficientNetB0 and DenseNet121 produced comparable results. The confidence interval analysis and pairwise McNemar tests revealed that performance differences among the best-performing models were relatively small, indicating that several CNN architectures can provide competitive solutions for rice grain defect classification when trained under a consistent transfer learning framework.
The analysis of class-level performance showed that discriminating between Whole and Chalky grains remained the most challenging aspect of the classification task. The visual similarity between these categories, together with subtle differences in opacity, texture, and reflectance patterns, contributed to persistent classification errors across all evaluated models. This finding highlights the intrinsic complexity of fine-grained rice defect identification and suggests that further improvements may require richer imaging modalities or more advanced feature extraction techniques.
Overall, the results demonstrate that transfer learning-based convolutional neural networks constitute an effective and scalable approach for automated rice grain inspection. The proposed methodology achieved reliable classification performance while maintaining a practical framework that may support future developments in post-harvest quality control and intelligent agricultural inspection systems.
7. Limitations and Future Work
Despite the promising results obtained in this study, some limitations should be acknowledged. First, the dataset was derived from a publicly available collection of Peruvian rice grain images, and information on the specific rice cultivars represented in the dataset was unavailable. Since Oryza sativa exhibits considerable genetic diversity, variations in grain morphology, texture, and appearance across cultivars may influence classification performance. Additionally, the dataset was collected under controlled imaging conditions, which may not fully represent the variability encountered in industrial environments, where lighting conditions, image acquisition devices, and grain presentation can differ substantially.
Future research should validate the proposed methodology on independent datasets comprising a wider range of rice cultivars and samples collected from different geographical regions to assess further the model’s generalization under diverse agricultural and imaging conditions. Furthermore, although this study focused on representative convolutional neural network architectures due to their proven effectiveness and computational efficiency in agricultural image analysis, future work may incorporate and compare emerging architectures, including Vision Transformers (ViT), Swin Transformers, and hybrid CNN–Transformer approaches. Also, future research could investigate the use of advanced synthetic data generation techniques, such as Generative Adversarial Networks (GANs), Transformer-based generative models, and diffusion models, to enhance dataset diversity and class balance while preserving realistic grain characteristics. Additional investigations could explore explainable artificial intelligence techniques, multimodal imaging strategies, and advanced feature-learning mechanisms to improve discrimination between visually similar classes, particularly Whole and Chalky grains, which consistently posed the most challenging defect-identification problem in this study.
Although 95% confidence intervals and pairwise McNemar tests were used to assess model performance, the results reported in this study are based on a single training and evaluation run for each architecture. Future work involving multiple independent runs could provide additional insight into run-to-run variability and further strengthen the robustness of comparative performance analyses. Furthermore, while the primary objective of this study was to compare transfer-learning architectures in a balanced-data setting, future research could include experiments on the original, non-augmented dataset to quantify the isolated impact of data augmentation on classification performance and class-level discrimination.
Author Contributions
Conceptualization, Y.P.V., M.K.C.F., S.A.A.C., P.A.L.B. and E.A.R.C.; methodology, Y.P.V., M.K.C.F., S.A.A.C., P.A.L.B. and E.A.R.C.; software, M.K.C.F., S.A.A.C., I.E.C.M., P.A.L.B. and E.A.R.C.; validation, P.A.L.B. and E.A.R.C.; formal analysis, Y.P.V., S.A.A.C. and P.A.L.B.; investigation, M.K.C.F., S.A.A.C., I.E.C.M., P.A.L.B. and E.A.R.C.; data curation, M.K.C.F., S.A.A.C., P.A.L.B. and E.A.R.C.; writing—original draft preparation, M.K.C.F. and E.A.R.C.; writing—review and editing, Y.P.V., M.K.C.F. and S.A.A.C.; visualization, S.A.A.C. and P.A.L.B.; supervision, Y.P.V.; project administration, M.K.C.F. and S.A.A.C.; funding acquisition, Y.P.V. All authors have read and agreed to the published version of the manuscript.
Funding
The APC was funded by the Catholic University of Santa María, Arequipa, Perú.
Institutional Review Board Statement
Not applicable.
Informed Consent Statement
Not applicable.
Data Availability Statement
The original data presented in the study are openly available in Kaggle at https://www.kaggle.com/datasets/cristhiansempertegui/dataset-de-arroz-peruano (accessed on 28 November 2025).
Acknowledgments
We acknowledge the Research Department and the Professional School of Systems Engineering of the Catholic University of Santa María for their support in the development of this research.
Conflicts of Interest
The authors declare no conflicts of interest.
References
- Bouchard, J.D.; Acevedo, B.A.; Díaz, S.F.; Maiocchi, M. Análisis multivariante aplicado al estudio de las propiedades culinarias de arroz (Oryza sativa L.) en variedades largo fino. Rev. Cienc. Tecnol. 2020, 33, 33–37. [Google Scholar] [CrossRef] [Scilit]
- Laabassi, K.; Belarbi, M.A.; Mahmoudi, S.; Mahmoudi, S.; Ferhat, K. Wheat varieties identification based on a deep learning approach. J. Saudi Soc. Agric. Sci. 2021, 20, 281–289. [Google Scholar] [CrossRef] [Scilit]
- Wijerathna-Yapa, A.; Pathirana, R. Sustainable Agro-Food Systems for Addressing Climate Change and Food Security. Agriculture 2022, 12, 1554. [Google Scholar] [CrossRef] [Scilit]
- Basso, M.F.; Neves, M.F.; de Sá, M.F.G. Agriculture evolution, sustainability and trends, focusing on Brazilian agribusiness: A review. Front. Sustain. Food Syst. 2024, 7, 1296337. [Google Scholar] [CrossRef] [Scilit]
- Patrício, D.I.; Signor, C.R.; Lângaro, N.C.; Rieder, R. Oat grains classification using deep learning. Rev. Bras. Comput. Apl. 2023, 15, 48–58. [Google Scholar] [CrossRef] [Scilit]
- Jayakumari, B.N.B.; Mambilamthoda, A.N.K.; Stephen, S.A.; Venkitesan, P.; Raghavendra, V. Coffee bean graded based on deep net models. Int. J. Electr. Comput. Eng. (IJECE) 2024, 14, 3084–3093. [Google Scholar] [CrossRef] [Scilit]
- Muthayya, S.; Sugimoto, J.; Montgomery, S.; Maberly, G. An overview of global rice production, supply, trade, and consumption. Ann. N. Y. Acad. Sci. 2014, 1324, 7–14. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Yuan, S.; Linquist, B.; Wilson, L.; Cassman, K.; Stuart, A.; Pede, V.; Miro, B.; Saito, K.; Agustiani, N.; Aristya, V.E.; et al. Sustainable intensification for a larger global rice bowl. Nat. Commun. 2021, 12, 7163. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Haefele, S.; Nelson, A.; Hijmans, R. Soil quality and constraints in global rice production. Geoderma 2014, 235, 250–259. [Google Scholar] [CrossRef] [Scilit]
- de Oliveira Carneiro, L.; Coradi, P.; Rodrigues, D.; Lima, R.; Teodoro, L.; de Moraes, R.S.; Teodoro, P.; Nunes, M.T.; Leal, M.; Lopes, L.R.; et al. Characterizing and Predicting the Quality of Milled Rice Grains Using Machine Learning Models. AgriEngineering 2023, 5, 1196–1215. [Google Scholar] [CrossRef] [Scilit]
- Pando, L.R.G.; Villacorta, H.S.; Peralta, G.S.; Aguilar, E.C.H. Siembra directa: Una alternativa para mejorar la sustentabilidad del cultivo de arroz (Oryza sativa L.) en el Perú. Prod. Agropecu. Desarro. Sosten. 2017, 6, 13–26. [Google Scholar] [CrossRef] [Scilit]
- Velesaca, H.O.; Suárez, P.L.; Mira, R.; Sappa, A. Computer vision based food grain classification: A comprehensive survey. Comput. Electron. Agric. 2021, 187, 106287. [Google Scholar] [CrossRef] [Scilit]
- Huang, L. Comparative Study of Deep Learning Neural Networks for Image Classification. Highlights Sci. Eng. Technol. 2023, 62, 78–83. [Google Scholar] [CrossRef] [Scilit]
- Aznan, A.; Gonzalez Viejo, C.; Pang, A.; Fuentes, S. Computer Vision and Machine Learning Analysis of Commercial Rice Grains: A Potential Digital Approach for Consumer Perception Studies. Sensors 2021, 21, 6354. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Komal; Sethi, G.K.; Bawa, R.K. Feature Based Qualitative Classification of Rice Varieties: A Review. J. Sci. Res. 2020, 64, 305–312. [Google Scholar] [CrossRef] [Scilit]
- Custodio, M.C.; Cuevas, R.P.; Ynion, J.; Laborte, A.G.; Velasco, M.L.; Demont, M. Rice quality: How is it defined by consumers, industry, food scientists, and geneticists? Trends Food Sci. Technol. 2019, 92, 122–137. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Lingwal, S.; Bhatia, K.; Tomer, M.S. Image-based wheat grain classification using convolutional neural network. Multimed. Tools Appl. 2021, 80, 35441–35465. [Google Scholar] [CrossRef] [Scilit]
- Xia, W.; Peng, R.; Chu, H.; Zhu, X.; Yang, Z.; Wang, Y. An Overall Real-Time Mechanism for Classification and Quality Evaluation of Rice. arXiv 2025, arXiv:2502.13764. [Google Scholar] [CrossRef] [Scilit]
- Korkmaz, A.; Talan, T.; Kosunalp, S.; Iliev, T. Comparison of deep learning models in automatic classification of coffee bean species. PeerJ Comput. Sci. 2025, 11, e2759. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Farahnakian, F.; Sheikh, J.; Farahnakian, F.; Heikkonen, J. A comparative study of state-of-the-art deep learning architectures for rice grain classification. J. Agric. Food Res. 2024, 15, 100890. [Google Scholar] [CrossRef] [Scilit]
- Bhupendra; Moses, K.; Miglani, A.; Kankar, P.K. Deep CNN-based damage classification of milled rice grains using a high-magnification image dataset. Comput. Electron. Agric. 2022, 195, 106811. [Google Scholar] [CrossRef] [Scilit]
- Wang, Y.; Su, W. Convolutional Neural Networks in Computer Vision for Grain Crop Phenotyping: A Review. Agronomy 2022, 12, 2659. [Google Scholar] [CrossRef] [Scilit]
- Hossen, M.I.; Awrangjeb, M.; Pan, S.; Mamun, A.A. Transfer learning in agriculture: A review. Artif. Intell. Rev. 2025, 58, 97. [Google Scholar] [CrossRef] [Scilit]
- Koklu, M.; Cinar, I.; Taspinar, Y.S. Classification of rice varieties with deep learning methods. Comput. Electron. Agric. 2021, 187, 106285. [Google Scholar] [CrossRef] [Scilit]
- Razavi, M.; Mavaddati, S.; Koohi, H. ResNet deep models and transfer learning technique for classification and quality detection of rice cultivars. Expert Syst. Appl. 2024, 247, 123276. [Google Scholar] [CrossRef] [Scilit]
- Saini, S.S.; Rawat, P. Deep Residual Network for Image Recognition. In Proceedings of the 2022 IEEE International Conference on Distributed Computing and Electrical Circuits and Electronics (ICDCECE); IEEE: Piscataway, NJ, USA, 2022; pp. 1–4. [Google Scholar] [CrossRef] [Scilit]
- Tan, M.; Le, Q.V. EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks. arXiv 2020, arXiv:1905.11946. [Google Scholar] [CrossRef] [Scilit]
- Bruno, A.; Moroni, D.; Martinelli, M. Efficient adaptive ensembling for image classification. Expert Syst. 2022, 42, e13424. [Google Scholar] [CrossRef] [Scilit]
- Sokudlor, N.; Laloon, K.; Junsiri, C.; Sudajan, S. Enhancing milled rice qualitative classification with machine learning techniques using morphological features of binary images. Int. J. Food Prop. 2023, 26, 2978–2992. [Google Scholar] [CrossRef] [Scilit]
- Koklu, M.; Özkan, I.A. Multiclass classification of dry beans using computer vision and machine learning techniques. Comput. Electron. Agric. 2020, 174, 105507. [Google Scholar] [CrossRef] [Scilit]
- Kurade, C.; Meenu, M.; Kalra, S.; Miglani, A.; Neelapu, B.; Yu, Y.; Ramaswamy, H. An Automated Image Processing Module for Quality Evaluation of Milled Rice. Foods 2023, 12, 1273. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Jin, B.; Zhang, C.; Jia, L.; Tang, Q.; Gao, L.; Zhao, G.; Qi, H. Identification of Rice Seed Varieties Based on Near-Infrared Hyperspectral Imaging Technology Combined with Deep Learning. ACS Omega 2022, 7, 4735–4749. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Liu, Q.; Liu, W.; Liu, Y.; Zhe, T.; Ding, B.; Liang, Z. Rice grains and grain impurity segmentation method based on a deep learning algorithm-NAM-EfficientNetv2. Comput. Electron. Agric. 2023, 209, 107824. [Google Scholar] [CrossRef] [Scilit]
- Zou, Y.; Tian, Z.; Cao, J.; Ren, Y.; Zhang, Y.; Liu, L.; Zhang, P.; Ni, J. Rice Grain Detection and Counting Method Based on TCLE-YOLO Model. Sensors 2023, 23, 9129. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Deng, R.; Tao, M.; Huang, X.; Bangura, K.; Jiang, Q.; Jiang, Y.; Qi, L. Automated Counting Grains on the Rice Panicle Based on Deep Learning Method. Sensors 2021, 21, 281. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Bari, B.S.; Islam, M.N.; Rashid, M.; Hasan, M.J.; Razman, M.; Musa, R.; Nasir, A.; Majeed, A.P. A real-time approach of diagnosing rice leaf disease using deep learning-based faster R-CNN framework. PeerJ Comput. Sci. 2021, 7, e432. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Teng, H.; Wang, Y.; Li, W.; Chen, T.; Liu, Q. Advancing Rice Disease Detection in Farmland with an Enhanced YOLOv11 Algorithm. Sensors 2025, 25, 3056. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Arias Rivas, B.A.; Machaca Mamani, J.C.; Cahuana Lipa, R.; Manrique Nugent, M.A.L. Computer vision algorithms for characterizing and classifying agro-exportable grains through size analysis and clustering techniques in Peru’s agricultural sector. Sapienza Int. J. Interdiscip. Stud. 2025, 6, e25075. [Google Scholar] [CrossRef] [Scilit]
- Sandler, M.; Howard, A.G.; Zhu, M.; Zhmoginov, A.; Chen, L.C. MobileNetV2: Inverted Residuals and Linear Bottlenecks. In Proceedings of the 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition; IEEE: Piscataway, NJ, USA, 2018; pp. 4510–4520. [Google Scholar] [CrossRef] [Scilit]
- Huang, G.; Liu, Z.; Weinberger, K.Q. Densely Connected Convolutional Networks. In Proceedings of the 2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR); IEEE: Piscataway, NJ, USA, 2016; pp. 2261–2269. [Google Scholar] [CrossRef] [Scilit]
- Hussain, M.; Bird, J.J.; Faria, D.R. A Study on CNN Transfer Learning for Image Classification. In Proceedings of the Advances in Computational Intelligence Systems; Lotfi, A., Bouchachia, H., Gegov, A., Langensiepen, C., McGinnity, M., Eds.; Springer: Cham, Switzerland, 2019; pp. 191–202. [Google Scholar] [CrossRef] [Scilit]
- Raschka, S.; Patterson, J.; Nolet, C. Machine Learning in Python: Main Developments and Technology Trends in Data Science, Machine Learning, and Artificial Intelligence. Information 2020, 11, 193. [Google Scholar] [CrossRef] [Scilit]
- Kumar, R.; Sharma, R.; Kesar, S. Enhancing Data Processing Efficiency and Scalability: A Comprehensive Study on Optimizing Data Manipulation with Pandas. Resmilitaris 2024, 10, 112–121. [Google Scholar] [CrossRef] [Scilit]
- Bisong, E. Introduction to Scikit-learn. In Building Machine Learning and Deep Learning Models on Google Cloud Platform; Apress: Berkeley, CA, USA, 2019. [Google Scholar] [CrossRef] [Scilit]
- Achanta, A.; Boina, R. Advanced Techniques in Python for Effective Data Visualization. Int. J. Sci. Res. (IJSR) 2023, 12, 1919–1926. [Google Scholar] [CrossRef] [Scilit]
- Lee, H.; Song, J. Introduction to convolutional neural network using Keras; an understanding from a statistician. Commun. Stat. Appl. Methods 2019, 26, 591–610. [Google Scholar] [CrossRef] [Scilit]
- Joseph, F.J.J.; Nonsiri, S.; Monsakul, A. Keras and TensorFlow: A Hands-On Experience. In Advanced Deep Learning for Engineers and Scientists; Springer: Cham, Switzerland, 2021. [Google Scholar] [CrossRef] [Scilit]
- Sempertegui, C. Dataset de Arroz Peruano. 2023. Available online: https://www.kaggle.com/datasets/cristhiansempertegui/dataset-de-arroz-peruano (accessed on 28 November 2025).
- Kingma, D.P.; Ba, J. Adam: A Method for Stochastic Optimization. arXiv 2017, arXiv:1412.6980. [Google Scholar] [CrossRef] [Scilit]
- Phukon, N.; Singh, K.R.; Singh, T.S.; Datta, S.; Deb, S.; Singh, U.R.; Thingbaijam, G. Quality assessment of rice using convolution neural networks and other machine learning techniques—A comparative study. Curr. Agric. Res. J. 2024, 12, 762–772. [Google Scholar] [CrossRef] [Scilit]
- Verma, D.S.; Dafadar, M.; Mishra, J.K.; Kumar, A.; Mahato, S. AI-Enable Rice Image Classification Using Hybrid Convolutional Neural Network Models. Int. J. Intell. Syst. 2025, 2025, 5571940. [Google Scholar] [CrossRef] [Scilit]
- Shah, S.R.; Qadri, S.; Bibi, H.; Shah, S.M.W.; Sharif, M.I.; Marinello, F. Comparing Inception V3, VGG 16, VGG 19, CNN, and ResNet 50: A case study on early detection of a rice disease. Agronomy 2023, 13, 1633. [Google Scholar] [CrossRef] [Scilit]
- Fitzgerald, M.A.; Bergman, C.J.; Resurreccion, A.P.; Möller, J.; Jimenez, R.; Reinke, R.F.; Martin, M.; Blanco, P.; Molina, F.; Chen, M.; et al. Addressing the Dilemmas of Measuring Amylose in Rice. Cereal Chem. 2009, 86, 492–498. [Google Scholar] [CrossRef] [Scilit]
- Chandran, A.K.N.; Sandhu, J.; Irvin, L.; Paul, P.; Dhatt, B.K.; Hussain, W.; Gao, T.; Staswick, P.; Yu, H.; Morota, G.; et al. Rice Chalky Grain 5 regulates natural variation for grain quality under heat stress. Front. Plant Sci. 2022, 13, 1026472. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Misra, G.; Badoni, S.; Parween, S.; Singh, R.K.; Leung, H.; Ladejobi, O.; Mott, R.; Sreenivasulu, N. Genome-wide association coupled gene to gene interaction studies unveil novel epistatic targets among major effect loci impacting rice grain chalkiness. Plant Biotechnol. J. 2020, 19, 910–925. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Marschalek, R.; Silva, M.C.; Santos, S.B.d.; Manke, J.R.; Bieging, C.; Porto, G.; Wickert, E.; Andrade, A.D.A. Image—Rice Grain Scanner: A three-dimensional fully automated assessment of grain size and quality traits. Crop Breed. Appl. Biotechnol. 2017, 17, 89–97. [Google Scholar] [CrossRef] [Scilit]
- Qiu, X.; Pang, Y.; Yuan, Z.; Xing, D.; Xu, J.; Dingkuhn, M.; Li, Z.; Ye, G. Genome-Wide Association Study of Grain Appearance and Milling Quality in a Worldwide Collection of Indica Rice Germplasm. PLoS ONE 2015, 10, e0145577. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Jiang, J.; Liu, H.; Zhao, C.; He, C.; Ma, J.; Cheng, T.; Zhu, Y.; Cao, W.; Yao, X. Evaluation of diverse convolutional neural networks and training strategies for wheat leaf disease identification with field-acquired photographs. Remote Sens. 2022, 14, 3446. [Google Scholar] [CrossRef] [Scilit]
- Harahap, S.A.F.; Irmawan, I. Performance comparison of MobileNet, EfficientNet, and Inception for predicting crop disease. Sriwij. Electr. Comput. Eng. J. 2024, 1, 30–36. [Google Scholar] [CrossRef] [Scilit]
- Hassan, E. Enhancing coffee bean classification: A comparative analysis of pre-trained deep learning models. Neural Comput. Appl. 2024, 36, 9023–9052. [Google Scholar] [CrossRef] [Scilit]
- Dioses, I.A.M.; Dioses, J.L.; Aquino, R.N.; Feliciano, C.G.M.; Tababa, J.B.; Hermosura, L.F. Soybean seed quality Assessment Classification using EfficientNet B0 algorithm. In Proceedings of the 2025 21st IEEE International Colloquium on Signal Processing & Its Applications (CSPA); IEEE: Piscataway, NJ, USA, 2025; pp. 144–149. [Google Scholar] [CrossRef] [Scilit]
- Gulzar, Y. Enhancing soybean classification with modified inception model: A transfer learning approach. Emir. J. Food Agric. 2024, 36, 1–9. [Google Scholar] [CrossRef] [Scilit]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.







