Skip to Content
ElectronicsElectronics
  • Article
  • Open Access

9 December 2022

Prediction of Fruit Maturity, Quality, and Its Life Using Deep Learning Algorithms

,
,
,
,
and
1
Department of Computer Science and Engineering, Lovely Professional University, Phagwara 144411, India
2
School of Computer Science (SCS), Taylor’s University, Subang Jaya 47500, Malaysia
3
Department of Software Engineering, Faculty of Engineering, Lakehead University, 955 Oliver Rd, Thunder Bay, ON P7B 5E1, Canada
4
Department of Software Engineering, College of Computer and Information Sciences, King Saud University, Riyadh 11543, Saudi Arabia

Abstract

Fruit that has reached maturity is ready to be harvested. The prediction of fruit maturity and quality is important not only for farmers or the food industry but also for small retail stores and supermarkets where fruits are sold and purchased. Fruit maturity classification is the process by which fruits are classified according to their maturity in their life cycle. Nowadays, deep learning (DL) has been applied in many applications of smart agriculture such as water and soil management, crop planting, crop disease detection, weed removal, crop distribution, strong fruit counting, crop harvesting, and production forecasting. This study aims to find the best deep learning algorithms which can be used for the prediction of fruit maturity and quality for the shelf life of fruit. In this study, two datasets of banana fruit are used, where we create the first dataset, and the second dataset is taken from Kaggle, named Fruit 360. Our dataset contains 2100 images in 3 categories: ripe, unripe, and over-ripe, each of 700 images. An image augmentation technique is used to maximize the dataset size to 18,900. Convolutional neural networks (CNN) and AlexNet techniques are used for building the model for both datasets. The original dataset achieved an accuracy of 98.25% for the CNN model and 81.75% for the AlexNet model, while the augmented dataset achieved an accuracy of 99.36% for the CNN model and 99.44% for the AlexNet model. The Fruit 360 dataset achieved an accuracy of 81.96% for CNN and 81.75% for the AlexNet model. We concluded that for all three datasets of banana images, the proposed CNN model is the best suitable DL algorithm for bananas’ fruit maturity classification and quality detection.

1. Introduction

Fruit maturity is the completeness of development, which can only take place while the fruit is still attached to the tree, and is shown by the halt of cell growth and the buildup of dry matter. Fruit maturity at harvest has a significant impact on all fruits and vegetables along the postharvest value chain in terms of quality [1]. An efficient and effective automatic model is very much needed that can identify and classify the fruits according to their maturity level within a limited time. DL technology has emerged with big data technologies and high-efficiency computing that creates new opportunities for crop harvesting and crop management in agricultural operations environments. In this study, a system is developed that can help farmers manage their fruit harvests and reduce harvest losses. The “Banana fruit” is used for the fruit maturity classification and quality identification system. In order to prevent harvesting either under- or over-matured bananas, farmers will greatly benefit from being able to recognize the age of fresh banana fruit [2]. A banana provides about 112 calories and contains water, protein, fiber, and carbohydrates. It improves kidney health and reduces amounts of fat. To reduce human efforts and automate rotten fruit identification, the authors proposed a model [3]. Apple, banana, and orange image datasets were used, and input image features were integrated using the CNN algorithm, and images were classified by max pooling, average pooling, and MobileNetV2 techniques. The CNN-based model was proposed by authors [4] to identify the rottenest bananas and classify five types of bananas: cavendish, ladyfinger, Sabri, green, and red bananas. The authors created their dataset, where 2000 banana images of each type and a total of 10,000 images are available in the dataset. Authors [5] proposed a unique CNN-based model for apple fruit categorization and quality identification. The dataset was created by the authors for this implementation, and it contains a total of 36,000 images of apples, in which it contains three classes of apples for training: (1) Premium, (2) Middle, and (3) Poor. The suggested model collected distinct, complicated, and relevant image properties for fruit identification and fruit classification. As compared with previous methods, their current proposed model has learned the two adjacent layers’ high-order features of different channels with a strong connection. Figure 1 shows the basis for the CNN model for fruit maturation classification, where each input image is sent to the first, second, and third fully connected layer and finally to output layer.
Figure 1. Basic fruit maturity classification CNN model.
The main contributions of this research are given below:
  • Augmentation methods have been applied to enhance the size of the dataset.
  • Developed a deep CNN to identify and classify bananas’ maturity range.
