Automated Mango Fruit Classification Using Python (Research Paper) Vaishnavi Bhivgade
Automated Mango Fruit Classification Using Python (Research Paper) Vaishnavi Bhivgade
Abstract: Keeping quality criteria in the agricultural supply chain depends on mango classification and grading. Conventional
manual sorting techniques are sometimes time-consuming, inconsistent, and vulnerable to human error, which causes substantial
financial loss and quality deterioration. Incorporating picture processing and machine learning approaches, this study offers an
automated mango fruit categorization system using Python to improve precision and speed. The suggested system catches real-
time mango images, extracts important visual elements like color, texture, and form, and classifies them according on ripeness and
flaws. Including Convolutional Neural Networks (CNNs), machine learning models are taught to perform classification jobs with
great accuracy using a labeled dataset. Designed to help farmers, quality control specialists, and distributors, the solution
simplifies the grading process, lowers physical labor, and boosts market value. Experimental findings show how the system has
the ability to beat conventional approaches in terms of speed, dependability, and uniformity, hence helping to promote more
intelligent agricultural methods and improved post-harvest management.
INTRODUCTION
Particularly in underdeveloped countries where it underpins livelihoods and guarantees food security,
agriculture continues to be the cornerstone of many economies. Among agricultural areas, the fruit sector has
a major impact on world trade; mangoes are among the most frequently grown and consumed tropical fruits.
India, the biggest mango grower, is essential in satisfying worldwide as well as home consumption. Mangoes
still mostly use human labor to sort fruits depending on characteristics like size, ripeness, and obvious
blemishes. Their quality assessment and grading are rather manual.
Conventional grading techniques are sometimes arbitrary, labor-intensive, and erratic, therefore resulting in
inefficiencies and post-harvest losses. These difficulties emphasize the need for a more dependable and
automated method of fruit identification. Particularly machine learning, recent developments in picture
processing and artificial intelligence provide solutions with greater accuracy and speed to help automate this
procedure.
Utilizing Python, machine learning techniques, and real-time picture processing, this study concentrates on
the creation of an automated mango classification system. The system seeks to detect flaws and assess
ripening levels by means of key visual qualities of mangoes—such as color, shape, and surface texture—and
so improve quality control, lower labor reliance, and increase operating efficiency for farmers, agricultural
inspectors, and fruit merchants.
The methodology, data preparation, model architecture, experimental results, and pragmatic consequences of
using such a system in real-world agricultural settings are all covered in the remaining chapters.
I. RELATED WORK
Especially in fruit categorization and quality assessment, machine learning and image processing
have found much momentum in agriculture in recent years. Several studies have shown the ability of artifi -
cial intelligence (AI) to automate the fruit grading and sorting processes, hence providing better accuracy
and consistency than conventional manual methods.
Focusing on color and texture characteristics to ascertain the ripeness of mangoes, Patil et al. (2020) sug -
gested an image-based approach employing Support Vector Machines (SVM) for fruit classification. Their
method demonstrated some good outcomes but was constrained by its need of regulated lighting conditions.
Likewise, Sharma and Singh (2019) classified mangoes according on maturity using k-Nearest Neighbors
(k-NN) and feature extraction techniques like Histograms of Oriented Gradients (HOG). The model's perfor-
mance suffered, though, with noisy or complicated backgrounds.
More sophisticated approaches based on deep learning have been developed to get around such con-
straints. Widely used in fruit categorization applications are Convolutional Neural Networks (CNNs),
renowned for their great capacity to extract spatial hierarchies from images. For instance, Jadhav et al.
(2021) used a CNN-based approach to find flaws in mangoes, then trained the model on a vast dataset with
labeled images for more accurate detection.
To improve classification performance and cut down training time, other investigation has been done on
transfer learning using pre-trained models like VGG16, ResNet50, and MobileNet. In real-time situations
(Kumar et al., 2022), these models have been used effectively to categorize several fruits including mangoes,
apples, and bananas. Furthermore, allowing real-time object recognition and categorization in mobile and in-
tegrated devices are methods such as YOLO (You Only Look Once) and SSD (Single Shot MultiBox Detec-
tor).
Though these developments have happened, most current systems are built for lab-scale surroundings
and miss field-use scalability. Few studies incorporate real-time image collection, automated preprocessing,
and integration into real-world agricultural processes. This study seeks to close that gap by creating an end-
to-end solution using Python that mixes real-time image acquisition, feature extraction, and machine learn -
ing-based categorization customized for mangoes.
The suggested approach for automatic mango fruit classification is a organized pipeline consisting of image
capture, preprocessing, feature extraction, model training, and classification. For real-time use in agricultural
contexts, the approach seeks great accuracy, scalability, and flexibility.
1. Collecting information
To mimic real-world settings, high-resolution photos of mangoes were gathered in different settings and
backgrounds under different illumination levels. The dataset includes mangoes at various stages of ripeness
(raw, semi-ripe, ripe) and with different types of surface blemishes (bruises, black spots, cuts, etc.). Images
were captured with a digital camera and categorized manually by agricultural experts.
2. Image Prep
Preprocessing methods were employed to reduce noise and raise the image quality:
For consistent model input, all images were adjusted to a standard size (e.g., 224x224 pixels).
To separate the mango from the background, techniques including thresholding and contour detection were
employed.
Better color-based feature extraction was achieved by translating RGB photos into HSV or LAB color
space.
Data Augmentation: Rotation, flipping, scaling, and brightness correction were used to enlarge the dataset
and improve model generalization.
3. Feature Extraction
Among the features manually extracted are shape descriptions, texture using GLCM, and color histograms.
Convolutional Neural Networks (CNNs) were used to learn spatial characteristics directly from image data.
4. Development of models
On manually extracted features, machine learning models SVM, Random Forest, and k-NN
classifiers were taught.
TensorFlow/Keras was used to create CNN architectures including VGG16, MobileNet, and custom
lightweight CNN models.
Pre-trained models were fine-tuned on the mango dataset for better performance and faster training
time via transfer learning.
Model performance is assessed using evaluation metrics that include: Accuracy, matrix of confusion
Using a webcam or camera module, the trained model was incorporated into a user-friendly Python-based
interface able of real-time categorization. This interface can be utilized by packaging centers or by field
farmers or quality control personnel for immediate feedback.
III. RESULTS AND DISCUSSION
On a custom dataset of 2,000 mango photographs shot under different illumination and backdrop
situations, the suggested system was assessed. Unripe, Semi-ripe, Ripe; healthy, minor defect, major
defect—two main characteristics—were considered in the categorization. Data was divided into training
(70%), validation (15%), and testing (15%) categories.
1. Modeling Output
Several models were trained and evaluated for their precision and efficiency:
In terms of accuracy and processing speed, the MobileNet-based transfer learning model beat other
models, therefore making it well suited for real-time use.
2. Ripeness Categories
Distinguishing unripe, semi-ripe, and ripe mangoes, the model had average classification accuracy of
94.3%. Minimal overlap between next categories in the confusion matrix showed that the model was
successful at picking up slight variations in texture and color connected with ripeness.
3. Detect Defect
With an accuracy of 91.8%, defect detection properly identified typical surface problems including black
spots, bruises, and cuts. But problems arose when mangoes had little flaws or were less visible from their
surface.
4. Real-time execution
Suitable for real-time grading at packing plants or farms, the last model was released on a Python-based
application with webcam connection. Within one second per frame, the system processed and classified
mango images.
5. Debate
The results confirm that machine learning—especially deep learning—can greatly improve the speed and
precision of mango categorization over conventional manual techniques. The great performance of the
MobileNet model emphasizes the usefulness of transfer learning for small-sized agricultural datasets.
Poor illumination and packed backdrops somewhat hampered the performance of the model.
With only surface-level picture analysis, little or inside flaws were more difficult to identify.
Future research might investigate the addition of hyperspectral imaging or multispectral sensors to further
enhance accuracy. Moreover, a bigger and more varied dataset will enable model generalization across
various mango types and environmental conditions.
IV. ACKNOWLEDGEMENT
First of all, we are sincerely grateful to our mentor and guide, for their insightful comments, constant
support, and direction during this endeavor. Our study's course was greatly influenced by their
encouragement and helpful comments.
Additionally grateful to the MCA , G.H.R.U Amravati University for offering the required infrastructure,
tools, and friendly research setting that enabled this study.
Special thanks go to the farmers and agricultural specialists who helped us to gather and categorize the
mango data. Our system's correctness and relevance were guaranteed in large part by their cooperative
efforts and practical knowledge.
Finally, we appreciate our friends and families for their constant encouragement, patience, and motivation
during this study.
V. REFERENCES
[1] S. Arivazhagan, R. Newlin Shebiah, S. Ananthi, and S. Vishnu Varthini, "Fruit recognition using color
and texture features," Journal of Emerging Trends in Computing and Information Sciences, vol. 1, no. 2, pp.
90–94, Oct. 2010.
[2] R. P. Patil and B. D. Jadhav, "Mango ripeness identification using SVM classifier," in Proc. IEEE Int.
Conf. on Advances in Computing, Communications and Informatics (ICACCI), Udupi, India, 2017, pp.
1509–1513.
[3] S. Kamilaris and F. X. Prenafeta-Boldú, "Deep learning in agriculture: A survey," Computers and
Electronics in Agriculture, vol. 147, pp. 70–90, Apr. 2018.
[4] A. Brahim and A. Ben Atitallah, "Real-time fruit classification system using deep convolutional neural
networks," in Proc. 2019 IEEE Int. Conf. on Image Processing (ICIP), Taipei, Taiwan, 2019, pp. 2746–2750.
[5] S. Sharma and V. Singh, "Classification of mangoes based on maturity and quality using image
processing," Procedia Computer Science, vol. 93, pp. 808–814, 2016.
[6] P. Jadhav, M. Yadav, and S. Joshi, "Mango defect detection and classification using image processing
and CNN," in Proc. 2020 Int. Conf. on Emerging Trends in Information Technology and Engineering (ic-
ETITE), Vellore, India, 2020, pp. 1–5.
[7] Y. LeCun, Y. Bengio, and G. Hinton, "Deep learning," Nature, vol. 521, no. 7553, pp. 436–444, 2015.
[8] M. Abadi et al., "TensorFlow: Large-scale machine learning on heterogeneous systems," 2015. [Online].
Available: https://www.tensorflow.org/
[9] A. Krizhevsky, I. Sutskever, and G. E. Hinton, "ImageNet classification with deep convolutional neural
networks," in Proc. Advances in Neural Information Processing Systems (NeurIPS), Lake Tahoe, NV, USA,
2012, pp. 1097–1105.
[10] N. Kumar, R. P. Mahajan, and M. Aggarwal, "Detection and classification of fruit diseases using CNN
model," International Journal of Computer Sciences and Engineering, vol. 6, no. 6, pp. 418–425, 2018.
[11] S. D. Kale and S. B. Khandagle, "Automatic fruit grading system using machine learning," in Proc.
2017 Int. Conf. on Innovations in Information, Embedded and Communication Systems (ICIIECS),
Coimbatore, India, 2017, pp. 1–4.
[12] K. Simonyan and A. Zisserman, "Very deep convolutional networks for large-scale image recognition,"
arXiv preprint arXiv:1409.1556, 2014.
[13] M. Sandler, A. Howard, M. Zhu, A. Zhmoginov, and L. Chen, "MobileNetV2: Inverted residuals and
linear bottlenecks," in Proc. IEEE/CVF Conf. on Computer Vision and Pattern Recognition (CVPR), Salt
Lake City, UT, USA, 2018, pp. 4510–4520.
[14] T. Lin, P. Goyal, R. Girshick, K. He, and P. Dollár, "Focal loss for dense object detection," in Proc.
IEEE Int. Conf. on Computer Vision (ICCV), Venice, Italy, 2017, pp. 2980–2988.
[15] R. Girshick, J. Donahue, T. Darrell, and J. Malik, "Rich feature hierarchies for accurate object detection
and semantic segmentation," in Proc. IEEE Conf. on Computer Vision and Pattern Recognition (CVPR),
Columbus, OH, USA, 2014, pp. 580–587.