Preprint
Review

This version is not peer-reviewed.

Deep Convolutional Learning for Automated Multi-Class Quality Grading and Defect Recognition of Fruits and Crop Leaves

Submitted:

31 October 2026

Posted:

03 November 2026

You are already at the latest version

Abstract
Grading harvested produce by eye is slow, depends heavily on the inspector, and yields inconsistent results from one batch to the next, which contributes to post-harvest loss and unfair pricing. This paper presents an automated grading framework based on a convolutional neural network (CNN) that goes beyond identifying which crop is in an image and instead judges its condition. Images of fruits and leaves are assigned to one of five quality grades—healthy, ripe, unripe, pest-damaged, and rotten—so that maturity stage and common defects are recognized within a single model. The pipeline combines image normalization and enhancement, extensive data augmentation, hierarchical feature learning, and a softmax classifier trained with cross-entropy loss and the Adam optimizer. On a held-out test set the model reaches 94.9% accuracy and a macro-averaged F1-score of 94.8%, surpassing a support vector machine trained on hand-crafted features by 8.4 percentage points while needing only about 21 ms per image. These results indicate that the approach is accurate and fast enough to support real-time sorting and supply-chain decisions in precision agriculture.
Keywords: 
;  ;  ;  ;  ;  ;  ;  
Subject: 
Engineering  -   Other

I. Introduction

Agriculture underpins food security, rural employment, and a large share of industrial raw materials worldwide, yet a substantial fraction of what is harvested never reaches the consumer in saleable condition. Much of this post-harvest loss is linked to how produce is sorted and graded. In most supply chains grading is still carried out by human inspectors, a process that is labor-intensive, subjective, and prone to fatigue-related errors, so two inspectors—or the same inspector at different times—may assign different grades to the same item. As markets demand standardized, traceable, and high-throughput quality control, interest in automated, vision-based grading has grown rapidly [5,13,18].
Advances in artificial intelligence (AI), and in particular in deep learning, have made computer vision a practical tool for monitoring and classifying crops. Convolutional neural networks (CNNs) learn layered representations directly from pixels, removing the need for manually engineered color or texture descriptors and generalizing better across datasets and acquisition conditions [7,8,13]. However, much of the published work treats agricultural imaging as a problem of identifying the crop species or diagnosing a single disease, typically as a binary or narrowly scoped multi-class task [7]–[9]. Such formulations overlook the broader set of attributes
that actually determine commercial value: maturity stage, the presence and severity of pest damage, bruising, and decay. Accurate multi-grade assessment of these attributes drives market segmentation, pricing, and compliance with export standards [18,20].
Maturity estimation and leaf-health assessment are two especially important cases. Knowing the ripeness of fruit allows harvest to be timed correctly and reduces spoilage during storage and transport, while early recognition of pest attack or rot prevents a localized problem from spreading through a consignment [1,3,16]. Deep networks are well suited to capturing the subtle differences in color, texture, and shape that separate sound produce from defective produce [18], but practical deployment is still hampered by variable illumination, occlusion, cluttered backgrounds, and a shortage of labeled training images [13]. Pre-processing, augmentation, and transfer learning are commonly used to mitigate these issues [20,21].
Against this background, this work develops a single CNN-based framework that grades both fruits and leaves according to ripeness and defect condition. The main contributions are as follows:
  • A five-class grading formulation (healthy, ripe, unripe, pest-damaged, rotten) that jointly captures maturity and defect state rather than crop identity alone.
  • An end-to-end pipeline, summarized in Figure 1 and Algorithm 1, that integrates image enhancement, augmentation for robustness to field conditions, deep feature extraction, and softmax classification.
  • A quantitative evaluation using accuracy, class-wise precision, recall, and F1-score, inference latency, and a comparison with a conventional machine-learning baseline.
The remainder of the paper is organized as follows. Section II reviews related work, Section III describes the proposed methodology, Section IV reports and discusses the experimental results, Section V examines limitations and future directions, and Section VI concludes the paper.

III. Proposed Methodology

The proposed framework follows the eight-stage workflow shown in Figure 1, from image acquisition through to the delivery of a quality grade. Each stage is described below.

A. Data Collection and Preparation