The rest of the paper is organized as follows: Related work is presented in Section 2. Section 3 contains the data collection. The proposed methodology is given in Section 4. Results and discussions are explained in Section 5. Finally, Section 6 contains the conclusion and future scope.

3. Data Collection

For this research, we created our dataset and used a mobile phone camera to capture images of banana fruit. We used white background (i.e., white paper in the background) to capture the right image with different angles and directions.
The Redmi Note 7 Pro mobile phone with a camera of 48 megapixels, 4 GB RAM, and 64 GB internal storage was used for dataset collection. Two datasets of banana images were used. The first dataset is created by us, and it contains images of raw, ripe, and over-ripe bananas, with 700 images in each category. The second dataset is available on Kaggle, which has 81 types of fruits, but we only used two fruits: banana and red banana, and both fruits contain 1312 banana images of size 100 × 100 × 3. Figure 2 shows the different categories of banana images from the original dataset and Fruit 360 images.
Figure 2. Ripening stages of banana fruits of the created custom dataset: (a) unripe, (b) ripe, and (c) over-ripe; for Fruit 360 dataset, Atapted with permission from Ref. [23]. Copyright © 2017–2021 Mihai Oltean: (d) ripe and (e) over-ripe.
First, we resized the captured images into 227 × 227 pixels and 112 × 112 pixels, and the Fruit 360 dataset is already resized to 100 × 100. DL-based CNN and AlexNet techniques were used for building the model for all three datasets that are the custom dataset, the augmented custom dataset, and the Fruit 360 datasets. Figure 3 shows the images of an original augmented dataset and the Fruit 360 dataset. Table 2 shows the original, augmented and Fruit 360 dataset information.
Figure 3. Banana fruit images: (a) augmented custom dataset and (b) Fruit 360 dataset, Atapted with permission from Ref. [23]. Copyright © 2017–2021 Mihai Oltean.
Table 2. Original, augmented, and Fruit 360 dataset information.
The authors (Asep Nana Hermana et al. [13]) also suggested by their experiment that by using image augmentation, over-fitting can be avoided. So, image augmentation methods are used such as affine transformation, compose transformation of 450 rotation, horizontal flip, random crop, and the different degree rotation in position augmentation to increase the original dataset size, where the augmented dataset contains 18,600 banana fruit images of 227 × 227 pixels. Three categories of ripening stages are considered for the created dataset and two categories for the Fruit 360 dataset, as images of unripe banana fruits are not available. Figure 4 shows the images after applying different augmentation techniques to the original dataset.
Figure 4. Ripe image dataset position augmentation: (a) original image, (b) random rotation 65°, (c) random rotation 135°, (d) random rotation 205°, (e) random rotation 275°, (f) center crop, (g) horizontal flip, (h) affine transformation, and (i) compose transformation of 45° rotation and horizontal flip.

4. Proposed Methodology

DL with the CNN is commonly used for image processing tasks, as convo-Nets/conv2D/cv2 can learn international symmetrical structures, find objects anywhere in the image, and retrieve abstract visual concepts by capturing increasingly difficult hierarchies. So, in this study, two DL architectures are utilized: the CNN and the AlexNet. The proposed approach is implemented using Keras and TensorFlow. For initial training and validation, common datasets are utilized. The layers of pre-processing for frequent input changes are also very scalable, as are the data loading pipelines [24,25].

4.1. AlexNet

Eight layers make up the architecture of AlexNet: three fully linked layers and five convolutional layers [26]. The network’s primary building block, the convolution layer, makes up the first layer [27]. The convolution window shape in AlexNet’s first layer is 11 by 11. The objects in ImageNet data often occupy more pixels with greater visual information, since the images in ImageNet are eight times higher and broader than the MNIST images. Therefore, to catch the object, a bigger convolution window is required. The second layer’s convolution window form is altered to 5 × 5, then 3 × 3. In addition, the network adds max-pooling layers with a window shape of 3 × 3 and a stride of 2 after the first, second, and fifth convolutional layers. There are two enormous fully linked layers with a total of 4096 outputs following the final convolutional layer [28]. The input image is given to the input layer below, as shown in Figure 5, and its pixel value is 227 as width, 227 as height, and 3D colors, which are stored as RGB. The image is then sent to the hidden layers because it contains convolutional layers of different filters, and then after processing the image is transferred to the fully connected layers and, finally, to the output layer.
Figure 5. The architecture of the AlexNet model.
When the image is transferred from the input to the first convoluted layer, it is resized depending on whether the padding is applied or not.
The size of the filter for the first layer is 96, so the size of the input image of the pooling layer will be 55 × 55 × 96 and as given in the below Table 3. All input size values are calculated using the above two formulas. When the augmented dataset is used for training, the image size is resized to 112 x 112 pixels, because when training a model with a large dataset, its RAM is insufficient for performance. So, the AlexNet model is trained, validated, and tested by reducing the image size to “112 × 112 × 3”.
Table 3. The proposed CNN model architecture.

4.2. Proposed CNN Model

A CNN is a kind of DL method made up of neurons that takes input images and assigns trainable weights and biases. Tens or even hundreds of layers can be present in a CNN, and each layer can be trained to recognize various aspects of an image. A CNN is built to automatically and adaptively learn spatial hierarchies of data by backpropagation using a number of building blocks, including convolution layers, pooling layers, and fully connected layers [29]. Each training image is subjected to filters at various resolutions, and the result of each convolved image is utilized as the input to the following layer. Beginning with relatively basic properties such as brightness and borders, the filters can get more complicated until they reach characteristics that specifically identify the object [30]. The maximum value from the area of the image that the Kernel has covered is returned by max pooling layers [29,31].
In this work, 3 convolutional layers with 2 max-pooling layers are used, where the input image size is set to 227 × 227 × 3 for the original dataset and 112 × 112 × 3 for the augmented dataset. The loss function is chosen as the cross-entropy function and Adam is chosen as the optimizer. This is because the Adam’s algorithm makes weight and offset updates more stable. A 20% dropout was used to balance training and validation accuracy and loss. Finally, the softmax activation function is applied at the output layer. The architecture of the proposed CNN model is shown in Figure 6. Table 3 shows the configuration of the proposed CNN architecture.
Figure 6. The architecture of the proposed CNN model.

5. Results and Discussion

Extensive research on fruit maturity classification and quality assessment is presented to identify fruit shelf life. This study uses two DL methods (CNN and AlexNet) with the image augmentation technique. A slight drop in accuracy is experienced at epoch 5 for the original dataset, which is removed by increasing the dataset size using the image augmentation technique. The results are shown in Figure 7, where the X-axis represents epoch number, and the Y-axis represents accuracy in the accuracy graph and loss in the loss graph.
Figure 7. Loss and accuracy graph of CNN model for (a,b).
The AlexNet, achieves 98.18% training accuracy and 81.75% validation accuracy for the original dataset with a “227 × 227 × 3” dataset image size. The augmented dataset achieved 99.80% training accuracy and 99.44% validation accuracy with an image size of “112 × 112 × 3”. The Fruit 360 dataset, which has an image size of “100 × 100 × 3”, achieved 100%, the highest training accuracy, and 89.84% validation accuracy when the proposed methodology is applied. The results of the AlexNet architecture are shown in Figure 8, where the X-axis represents epoch number, and the Y-axis represents accuracy in the accuracy graph and loss in the loss graph.
Figure 8. Loss and accuracy graph of AlexNet model for (a,b).
The proposed CNN model obtained a training accuracy of 99.18% and a validation accuracy of 98.25% on the original dataset with a 227 × 227 × 3 image size. The augmented dataset has an image size of 112 × 112 × 3 and achieved 99.42% training accuracy and 99.36% validation accuracy. The Fruit 360 dataset reached 81.75% validation accuracy, where the training accuracy is 100% and has properly classified the unripe, ripe, and over-ripe fruits, as shown in Figure 9.
Figure 9. The proposed model results for (a) unripe, (b) ripe, and (c) over-ripe.
Table 4 describes the training accuracy and validation accuracy for the three datasets for the proposed CNN model and AlexNet model. The images in the test dataset are shown in Figure 9, (a) the 3rd image is classified as unripe, (b) the 56th image is classified as ripe, and (c) the 89th image is classified as over-ripe when tested. We used bar graphs to plot 0 to unripe, 1 to ripe, and 2 to over-ripe. In Figure 9, we plotted the image and predicted values bar graph of that image.
Table 4. Training and validation accuracy for CNN and AlexNet model.