Images of fruits and leaves were gathered from real field conditions and from publicly available agricultural image repositories. Each image was labeled with one of five quality grades—healthy, ripe, unripe, pest-damaged, or rotten—according to predefined grading criteria, and all images were rescaled to a common resolution so that the network receives inputs of identical size. The labeled collection was then partitioned into training, validation, and test subsets in an 80:10:10 ratio, so that model selection and final evaluation are performed on images not seen during training.

B. Pre-processing and Augmentation

Pre-processing aims to make relevant visual features more prominent and to suppress noise. It includes intensity normalization, contrast adjustment, color-space normalization, and, where necessary, removal of the background around the fruit or leaf. To enlarge the effective size and diversity of the training set and to discourage overfitting, random rotations, horizontal and vertical flips, zooming, translations, and brightness changes are applied during training. These transformations emulate the variation in illumination, orientation, and partial occlusion that the system will encounter outside the laboratory.

C. Network Architecture

The classifier is a multi-class CNN built from a stack of convolutional blocks. Each block contains convolutional layers that extract local features, followed by batch normalization to stabilize learning and a ReLU activation to introduce non-linearity. Max-pooling layers are inserted between blocks to reduce spatial resolution while retaining the strongest responses. The final feature maps are flattened and passed to fully connected layers, the last of which uses a softmax activation to output a probability for each of the five quality grades.

D. Mathematical Formulation

Feature extraction is performed by two-dimensional convolution. For the k-th filter, the response at location (i, j) is
F i , j ( k ) = ∑ m = 0 M − 1 ∑ n = 0 N − 1 I i + m ,   j + n K m , n ( k ) + b ( k )
where I is the input image (or feature map), K(k) is an M × N kernel, and b(k) is the bias of the filter. Learned kernels respond to edges, textures, and color patterns that distinguish ripeness levels and blemishes. The rectified linear unit is then applied element-wise,
A i , j ( k ) = max 0 ,   F i , j ( k )
which keeps computation inexpensive and alleviates the vanishing-gradient problem. Max-pooling over a window Ω with stride s condenses each activated map:
S i , j ( k ) = max ( m , n ) ∈ Ω A si + m ,   sj + n ( k )
Given the vector of output scores (logits) z produced by the last fully connected layer, the probability that image x belongs to grade c among C = 5 grades is obtained from the softmax function,
P y = c   ∣   x = e zc ∑ k = 1 C e zk
and the predicted grade is the one with the highest probability. Training minimizes the categorical cross-entropy
L = − ∑ c = 1 C y c logP y = c   ∣   x
where yc equals 1 for the true grade and 0 otherwise. Parameters θ are updated with the Adam optimizer,
θ t + 1 = θ t − η m t v t + ε
where mt and vt are the bias-corrected first- and second-moment estimates of the gradient, η is the learning rate, and ε is a small constant for numerical stability.
E. Training Procedure 
Algorithm 1 summarizes the complete training and deployment procedure. Learning rate, batch size, and number of epochs were tuned on the validation set, and training and validation loss curves were monitored to detect overfitting and confirm convergence. If validation accuracy fails to reach the required threshold, the hyper-parameters are adjusted and the network is retrained.
Algorithm 1 CNN-Based Multi-Class Crop Quality Grading
1: Input: labeled image set D; Output: trained grading model
2: Initialize network weights and biases
3: Resize, normalize, and enhance every image in D
4: Partition D into training, validation, and test sets (80:10:10)
5: for epoch = 1 to E do
6:  for each mini-batch of augmented training images do
7:   Extract features with (1)–(3)
8:   Compute grade probabilities with (4)
9:   Evaluate loss (5) and update θ with (6)
10:  end for
11:  Evaluate on validation set; stop early if loss stops improving
12: end for
13: if validation accuracy ≥ threshold then test on unseen data and deploy
14: else retune hyper-parameters and repeat training
15:  return trained model

F. Evaluation Metrics

Besides overall accuracy, performance is reported per grade using precision, recall, and F1-score, computed from the true positives (TP), false positives (FP), and false negatives (FN) of each class c:
Pr c = TP c TP c + FP c , Rec c = TP c TP c + FN c
F 1 c = 2   Pr c Rec c Pr c + Rec c , F 1 macro = 1 C ∑ c = 1 C F 1 c
The macro average weights every grade equally, which prevents strong performance on common grades from masking weak performance on rarer defect grades. A confusion matrix is also examined to identify which grades are confused with one another.