6. Conclusions and Future Work

We studied 35 different papers (research_articles) in our review paper [32] based on ML and DL techniques for fruit maturation classification, and we concluded that a CNN is the best suitable algorithm for fruit maturation classification and quality evaluation. Fruit ripening classification is a very crucial function in different fields such as the food industry, agriculture, and other industries.
In this study, we proposed two approaches using DL methods (CNN and AlexNet) for banana fruit images on our original dataset, augmented dataset, and available dataset (Fruit 360). Training and validation were conducted for both the proposed models and tested their working performance, and the accuracy rate we obtained for the original dataset is 98.25% for the CNN and 81.75% for the AlexNet model, while the augmented dataset achieved 99.36% accuracy for the CNN and 99.44% for the AlexNet model. This indicates that the classification and prediction accuracy for fruits at the ripening stage is well attained by our suggested models. The proposed methodology is limited to banana, in the future, we may use some different fruits such as mango, orange, and papaya, which are similar to bananas, as they are green when not ripe, yellow when ripe, and brown or black when over-ripe. Moreover, we will try to use our dataset for other deep learning methods for fruit maturity classification and quality assessment.

Author Contributions

Conceptualization, N.A. and U.M.; software, N.A.; validation, J.S., N.A. and U.M.; formal analysis, J.S., N.A. and U.M.; investigation, U.M.; resources, N.Z.J. and M.S.H. and A.Y.; writing—original draft preparation, N.A. and U.M.; writing—review and editing, N.Z.J. and M.S.H.; visualization, N.A.; supervision, M.S.H. and A.Y.; project administration, N.Z.J.; funding acquisition, M.S.H. All authors have read and agreed to the published version of the manuscript.

Funding