IV. Experimental Results

A. Training Behavior

The network was trained for up to 50 epochs with a mini-batch size of 32 and an initial learning rate of 0.001 using Adam. Training loss fell steadily from 1.42 after the first epoch to 0.08, while validation loss settled at 0.17 by epoch 45, at which point early stopping prevented further fitting to the training data. The final training and validation accuracies were 96.8% and 94.3%, respectively; the small gap of 2.5 percentage points indicates good convergence with only mild overfitting across all five grades.

B. Classification Performance

On the held-out test set the model achieved an overall accuracy of 94.9%. Table 2 lists the aggregate results and Table 3 the class-wise scores, which are also plotted in Figure 2. The rotten and healthy grades were recognized most reliably, with F1-scores of 96.0% and 95.9%, which is consistent with the strong color and texture contrast of decayed tissue and of intact produce. The unripe grade was the most difficult (F1 = 93.2%, recall = 92.5%), followed by ripe (F1 = 94.2%). The confusion matrix shows that about 3.1% of samples were exchanged between the ripe and unripe grades, a consequence of the gradual and sometimes subtle change in color during maturation. Pest-damaged samples reached an F1-score of 94.7%. Averaged over the five grades, precision, recall, and F1-score were 95.1%, 94.5%, and 94.8%, confirming balanced performance with no grade falling far behind the others.

C. Baseline Comparison and Efficiency

To quantify the benefit of learned features, the model was compared with a support vector machine (SVM) trained on hand-crafted features, which reached 86.5% test accuracy. As illustrated in Figure 3, the CNN improves on this baseline by 8.4 percentage points. Inference requires on average 0.021 s per image, or roughly 48 images per second, which is compatible with real-time grading on a sorting line.

D. Discussion

The results support three observations. First, learning features directly from the images is clearly preferable to hand-crafted descriptors for this task, as shown by the large margin over the SVM. Second, the remaining errors are concentrated between neighboring maturity stages rather than between sound and defective produce, which is the less costly type of error in practice because it affects price grade rather than food safety. Third, the low latency means accuracy has not been obtained at the expense of throughput.

V. Limitations and Future Directions

Despite the high accuracy, several challenges remain. Changes in lighting, shadows, background, and camera angle can still degrade feature extraction. Visually similar grades, especially ripe and unripe fruit, share overlapping color and texture cues and account for most misclassifications. The dataset is also imbalanced, since pest-damaged and rotten samples are less common than healthy ones, which may limit generalization to rare defects. On the practical side, consistent image quality may require good cameras and controlled positioning that small farms cannot easily provide; inference on low-power edge hardware may need further optimization; and performance depends on the size and diversity of the training data, so the model may transfer poorly to regions with different cultivars.
Future work will address these points. Deploying the model on smartphones, embedded boards, or sorting machines would enable on-field, real-time grading, and coupling it with IoT sensors and cloud platforms would support large-scale data collection and centralized supply-chain analytics. Transfer learning with efficient backbones such as MobileNet or EfficientNet could reduce computational cost while maintaining accuracy, making the system more accessible to small and medium-scale farmers. Extending the dataset to more crops, regions, and seasons would improve generalization, and explainable-AI techniques could make grading decisions more transparent to growers and buyers. In the longer term, combining image-based grading with predictive models of yield, disease outbreaks, and storage life could form a comprehensive decision-support system.

VI. Conclusion

This paper presented a CNN-based framework for multi-class quality grading and defect recognition of fruits and leaves, intended to replace slow and inconsistent manual inspection. By classifying produce into healthy, ripe, unripe, pest-damaged, and rotten grades, the system captures both maturity and common defects within a single model. Combining pre-processing, data augmentation, a convolutional architecture with batch normalization and pooling, and cross-entropy training with Adam, the model achieved 94.9% test accuracy and a macro F1-score of 94.8%, outperformed an SVM baseline by 8.4 percentage points, and processed each image in about 21 ms. Although dataset imbalance and real-world deployment constraints still need attention, the results confirm that deep-learning-based grading is a practical route toward faster, fairer, and more consistent quality control in precision agriculture.

References

  1. Zhang, X.; Adli, H. K.; Abdullah, N.; Ridzuan, F.; Wu, P. Brief review on deep learning-based tomato ripeness detection techniques for smart agriculture. AIP Conf. Proc. 2025, vol. 3338(no. 1), art. no. 020004. [Google Scholar] [CrossRef]
  2. Zhang, J.; et al. Advances in hyperspectral imaging-based non-destructive assessment of tomato quality attributes. Smart Agric. Technol. vol. 12, art. no. 101534, 2025. [CrossRef]
  3. Chen, J.; et al. Hyperspectral imaging-driven deep learning approach: Asymptomatic stage detection and severity grading of tomato yellow leaf curl disease. Smart Agric. Technol. 2025, vol. 12, art. no. 101281. [Google Scholar] [CrossRef]
  4. Bloom, Z. A.; Larsen, J. C.; Pena Martinez, E. E.; Williams, C. M.; Jones, D. S.; Kudenov, M. W. High-throughput classification and quantification of skinning phenotype in sweet potatoes. Plant Phenome J. vol. 8(no. 1), art. no. e70023, 2025. [CrossRef]
  5. Ajith, S.; Vijayakumar, S.; Elakkiya, N. Yield prediction, pest and disease diagnosis, soil fertility mapping, precision irrigation scheduling, and food quality assessment using machine learning and deep learning algorithms. Discov. Food 2025, vol. 5(no. 1), art. no. 67. [Google Scholar] [CrossRef]
  6. Swami, G.; Sheth, K.; Patel, D. PV capacity evaluation using ASTM E2848: Techniques for accuracy and reliability in bifacial systems. Smart Grid Renew. Energy 2024, 15, 201–216. [Google Scholar] [CrossRef]
  7. Zhu, R.; Zhang, J.; Huang, J.; Kang, R.; Chen, K. Research progress of crop leaf disease detection based on convolutional neural network. Trans. Chin. Soc. Agric. Eng. 2025, vol. 41(no. 7), 15–28. [Google Scholar] [CrossRef]
  8. Li, M.; et al. Wheat powdery mildew severity classification based on an improved ResNet34 model. Agriculture 2025, vol. 15(no. 15), art. no. 1580. [Google Scholar] [CrossRef]
  9. Pallavi, N.; Vijayakarthik, P.; Sushma, B. Optimizing dragon fruit quality and maturity classification through deep learning techniques. SN Comput. Sci. 2025, vol. 6(no. 6), art. no. 652. [Google Scholar] [CrossRef]
  10. Chuang, X.; et al. Improved lightweight YOLOv5n-based network for bruise detection and length classification of asparagus. Comput. Electron. Agric. vol. 233, art.(no. 110194), 2025. [CrossRef]
  11. Zhu, T.; Teng, G.; Zhang, Y.; Ni, C.; He, H. Improved YOLO v11 method for surface defect detection of tomato. Trans. Chin. Soc. Agric. Mach. 2025, vol. 56(no. 6), 546–553. [Google Scholar] [CrossRef]
  12. Noorali, N. E.; Rajabipour, A.; Sardari, H.; Hosseinpour, S. A. Detection of external defects of tomato crop using appearance parameters by convolutional neural networks. Future Foods 2025, vol. 11, art.(no. 100611). [Google Scholar] [CrossRef]
  13. Jiang, C.; Miao, K.; Hu, Z.; Gu, F.; Yi, K. Image recognition technology in smart agriculture: A review of current applications, challenges and future prospects. Processes 2025, vol. 13(no. 5), art. no. 1402. [Google Scholar] [CrossRef]
  14. Jeyabalan, S. P.; Saravanan, S.; Raj, R. M.; Anburaj, C. Seed quality assessment using partial least squares and random forest models. AIP Conf. Proc. 2025, vol. 3279(no. 1), art. no. 020205. [Google Scholar] [CrossRef]
  15. Yue, W.; Chen, X.; Cao, Q.; Tao, J.; Ruan, X. Method for evaluating rice quality based on the daily effect of meteorological factors. Trans. Chin. Soc. Agric. Eng. 2025, vol. 41(no. 4), 116–123. [Google Scholar] [CrossRef]
  16. Chen, D.; et al. YOLOv8-MDN-Tiny: A lightweight model for multi-scale disease detection of postharvest golden passion fruit. Postharvest Biol. Technol. 2025, vol. 219, art. no. 113281. [Google Scholar] [CrossRef]
  17. Weng, S.; et al. Reference-based image super-resolution of hyperspectral and red-green-blue image for determination of wheat kernel quality using deep learning networks. Eng. Appl. Artif. Intell. 2025, vol. 139, art. no. 109513. [Google Scholar] [CrossRef]
  18. Mahato, S.; et al. “Artificial intelligence and its impact on quality seeds of cereals, pulses, and oilseed crops,” in Advances in Seed Quality Evaluation and Improvement; Springer: Singapore, 2025; pp. 53–78. [Google Scholar] [CrossRef]
  19. Bautista, K.; Delgado, J. T.; Urrea, S.; Arguello, H.; García, H. Estimation of a color uniformity index in mandarins using an artificial intelligence-based system. Proc. 25th Symp. Image, Signal Process. Artif. Vis. (STSIVA), 2025. [Google Scholar] [CrossRef]
  20. Rosada, R.; Hussein, Z. M.; Novamizanti, L. Evaluating YOLO variants for real-time multi-object detection of strawberry quality and ripeness. In Proc. IEEE Int. Conf. Ind. 4.0; Artif. Intell., Commun. Technol. (IAICT), 2025; pp. 483–490. [Google Scholar] [CrossRef]
  21. Sheth, K.; Patel, D. Sensor-bias and clipping sensitivity in bifacial PV plant capacity verification. In 2026 7th International Conference on Electronics and Sustainable Communication Systems (ICESC); IEEE, 2026. [Google Scholar] [CrossRef]