This work was supported by the Researchers Supporting Project number (RSP-2021/32), King Saud University, Riyadh, Saudi Arabia.

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. Fruit Maturity—An Overview|ScienceDirect Topics. Available online: https://www.sciencedirect.com/topics/agricultural-and-biological-sciences/fruit-maturity (accessed on 2 November 2022).
  2. Prabha, D.S.; Kumar, J.S. Assessment of banana fruit maturity by image processing technique. J. Food Sci. Technol. 2015, 52, 1316–1327. [Google Scholar] [CrossRef]
  3. Chakraborty, S.; Shamrat, F.M.J.M.; Billah, M.M.; Jubair, M.A.; Alauddin, M.; Ranjan, R. Implementation of Deep Learning Methods to Identify Rotten Fruits. In Proceedings of the 2021 5th International Conference on Trends in Electronics and Informatics (ICOEI), Tirunelveli, India, 3–5 June 2021; pp. 1207–1212. [Google Scholar] [CrossRef]
  4. Al Haque, A.F.; Hakim, M.A.; Hafiz, R. CNN Based Automatic Computer Vision System for Strain Detection and Quality Identification of Banana. In Proceedings of the 2021 International Conference on Automation, Control and Mechatronics for Industry 4.0 (ACMI), Rajshahi, Bangladesh, 8–9 July 2021. [Google Scholar] [CrossRef]
  5. Li, Y.; Feng, X.; Liu, Y.; Han, X. Apple quality identification and classification by image processing based on convolutional neural networks. Sci. Rep. 2021, 11, 16618. [Google Scholar] [CrossRef] [PubMed]
  6. Vijayalakshmi, M.; Peter, V.J. CNN based approach for identifying banana species from fruits. Int. J. Inf. Technol. 2021, 13, 27–32. [Google Scholar] [CrossRef]
  7. Iqbal, H.M.R.; Hakim, A. Classification and Grading of Harvested Mangoes Using Convolutional Neural Network. Int. J. Fruit Sci. 2022, 22, 95–109. [Google Scholar] [CrossRef]
  8. Ashtiani, S.-H.M.; Javanmardi, S.; Jahanbanifard, M.; Martynenko, A.; Verbeek, F.J. Detection of Mulberry Ripeness Stages Using Deep Learning Models. IEEE Access 2021, 9, 100380–100394. [Google Scholar] [CrossRef]
  9. Ni, J.; Gao, J.; Li, J.; Yang, H.; Hao, Z.; Han, Z. E-AlexNet: Quality evaluation of strawberry based on machine learning. J. Food Meas. Charact. 2021, 15, 4530–4541. [Google Scholar] [CrossRef]
  10. Das, P.; Yadav, J.K.P.S.; Yadav, A.K. An Automated Tomato Maturity Grading System Using Transfer Learning Based AlexNet. Ingénierie Des Systèmes D Inf. 2021, 26, 191–200. [Google Scholar] [CrossRef]
  11. Al-Masawabe, M.M.; Samhan, L.F.; AlFarra, A.H.; Aslem, Y.E.; Abu-Naser, S.S. Papaya Maturity Classifications using Deep Convolutional Neural Networks. Int. J. Eng. Inf. Syst. (IJEAIS) 2021, 5, 60–67. [Google Scholar]
  12. Miragaia, R.; Chávez, F.; Díaz, J.; Vivas, A.; Prieto, M.H.; Moñino, M.J. Plum Ripeness Analysis in Real Environment Using Deep Learning with Convolutional Neural Networks. Agronomy 2021, 11, 2353. [Google Scholar] [CrossRef]
  13. Hermana, A.N.; Rosmala, D.; Husada, M.G. Transfer Learning for Classification of Fruit Ripeness Using VGG16. In Proceedings of the ICCMB 2021: 2021 The 4th International Conference on Computers in Management and Business, Singapore, 30 January–1 February 2021; pp. 139–146. [Google Scholar] [CrossRef]
  14. Rivero Mesa, A.; Chiang, J. Non-invasive Grading System for Banana Tiers using RGB Imaging and Deep Learning. In Proceedings of the ICCAI 2021: 2021 7th International Conference on Computing and Artificial Intelligence, Tianjin, China, 23–26 April 2021; pp. 113–118. [Google Scholar] [CrossRef]
  15. Ni, J.; Gao, J.; Deng, L.; Han, Z. Monitoring the Change Process of Banana Freshness by GoogLeNet. IEEE Access 2020, 8, 228369–228376. [Google Scholar] [CrossRef]
  16. Saragih, R.E.; Emanuel, A.W.R. Banana Ripeness Classification Based on Deep Learning using Convolutional Neural Network. In Proceedings of the 2021 3rd East Indonesia Conference on Computer and Information Technology (EIConCIT), Surabaya, Indonesia, 9–11 April 2021. [Google Scholar] [CrossRef]
  17. Pérez-Pérez, B.; Vázquez, J.G.; Salomón-Torres, R. Evaluation of Convolutional Neural Networks Hyperparameters with Transfer Learning to Determine Sorting of Ripe Medjool Dates. Agriculture 2021, 11, 115. [Google Scholar] [CrossRef]
  18. Naik, S.; Rana, Y.; Thakkar, V. Mango Classification Using Shape, Texture and Convolutional Neural Network Features. In ICT Systems and Sustainability: Proceedings of ICT4SD 2021; Springer: Singapore, 2022; Volume 1. [Google Scholar] [CrossRef]
  19. Arampongsanuwat, S.; Chaowalit, O. Application of deep convolutional neural networks for mangosteen ripeness classification. ICIC Express Lett. 2021, 15, 649–657. [Google Scholar] [CrossRef]
  20. Septiarini, A.; Hamdani, H.; Hatta, H.R.; Kasim, A.A. Image-based processing for ripeness classification of oil palm fruit. In Proceedings of the 2019 5th International Conference on Science in Information Technology (ICSITech), Yogyakarta, Indonesia, 23–24 October 2019. [Google Scholar] [CrossRef]
  21. Taofik, A.; Ismail, N.; Gerhana, Y.A.; Komarujaman, K.; Ramdhani, M.A. Design of smart system to detect ripeness of tomato and chili with new approach in data acquisition. In Proceedings of the 2nd Annual Applied Science and Engineering Conference (AASEC 2017), Bandung, Indonesia, 24 August 2017. [Google Scholar] [CrossRef]
  22. Sapan, N.; Hinal, S. Classification of Mango (Mangifera indica L.) fruit varieties using Convolutional Neural Network. Retrieved 6 December 2022. Available online: https://180slearning.in/pdf_uploads/CRC_17_Sapan.pdf (accessed on 2 November 2022).
  23. Fruits 360|Kaggle. Available online: https://www.kaggle.com/datasets/moltean/fruits (accessed on 2 November 2022).
  24. Introduction to TensorFlow. Available online: https://www.tensorflow.org/learn (accessed on 2 November 2022).
  25. Krizhevsky, A.; Sutskever, I.; Hinton, G.E. ImageNet classification with deep convolutional neural networks. Commun. ACM 2017, 60, 84–90. [Google Scholar] [CrossRef]
  26. AlexNet: The Architecture That Challenged CNNs|by Jerry Wei|Towards Data Science. Available online: https://towardsdatascience.com/alexnet-the-architecture-that-challenged-cnns-e406d5297951 (accessed on 2 November 2022).
  27. Unnikrishnan, A.; Sowmya, V.; Soman, K.P. Deep AlexNet with Reduced Number of Trainable Parameters for Satellite Image Classification. Procedia Comput. Sci. 2018, 143, 931–938. [Google Scholar] [CrossRef]
  28. Deep Convolutional Neural Networks (AlexNet)—Dive into Deep Learning 1.0.0-alpha1.post0 Documentation. Available online: https://d2l.ai/chapter_convolutional-modern/alexnet.html (accessed on 2 November 2022).
  29. Yamashita, R.; Nishio, M.; Do, R.K.G.; Togashi, K. Convolutional neural networks: An overview and application in radiology. Insights Imaging 2018, 9, 611–629. [Google Scholar] [CrossRef] [PubMed]
  30. What is a Convolutional Neural Network?—MATLAB & Simulink. Available online: https://www.mathworks.com/discovery/convolutional-neural-network-matlab.html (accessed on 2 November 2022).
  31. A Comprehensive Guide to Convolutional Neural Networks—the ELI5 Way|by Sumit Saha|Towards Data Science. Available online: https://towardsdatascience.com/a-comprehensive-guide-to-convolutional-neural-networks-the-eli5-way-3bd2b1164a53 (accessed on 2 November 2022).
  32. Nagnath, A.; Usha, M. Fruit quality identification using image processing, machine learning, and deep learning: A review. Adv. Appl. Math. Sci. 2022, 21, 2645–2660. [Google Scholar]
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Article Metrics

Citations

Article Access Statistics

Multiple requests from the same IP address are counted as one view.