Figure 1. Workflow of the proposed CNN-based crop quality grading framework. The loop from validation back to training represents hyper-parameter retuning when the accuracy threshold is not met.
Figure 1. Workflow of the proposed CNN-based crop quality grading framework. The loop from validation back to training represents hyper-parameter retuning when the accuracy threshold is not met.
Preprints 241613 g001
Figure 2. Class-wise precision, recall, and F1-score of the proposed CNN on the test set. The dashed line marks the macro-averaged F1-score.
Figure 2. Class-wise precision, recall, and F1-score of the proposed CNN on the test set. The dashed line marks the macro-averaged F1-score.
Preprints 241613 g002
Figure 3. Accuracy of the proposed CNN on the training, validation, and test sets compared with the test accuracy of the SVM baseline using hand-crafted features.
Figure 3. Accuracy of the proposed CNN on the training, validation, and test sets compared with the test accuracy of the SVM baseline using hand-crafted features.
Preprints 241613 g003
Table 1. Representative Studies on Vision-Based Crop Quality Assessment.
Table 1. Representative Studies on Vision-Based Crop Quality Assessment.
Ref. Crop Technique Task
[1] Tomato CNN review Ripeness detection
[3] Tomato HSI + deep learning Early disease detection, severity
[8] Wheat Improved ResNet34 Mildew severity grading
[9] Dragon fruit Deep CNN Maturity and quality grading
[10] Asparagus Lightweight YOLOv5n Bruise detection, length class
[16] Passion fruit YOLOv8-MDN-Tiny Post-harvest disease detection
[21] Strawberry YOLO variants Real-time quality, ripeness
Ours Fruits, leaves Multi-class CNN Ripeness + defect grading
Table 2. Overall Performance of the Proposed Model.
Table 2. Overall Performance of the Proposed Model.
Measure Value
Training accuracy 96.8%
Validation accuracy 94.3%
Test accuracy 94.9%
Macro precision / recall / F1 95.1% / 94.5% / 94.8%
SVM baseline test accuracy 86.5%
Gain over baseline +8.4 points
Inference time per image 0.021 s
Table 3. Class-Wise Precision, Recall, and F1-Score (%).
Table 3. Class-Wise Precision, Recall, and F1-Score (%).
Grade Precision Recall F1-score
Healthy 95.6 96.2 95.9
Ripe 94.8 93.7 94.2
Unripe 93.9 92.5 93.2
Pest-damaged 95.1 94.4 94.7
Rotten 96.3 95.8 96.0
Macro average 95.1 94.5 94.8
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.
Copyright: This open access article is published under a Creative Commons CC BY 4.0 license, which permit the free download, distribution, and reuse, provided that the author and preprint are cited in any reuse.