Next Article in Journal
Do Immersive Displays Influence Exhibition Attendees’ Satisfaction?: A Stimulus-Organism-Response Approach
Next Article in Special Issue
Understanding the Factors Influencing Consumers’ Intention toward Shifting to Solar Energy Technology for Residential Use in Saudi Arabia Using the Technology Acceptance Model
Previous Article in Journal
Implementation of Industry 4.0 Principles and Tools: Simulation and Case Study in a Manufacturing SME
Previous Article in Special Issue
Energy Efficient Clustering Protocol for FANETS Using Moth Flame Optimization
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

A Deep Learning-Based Model for Date Fruit Classification

1
Department of Management Information Systems, College of Business Administration, King Faisal University, Al-Ahsa 31982, Saudi Arabia
2
Information Security and Engineering Technology, Abu Dhabi Polytechnic, Abu Dhabi 111499, United Arab Emirates
*
Authors to whom correspondence should be addressed.
Sustainability 2022, 14(10), 6339; https://doi.org/10.3390/su14106339
Submission received: 22 April 2022 / Revised: 18 May 2022 / Accepted: 21 May 2022 / Published: 23 May 2022

Abstract

:
A total of 8.46 million tons of date fruit are produced annually around the world. The date fruit is considered a high-valued confectionery and fruit crop. The hot arid zones of Southwest Asia, North Africa, and the Middle East are the major producers of date fruit. The production of dates in 1961 was 1.8 million tons, which increased to 2.8 million tons in 1985. In 2001, the production of dates was recorded at 5.4 million tons, whereas recently it has reached 8.46 million tons. A common problem found in the industry is the absence of an autonomous system for the classification of date fruit, resulting in reliance on only the manual expertise, often involving hard work, expense, and bias. Recently, Machine Learning (ML) techniques have been employed in such areas of agriculture and fruit farming and have brought great convenience to human life. An automated system based on ML can carry out the fruit classification and sorting tasks that were previously handled by human experts. In various fields, CNNs (convolutional neural networks) have achieved impressive results in image classification. Considering the success of CNNs and transfer learning in other image classification problems, this research also employs a similar approach and proposes an efficient date classification model. In this research, a dataset of eight different classes of date fruit has been created to train the proposed model. Different preprocessing techniques have been applied in the proposed model, such as image augmentation, decayed learning rate, model checkpointing, and hybrid weight adjustment to increase the accuracy rate. The results show that the proposed model based on MobileNetV2 architecture has achieved 99% accuracy. The proposed model has also been compared with other existing models such as AlexNet, VGG16, InceptionV3, ResNet, and MobileNetV2. The results prove that the proposed model performs better than all other models in terms of accuracy.

1. Introduction

Food is one of the most fundamental needs for human life and existence. The agricultural sector works day and night to fulfill the food-related needs of the human population. Further, agriculture also plays an important role in the economic development of countries [1]. The related sectors are always looking for improvements of all kinds in all stages of agricultural activity. Over the last century, more and more technology has been adopted, transformed, and optimized in pursuit of increased yields [2]. Some of the recent examples include techniques of smart agriculture using artificial intelligence and machine learning methods [3,4], precision agriculture using information and communication technologies augmented with blockchain technology [5], and the use of biosensing technology [6].
Fruits are considered an important part of the human diet and their cultivation and production is a significant part of the overall farming activity. In this broader context, an interesting problem related to realizing the likely economic value of fruits is the detection and precise classification of fruits [7]. Several applications of classification systems can support the buying process by identifying the fruit type with its dietary value and supplying related information and advice (see e.g., [8]). However, the problem becomes more relevant in an industrial context in carrying out automation of activities such as matching fruit quality varieties with other information, e.g., nutritional details and price. Besides alleviating the labor, expense, and bias involved in manual quantification, the automated inspection also works well for multi-criteria classification and quality assurance.
Date fruit has a high nutritional value and serves as a rich source of calcium, potassium, vitamin C, and iron. Even though date palm trees are cultivated worldwide, they are considered a major type of fruit within the middle east and the Kingdom of Saudi Arabia (KSA), specifically [9]. The date palm trees cover about 72% of the total cultivated area in KSA [10], and thus the Saudi Arabian Ministry of Environment, Water, and Agriculture pays special attention to the initiatives, especially regarding date production and developments. Recently, following the recommendation by the ministry, the Food and Agriculture Organization of the United Nations (FAO) declared 2027 to be the International Year of the Date Palm [11]. As far as the aforementioned context of automated classification is concerned, many existing approaches have aimed at classifying dates [12].
In general, there are two key approaches in computer vision, i.e., deep learning (DL) and traditional techniques. The traditional approaches use techniques such as feature descriptors along with the essential step of feature extraction involving other cumbersome steps such as feature selection. Thus, one of the well-known disadvantages of the traditional approaches lies in their high dependency on human expertise in extracting hand-crafted features. Nonetheless, there are situations in which traditional techniques with global features provide satisfactory performance. DL techniques, on the other hand, enable end-to-end learning in which a model is only provided with a properly annotated dataset to be used for training. The DL model then automatically extracts the most salient features to better learn the specific details and patterns from the underlying data. DL-based techniques, despite their trade-offs regarding computational resources and training time, have been proven to perform far better than traditional algorithms in computer vision problems [13].
Despite the satisfactory results reported by traditional methods [14], DL-based approaches are naturally considered the most suitable and effective solution to the problem of date classification. Using computer vision systems for similar classification tasks has been a steadily growing research area [15]. As far as vision-based systems are concerned, convolutional neural networks (CNNs) have been well-recognized in the research community as a potent mechanism for image classification tasks [16,17]. Recent studies have also explored CNNs in the specific context of date classification for the automation of tasks, including their harvesting, sorting, and packaging [18,19]. In essence, CNNs are deep learning algorithms that take an input image and process it by assigning weights and biases to its various features. The major strength of CNNs lies in their ability to recognize (and thus classify) the distinguishing features with minimal pre-processing as compared with the primitive methods. A typical CNN comprises several layers, such as convolutional, pooling, and fully connected layers, each with a specific purpose. There have been many approaches proposed for date fruit classification such as [10,20,21] based on CNN. In [20], the authors have proposed an approach for classifying three date fruit types (Aseel, Karbalain, and Kupro) based on color, shape, and size. The approach yielded an accuracy of 89.2%. Another proposed approach [10] used a Support Vector Machine (SVM) and classified five types of date fruit based on maturity level, type, and weights with an accuracy of 99%. However, in [21], the authors have compared the performance of eight different types of existing approaches while focusing only on one type of date fruit (Medjool). They claimed that VGG-19 architecture achieved the highest accuracy (99.32%).
This research work proposes a new model for date fruit classification that is based upon deep learning and CNN. The proposed model is trained and validated based on an in-house dataset created containing eight different types of date fruits, which are commonly found in Saudi Arabia. Around 204 to 240 images have been captured for each class and rescaled to train the model. The proposed model adopts a trained MobileNetV2 architecture [22] to successfully accomplish the date fruit identification and classification. The existing model has been modified by replacing the classification layer with five different layers, aiming at increasing the accuracy and minimizing the error rate of the classification procedure. The modified model helps in optimizing the classification procedure and assists in the identification and classification of various date fruit types.
The following points summarize the contribution of this research work.
  • A detailed review has been conducted to investigate the most promising work in the machine learning/deep learning domain for date fruit classification.
  • A new dataset containing eight different types of date fruit has been created.
  • A new optimized model based on advanced deep learning techniques has been proposed for the classification of date fruit. Furthermore, different preprocessing techniques have been employed to avoid the chance of overfitting.
  • An optimization technique has been implemented to monitor any positive change in terms of accuracy in the model, based on a backup of the optimal model taken at the end of each iteration to affirm the proposed model’s accuracy with the minimum validation loss.
The rest of the paper is structured as follows. Section 2 reported and discussed the related literature to this research. Section 3 explained and illustrated the proposed model. Section 4 explains the experimental setup of this research work. The results are illustrated and explained in Section 5. The conclusions are in Section 6.

2. Related Work

Several researchers have employed artificial intelligence (AI) techniques aiming to automate many human-based tasks in the food and agriculture sector [14,23,24]. A review of the possible tasks involved in the automation has been provided in the literature [8,14,15], which includes the fruit classification, quality check, sorting, grading, maturity level, and defect detection. Naik and Patel [25] provided an overall direction for selecting the AI models suitable for fruit classification based on fruit type, features, accuracy, and classifier. Furthermore, deep learning has been used widely for fruit images classification and recognition [18]. For example, Sharmila et al. [26] proposed a model to overcome the issues of aspects detachment by applying CNNs, max-pooling layers, a fully connected multi-layer neural network, activation factors, and flattening on 10 fruit classes. Thus, the used classifier model accuracy reached 97%. In [27], a fruit classification approach was proposed that combines CNN, Recurrent Neural Networks (RNN), and a Long Short-term Memory Network (LSTM). The CNNs and RNNs were used on 10 different types of apple fruit image sample to produce discriminative characteristics of the apple fruit and its sequential labels, while LSTM was used to encode learning at each classification interval. The classification accuracy for this proposed algorithm reached 98%. Classification and quality check of date fruit, specifically, using machine learning algorithms has also become a topic of interest to several researchers [25,28]. To support this interest, Altaheri et al. [29] published a comprehensive dataset that contains 360 videos of the palms that can be used for multi-scale images, variable illumination, and different bagging states. Alresheedi et al. [9] compared detection performance and accuracy of several classical machine learning methods with CNN on a dataset comprising nine classes of dates fruit. They found that Multi-Layer Perceptron (MLP) has the highest detection performance and CNN achieved the highest accuracy.
In addition, a framework for date recognition is presented in a study by [20] which is based on color, shape, and size. Features were extracted from an established 500 images dataset of three date fruit types named Aseel, Karbalain, and Kupro. This framework was constructed based on deep CNNs with 5 neurons input and 10 neurons hidden layers. This model achieved 89.2% accuracy. In [30], K-Nearest Neighbor (KNN), Linear Discriminant Analysis, and Artificial Neural Networks (ANN) methods were also employed to classify and recognize seven different date fruit classes. The ANN method was found to be the lowest-performing method with the most accurate classifier with an accuracy that reached 99%. A solution proposed by Faisal et al. [10] consisted of three different estimation functions aiming to classify date fruits based on maturity level, type, and weights. This solution used a Support Vector Machine (SVM) and has achieved on average 99% accuracy in all the estimation functions. An additional study [19] focused on sorting date fruit based on maturity level and health condition. Thus, a dataset of four date fruit types at maturity stages, and the defective dates were used as input for the CNN model. This CNN model constructed using the VGG-16, max-pooling, batch normalization, dropout, and dense layers achieved 97% classification accuracy. On the other hand, Perez et al. [21] used only Medjool dates to evaluate and compare the performance of eight different CNNs architectures for sorting and detecting maturity stage. The results of this experiment concluded that VGG-19 architecture performed best and archived 99.32% accuracy.
Other researchers such as Alavi [31] have also proposed a system called the Mamdani fuzzy inference system (MFIS) for the quality determination of 500 Mozafati date fruit by using fuzzy logic as a method for decision making. This system classifies dates based on measuring quality, specifically the date’s length and freshness. The predicted quality accuracy of the system was compared with a human expert and resulted in a 91% accuracy rate.

3. Proposed Model

In this section, details of the proposed model are provided. An efficient model has been provided for date fruit identification and classification. The entire process included three stages: (i) dataset preparation, (ii) model training, and (iii) model testing, as shown in Figure 1. These three stages are further elaborated on in the following subsections.

3.1. Dataset Preparation

This subsection explains the development of the dataset used in this research. The dataset comprises 8 different types of date fruits commonly found in Saudi Arabia: Lubana, Khalas, Mabroom, Raziz, Ambir, Shishi, Khudri, and Safawi. The pictures of these dates were captured with a smartphone (Samsung Galaxy Note 8). The resolution of the camera was set at 12-megapixels (4032 × 3024). A tripod mobile stand of 48 cm Outer 55 W 5500 K Dimmable LED Ring Light was used to hold the smartphone to capture the images, as illustrated in Figure 2. The number of images captured for each date fruit was between 204 and 240. It is important to note that the distribution of the images was set in such a way as to avoid an imbalance in classification. Table 1 shows the frequency distribution of the dataset.
While capturing the images, a distance of 10 inches was set between the date fruit sample and the mobile phone camera. All the images were captured during the day to avoid any change in the texture of date fruits. Furthermore, a white ring light has been used to avoid any shadow effects. Figure 3 shows a sample of captured images of different types of date fruits. These images are resized (224 × 223 × 3), labeled, and arranged in separate folders after being captured.

3.2. Training

In this subsection, we report the training of the proposed model based on the created dataset. The proposed model is based on MobileNetV2 architecture [22], which was originally proposed for mobile and resource-constrained environments. The main motivation behind the adoption of this architecture includes its strength in terms of reducing the computational and memory expense as well as compliance of its design more closely to mobile applications. Originally, the MobileNetV2 contains 1000 nodes in the classification layer. However, to make it compatible with our problem, the classification layer was removed and replaced with a customized head. The new head contained five different layers: (i) average pooling layer, (ii) flatten layer, (iii) dense layer, (iv) dropout layer, and (v) softmax layer. The pool size of the average pooling layer was set to (7,7). In the flatten layer, the flattened neurons were fed to a dense layer with the activation function being Relu. This was proceeded by setting the probability of a dropout layer with a value of 0.5 and the addition of eight nodes within the classification layer of the model. This produced a modified version of the MobileNetV2 architecture having eight classification nodes, which was better suited to investigate the problem addressed in this study and more suitable for transfer learning. Figure 4 shows the proposed model for the date fruit identification and classification.
Despite being successful in many practical studies and achieving splendid success, traditional machine learning techniques still possess limitations in addressing specific real-world scenarios [32]. On the other hand, new techniques, with the help of transfer knowledge, have improved the performance of target learners in target domains. The dependency of target learners on a large volume of data has been reduced by [32,33] and minimized the issues related to the unavailability of sufficient training data. There are two ways to incorporate transfer learning. In the first case, the model is trained from scratch based on the new dataset, whereas in the other case only the newly added layers are trained based on the new dataset, and the existing layers’ weights are kept unchanged. In our proposed model, a hybrid approach was adopted in which for the first 20 iterations only, the customized head (newly added layers) was trained based on the date fruit dataset, and the rest of the layers were frozen. After that, the layers were unfrozen so that there would be a slight weight adjustment to the trained layers for the date fruit dataset.
Furthermore, in the proposed model, different preprocessing and/or model tuning techniques were used to avoid the issue of model overfitting. Such techniques are explained briefly as follows:
  • Data Augmentation: In data augmentation, different types of images are artificially created in various processing manners or by combining multiple processing methods, such as random rotations, shifts, shears, and flips. So, the MobileNetV2 architecture was modified by adding five different layers as mentioned earlier, and by incorporating many preprocessing techniques. To generate augmented images, this research work used an inbuilt function in Keras’ Library [34]. For each image, 10 different images were created randomly by incorporating different methods such as zooming the image by 20%, rotating by 30%, width shifting by 10%, and adjusting height by 10%.
  • Adaptive Learning Rate: Learning rate schedules seek to adjust the learning rate during the training process by reducing the learning rate according to the pre-defined schedule. Common learning rate schedules include time-based decay, step decay, and exponential decay. For this work, the initial learning rate was set to INIT_LR = 0.0001 and then the decay of the form decay = INIT_LT/EPOCHS was used.
  • Model Checkpointing: This is the technique where checkpoints are set to save the weights of the models whenever there is a positive change in the classification accuracy on the validation dataset. It is used to control and monitor ML models during training at some frequency (for example, at the end of each epoch/batch). It allows us to specify a quantity to monitor, such as loss or accuracy on training or a validation dataset, and thereafter it can save model weights or an entire model whenever the monitored quantity is optimum when compared to the last epoch/batch. In this research work, a model checkpoint of the form checkpoint = Model Checkpoint (fname, monitor = “val_loss”, mode = “min”, save_best_only = True, verbose = 1) was used. This callback monitored the validation loss of the model and would overwrite the trained model only when there was a decrease in the loss as compared to the previous best model.
  • Dropout: This technique is used to avoid the overfitting of a model. In this technique, neurons are randomly selected and ignored/dropped out during training. This indicates that the contribution of these neurons is temporally ignored to the activation of downstream neurons and any weight changes are not implemented on any neuron on the backward pass.

3.3. Testing

At the testing stage, the best-trained model obtained from training was tested. To test the model, a subset of the dataset was used which contained 25% of the images of the entire dataset from each class. It is essential to note that the images used in testing the model were not exposed to the model before. This is to ensure the validity of the model in terms of accuracy. The results obtained during training and testing were compared to validate the proposed model.

4. Experimental Setup

The objective of this research is to propose a model which helps in the identification and classification of different types of date fruits. The performance of the proposed model was measured along with the other models found in the literature. This section describes (i) model selection (ii) the data used for training and testing the proposed model and other models, (iii) the performance of other models compared with the proposed model. The proposed model was implemented using Python 3.0 on Windows 10 operating system, with system configuration using i7 processor with 16 GB RAM. The same configuration was used for the training and testing of other models.

4.1. Model Selection

It is important to identify which model will perform better on the created dataset. For that reason, we chose well-known models that have been used for image classification such as AlexNet [35], VGG16 [36], InceptionV3 [37], ResNet [38], and MobileNetV2 [22]. Table 2 shows the precision, recall, and Fi-score of the above-mentioned models. It can be seen that the MobileNetV2 performed better on the created dataset (date fruit data). It is important to know that these models were trained on this dataset without any preprocessing techniques. As mentioned earlier, MobileNetV2 architecture was originally proposed for mobile and resource-constrained environments. Furthermore, this architecture is efficient in terms of reducing the computational and memory expense as well as compliance of its design more closely to mobile applications. Due to these reasons, we have chosen MobileNetV2 architecture as a base model for our study.

4.2. Training and Testing Data

As mentioned earlier, each class of the date fruits contained between 200 and 240 images. These images were split into two subsets with a ratio of 3:1. In other words, two subsets of the dataset were created; one containing 75% of images used for training the models, and the other subset containing 25% of images of the dataset used for testing the models. It is important to note that the mentioned ratio is before applying the data augmentation technique.

4.3. Performance Measures

To measure the classification performance of the proposed model, a wide range of matrices were used, derived from the 2 × 2 confusion matrix.
A confusion matrix (C) is theoretically defined as Ci,j which is equal to the number of the known observations in the group (i) and predicted observations in the group (j), as shown in Figure 5.
There were four different cases in the confusion matrix as follows, from which more advanced metrics were obtained.
  • True Positive: If, for instance, a presented image is of a Lubana date fruit, and the model classifies it as a Lubana date fruit image.
  • True Negative: If, for instance, a presented image is not of Lubana date fruit, and the model does not classify it as a date fruit image.
  • False Positive: If, for instance, a presented image is not of Lubana date fruit; however, the model incorrectly classifies it as the Lubana date fruit image.
  • False Negative: If, for instance, a presented image is of Lubana date fruit; however, the model incorrectly classifies it as something else.
In the machine learning life cycle, model evaluation is an important phase to check its performance. To check the performance of our proposed model the following metrics were measured.
  • Accuracy: The proportion of the total number of correct predictions, which is a sum of total correct positive and total correct negative instances over the total number of instances.
A c c u r a c y = ( T P + T N ) / ( T P + F P + T N + F N )
  • Precision: A ratio of correct positive prediction over the total number of positively predicted instances and is computed as true positive over the sum of true positive and false positive.
P r e c i s i o n = T P / ( T P + F P )
  • Recall: A ratio of correct positive prediction over the total number of actual positive classes was computed as true positive over the sum of the true positive and false negative.
R e c a l l = T P / ( T P + F N )
  • Macro Average: The function to compute F-1 for each label and returns the average without considering the proportion for each label in the dataset.
  • Weighted Average: The function to compute F-1 for each label and returns the average considering the proportion for each label in the dataset.
We have also assessed the trained model for validation accuracy and validation loss. Furthermore, the model is being continuously monitored in terms of validation accuracy and loss to spot any noticeable deviation in training and validation performance.

5. Results

This section presents results from our experiments comparing the performance of the proposed model with Model I, Model II, and Model III (explained in detail in the following section) based on the dataset created. After that, the training and validation curves of all models are discussed. Finally, the class-wise precision and recall of all models are discussed.
The proposed model was compared with three different models, as mentioned below.
Model I:Model I was the MobileNetV2 architecture which had the classification layer modified and contained only eight nodes to classify the aforementioned date fruits.
Model II:Model II was the MobileNetV2 architecture which had the classification layer replaced with five different layers (same as the proposed model) and the last layer was customized to fit with the dataset used.
Model III:Model III was the same as Model II but in Model III the pre-existing layers of the model were frozen for the first 20 iterations and the customized head was trained alone during these iterations. After the 20th iteration, the whole model was trained.
Figure 6 shows the overall accuracy of all the four models which were trained on the date fruit dataset. From the figure, it can be concluded that Model I has the lowest accuracy of 64%. Whereas the results of Model II were better (85%) than Model I as Model II contained newly added layers. Results of Model III were slightly better than Model II with an accuracy of 88%. This was because the newly added layers were only trained for the first 20 iterations then only whole models were trained for the rest of the iterations. The accuracy of the proposed model was 99% because the proposed model contained customized heads along with other preprocessing techniques. These preprocessing techniques helped to increase the prediction rate.
Figure 7a–d presents the training and validation loss curves as well as the training and validation accuracy curves of Model I, Model II, and Model III, and the proposed model respectively. Figure 7a is the model based on the MobileVnet2 architecture, in which only the last classification node was removed. The plot represents training and validation accuracy as well as training and validation loss. The overall accuracy of this model was 64%. It can be noticed that even after 100 epochs, the model was not able to learn much about the date fruit dataset. From Figure 7a it can be noticed that there is not a smooth learning curve which indicates that the model was not able to learn much. Though the performance of the model on the training set was better compared to the validation set. Nonetheless, the performance of Model I was not promising. The training accuracy rate of this model started from 50% and increased steadily until the 100th epoch when it touched around 100%. Something can be noticed from the training loss as it started with an initial value of 2 and kept on reducing till the last epoch. Though the performance of the model on the training set was somewhat stable, it failed miserably on the test set, wherein the best accuracy reported was 64% which is far from acceptable. One of the reasons for showing poor performance was that Model I was not very suitable for the problem.
Figure 7b presents the results of Model II, in which MobileNetV2 was customized by replacing the classification layer with a customized head containing five different layers. The model was trained over 100 epochs, and the performance of the model over the training and validation set is presented in this figure. Model II resulted in a total accuracy of 85%, which is around 31% better than Model I. It can be noticed from the figure that the accuracy of this model on the training and validation set increased whereas the loss kept decreasing. However, the results are still not promising when it comes to the classification of date fruits.
Figure 7c presents the results of Model III, in which the customized head (as mentioned in Model II) was trained for the first 20 iterations, without training the rest of the layers of the MobilVnet2. The main idea behind this was to make sure that the newly added layers learned some features about the date fruit dataset. Till the 20th iteration, it was believed that the customized head had learned enough features related to the provided dataset. From the 20th iteration until the 100th iteration, the whole model (frozen layers along with the newly added layers) was trained. Figure 7c presents the training and validation curves of Model III. From the Figure, it can be noticed that the accuracy of Model III improved (88%) compared to Model II. This was because the customized head was trained separately for the first 20 iterations. From the figure, it can be seen that there was an improvement in both training and the validation sets. There were positive changes in the curves in comparison with Model II. In other words, the curves of the training and validation accuracy set kept increasing, and the loss curves kept decreasing. However, it can be noticed that there was a deviation between the performance of the training and validation sets. The model had higher accuracy on the training set, but when it came to validation accuracy, it was lower, which indicates that the model was overfitting. Due to that, we concluded that this model was not performing as expected.
Figure 7d depicts the performance of the proposed model over the training and validation sets. As mentioned in Section 3.2, the proposed model used the architecture of MobileNetV2, in which the classification layer was replaced by adding five different layers as explained in the previous section. In addition, different preprocessing techniques such as Data Augmentation, Adaptive Learning Rate, Model Checkpointing, and Dropout techniques were employed to reduce the impact of overfitting.
From Figure 7d, it can be noticed that the accuracy of the proposed model started at 40% from the first iteration and dramatically increased reaching 99% within the first 10 iterations. From the 10th iteration onwards, the accuracy of the model remained the same until the end of the 100th iteration. From the figure, it can also be noticed that the training loss started with a high value at the beginning and then dropped dramatically in successive iterations, which s considered a good characteristic of a model. Throughout the training, the proposed model maintained the lowest loss value. From the results, it can be depicted that during the training, the model performed well and outperformed all the other models in terms of accuracy. This was due to the fact that adding new layers and incorporating different preprocessing techniques was very effective and helped in increasing the accuracy rate.
During the validation process, it could also be seen that the proposed model showed stability. This was due to incorporating different preprocessing techniques. This began with the process of data collection, in which a balanced dataset was created containing almost the same number of images in each class. Further, the incorporation of the data augmentation technique helped to expose different variations of the dataset to the model. Similarly, the dropout technique played a vital role in the model’s validation performance. It made sure that the model did not deviate much from its training performance.
Table 3 presents the validation results of the proposed model for each date fruit class in terms of Precision, Recall, F1-Score, and Support (number of the instances/images of a particular class before data augmentation). From the table, it can be noticed that the precision value for almost all date fruit classes was 1. It can be also noticed that the lost precision value was 0.97 for Khurdi and Safawi. This was because the size of the Khudri and Safawi is almost the same. Likewise, the proposed model reported the maximum value for recall for most of the classes. Table 2 also reports the F1-score of all the classes.
Figure 8 presents the precision and recall of all models based on the date fruit dataset. From Figure 8a it can be noticed that Model I had the worst precision rate in all classes as compared to the other models except in the Shishi class where its precision rate was 1. Model I had poor performance over the Safawi class because it somehow resembled other classes. When it came to the performance of Model II and Model III, their precision rate was somehow acceptable as their precision rate among all classes was above 0.8, except for model II in class Safawi where the precision rate was around 0.75. The proposed model in precision rate overperformed all the models in all classes as its precision rate was around 1 for most of the classes. For Khudri and Safawi, the proposed model acquired the lowest precision rate, which was 0.97, which is still far better than any other model. Figure 8b presents the recall of all the models. From the figure, it can be noticed that Model I was poorly performing in all the classes and had the worst rate in the Ambir and Shishi classes which was less than 0.2. Whereas it can be noticed that Model II and Model III had better recall rates than Model I. Among all the models, the proposed model outperformed all the models and constantly had the highest recall across all the different date fruit classes, highlighting the success of the proposed model.
Moreover, the proposed model was compared with well-known models such as AlexNet [35], VGG16 [36], InceptionV3 [37], and ResNet [38]. To ensure a fair comparison, the above-mentioned preprocessing techniques and the same number of iterations were applied for all the mentioned models and the proposed model. Table 4 shows the results of precision, recall, and F1-score produced by AlexNEt, VGG16, InceptionV3, ResNet, and the proposed model. It can be concluded that the proposed model outperformed all the other models by achieving better values for all parameters (precision, recall, and F1-score). From the Table, it can be depicted that AlexNet performed poorly among all the models when it came to precision. However, it is InceptionV3 that had the worst recall rate among all the models. The proposed model had the highest precision, recall, and F1-score, which was due to adding five different layers to the MobileNetV2 architecture, which helped the proposed model to predict and identify different date fruit classes with the highest accuracy.
Furthermore, the proposed approach was compared with the state-of-the-art approaches in terms of qualitative and quantitative features as shown in Table 5. From the Table, it can be concluded that most of the approaches have used self-collected datasets. Most of the approaches have adopted VGG-based architecture. In contrast, the proposed approach based on the MobileNetV2 architecture performed well on the collected dataset. This architecture performed equally and efficiently as compared with the other architectures but was faster and occupied less space while processing. Additionally, this architecture is best suited for the collected dataset as it was collected using a smartphone.

6. Conclusions

In this study, a CNN-based model is proposed capable of classifying eight different popular date fruits in Saudi Arabia. The proposed model is trained on an in-house dataset which contains around 1750 images of eight different date fruits with a frequency between 204 and 240 for each class. Different preprocessing techniques have been incorporated into the proposed model to improve the accuracy rate such as decayed learning rate, model checkpointing, image augmentation, and dropout. An existing architecture (MobileNetV2) has been adopted for a proposed model for classification. In the adopted model, the last layer has been replaced by five different layers including the average pooling layer, the flatten layer, the dense layer, the dropout layer, and the softmax layer. To improve the classification performance, the model was fine-tuned. After thorough experimentation, it was concluded that the architecture with the proposed composition of layers performed better than other compositions for the specific classification task addressed in this study. Hence, this architecture was adopted for the classification as well as the comparison with other state-of-the-art approaches. The proposed model has achieved 99% accuracy and has been compared with other existing well-known models. The results have shown that the proposed model outperformed all the models in terms of accuracy. As a future avenue, more date fruit varieties can be added and a mobile application to guide the users can be developed and published. Other CNN models and the latest transformers can also be tried on the dataset. Furthermore, the current work has compared the results obtained from four different variations of architectures and adopted the best architecture for testing. However, a detailed ablation study may be conducted in the future to further analyze the possibilities.

Author Contributions

Conceptualization, Y.G. and Y.H.; Data curation, K.A. and Y.G.; Formal analysis, Y.G. and Y.H.; Funding acquisition, K.A.; Investigation, Y.G., Y.H., and A.M.; Methodology, K.A., Y.G., Y.H., and A.B.S.; Project administration, K.A. and Y.G.; Resources, Y.G. and A.B.S.; Software, Y.H.; Supervision, Y.G.; Validation, Y.G., Y.H., A.M., and A.B.S.; Visualization, K.A., Y.G., Y.H., A.M., and A.B.S.; Writing—original draft, K.A., Y.G., Y.H., A.M., and A.B.S.; Writing—review and editing, K.A., Y.G., A.M., and A.B.S. All authors have read and agreed to the published version of the manuscript.

Funding

This work was supported by the Deanship of Scientific Research, King Faisal University, Saudi Arabia grant number RA00017.

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

The dataset used in this study an in-house dataset(private) created by Authors.

Conflicts of Interest

The authors declare no conflict of interest. The funder had no role in the design of the study and in the writing of the manuscript, or in the decision to publish the results.

References

  1. Timmer, C. Agriculture and economic development revisited. Agric. Syst. 1992, 40, 21–58. [Google Scholar] [CrossRef]
  2. King, A. Technology: The Future of Agriculture. Nature 2017, 544, S21–S23. [Google Scholar] [CrossRef] [PubMed] [Green Version]
  3. Yang, X.; Shu, L.; Chen, J.; Ferrag, M.A.; Wu, J.; Nurellari, E.; Huang, K. A Survey on Smart Agriculture: Development Modes, Technologies, and Security and Privacy Challenges. IEEE/CAA J. Autom. Sin. 2020, 8, 273–302. [Google Scholar] [CrossRef]
  4. Escamilla-García, A.; Soto-Zarazúa, G.M.; Toledano-Ayala, M.; Rivas-Araiza, E.; Gastélum-Barrios, A. Applications of Artificial Neural Networks in Greenhouse Technology and Overview for Smart Agriculture Development. Appl. Sci. 2020, 10, 3835. [Google Scholar] [CrossRef]
  5. Liu, W.; Shao, X.-F.; Wu, C.-H.; Qiao, P. A systematic literature review on applications of information and communication technologies and blockchain technologies for precision agriculture development. J. Clean. Prod. 2021, 298, 126763. [Google Scholar] [CrossRef]
  6. Ali, Q.; Ahmar, S.; Sohail, M.A.; Kamran, M.; Ali, M.; Saleem, M.H.; Rizwan, M.; Ahmed, A.M.; Mora-Poblete, F.; Júnior, A.T.D.A.; et al. Research advances and applications of biosensing technology for the diagnosis of pathogens in sustainable agriculture. Environ. Sci. Pollut. Res. 2021, 28, 9002–9019. [Google Scholar] [CrossRef]
  7. Chen, X.; Zhou, G.; Chen, A.; Pu, L.; Chen, W. The fruit classification algorithm based on the multi-optimization convolutional neural network. Multimed. Tools Appl. 2021, 80, 11313–11330. [Google Scholar] [CrossRef]
  8. Hossain, M.S.; Al-Hammadi, M.H.; Muhammad, G. Automatic Fruit Classification Using Deep Learning for Industrial Applications. IEEE Trans. Ind. Informatics 2018, 15, 1027–1034. [Google Scholar] [CrossRef]
  9. Alresheedi, K.M.; Aladhadh, S.; Khan, R.U.; Qamar, A.M. Dates Fruit Recognition: From Classical Fusion to Deep Learning. Comput. Syst. Sci. Eng. 2022, 40, 151–166. [Google Scholar] [CrossRef]
  10. Faisal, M.; Albogamy, F.; Elgibreen, H.; Algabri, M.; Alqershi, F.A. Deep Learning and Computer Vision for Estimating Date Fruits Type, Maturity Level, and Weight. IEEE Access 2020, 8, 206770–206782. [Google Scholar] [CrossRef]
  11. Available online: Https://Www.Mewa.Gov.Sa/En/MediaCenter/News/Pages/News201220.Aspx (accessed on 21 April 2022).
  12. Meshram, V.; Patil, K.; Meshram, V.; Hanchate, D.; Ramkteke, S. Machine learning in agriculture domain: A state-of-art survey. Artif. Intell. Life Sci. 2021, 1, 100010. [Google Scholar] [CrossRef]
  13. O’Mahony, N.; Campbell, S.; Carvalho, A.; Harapanahalli, S.; Hernandez, G.V.; Krpalkova, L.; Riordan, D.; Walsh, J. Deep Learning vs. Traditional Computer Vision. In Proceedings of the Science and Information Conference; Springer: Berlin/Heidelberg, Germany, 2019; pp. 128–144. [Google Scholar]
  14. Behera, S.K.; Rath, A.K.; Mahapatra, A.; Sethy, P.K. Identification, classification & grading of fruits using machine learning & computer intelligence: A review. J. Ambient Intell. Humaniz. Comput. 2020, 1–11. [Google Scholar] [CrossRef]
  15. Bhargava, A.; Bansal, A. Fruits and vegetables quality evaluation using computer vision: A review. J. King Saud Univ.-Comput. Inf. Sci. 2021, 33, 243–257. [Google Scholar] [CrossRef]
  16. Sarvamangala, D.R.; Kulkarni, R.V. Convolutional neural networks in medical image understanding: A survey. Evol. Intell. 2021, 15, 1–22. [Google Scholar] [CrossRef] [PubMed]
  17. Zheng, M.; Xu, J.; Shen, Y.; Tian, C.; Li, J.; Fei, L.; Zong, M.; Liu, X. Attention-based CNNs for Image Classification: A Survey. J. Phys. Conf. Ser. 2022, 2171, 012068. [Google Scholar] [CrossRef]
  18. Altaheri, H.; Alsulaiman, M.; Muhammad, G. Date Fruit Classification for Robotic Harvesting in a Natural Environment Using Deep Learning. IEEE Access 2019, 7, 117115–117133. [Google Scholar] [CrossRef]
  19. Nasiri, A.; Taheri-Garavand, A.; Zhang, Y.-D. Image-based deep learning automated sorting of date fruit. Postharvest Biol. Technol. 2019, 153, 133–141. [Google Scholar] [CrossRef]
  20. Magsi, A.; Mahar, J.A.; Danwar, S.H. Date Fruit Recognition using Feature Extraction Techniques and Deep Convolutional Neural Network. Indian J. Sci. Technol. 2019, 12, 1–12. [Google Scholar] [CrossRef]
  21. 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]
  22. Sandler, M.; Howard, A.; 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, Salt Lake City, UT, USA, 18–28 June 2018; pp. 4510–4520. [Google Scholar]
  23. Hamid, Y.; Wani, S.; Soomro, A.B.; Alwan, A.A.; Gulzar, Y. Smart Seed Classification System Based on MobileNetV2 Architecture. In Proceedings of the 2022 2nd International Conference on Computing and Information Technology (ICCIT), Tabuk, Saudi Arabia, 25–27 January 2022; pp. 217–222. [Google Scholar]
  24. Gulzar, Y.; Hamid, Y.; Soomro, A.B.; Alwan, A.A.; Journaux, L. A Convolution Neural Network-Based Seed Classification System. Symmetry 2020, 12, 2018. [Google Scholar] [CrossRef]
  25. Naik, S.; Patel, B. Machine Vision based Fruit Classification and Grading—A Review. Int. J. Comput. Appl. 2017, 170, 22–34. [Google Scholar] [CrossRef]
  26. Sharmila, A.; Dhivya Priya, E.L.; Gokul Anand, K.R.; Sujin, J.S.; Soundarya, B.; Krishnaraj, R. Fruit Recognition Approach by Incorporating MultilayerConvolution Neural Network. In Proceedings of the 2022 4th International Conference on Smart Systems and Inventive Technology (ICSSIT), Tirunelveli, India, 20–22 January 2022; pp. 1042–1046. [Google Scholar]
  27. Gill, H.S.; Khehra, B.S. An integrated approach using CNN-RNN-LSTM for classification of fruit images. Mater. Today Proc. 2021, 51, 591–595. [Google Scholar] [CrossRef]
  28. Shoshan, T.; Bechar, A.; Cohen, Y.; Sadowsky, A.; Berman, S. Segmentation and motion parameter estimation for robotic Medjoul-date thinning. Precis. Agric. 2021, 23, 514–537. [Google Scholar] [CrossRef]
  29. Altaheri, H.; Alsulaiman, M.; Muhammad, G.; Amin, S.U.; Bencherif, M.; Mekhtiche, M. Date fruit dataset for intelligent harvesting. Data Brief 2019, 26, 104514. [Google Scholar] [CrossRef] [PubMed]
  30. Haidar, A.; Dong, H.; Mavridis, N. Image-Based Date Fruit Classification. In Proceedings of the 2012 IV International Congress on Ultra Modern Telecommunications and Control Systems, St. Petersburg, Russia, 3–5 October 2012; pp. 357–363. [Google Scholar]
  31. Alavi, N. Quality determination of Mozafati dates using Mamdani fuzzy inference system. J. Saudi Soc. Agric. Sci. 2012, 12, 137–142. [Google Scholar] [CrossRef] [Green Version]
  32. Zhuang, F.; Qi, Z.; Duan, K.; Xi, D.; Zhu, Y.; Zhu, H.; Xiong, H.; He, Q. A Comprehensive Survey on Transfer Learning. Proc. IEEE 2021, 109, 43–76. [Google Scholar] [CrossRef]
  33. Tan, C.; Sun, F.; Kong, T.; Zhang, W.; Yang, C.; Liu, C. A Survey on Deep Transfer Learning. In Proceedings of the International Conference on Artificial Neural Networks; Springer: Berlin/Heidelberg, Germany, 2018; pp. 270–279. [Google Scholar]
  34. Arnold, T.B. kerasR: R Interface to the Keras Deep Learning Library. J. Open Source Softw. 2017, 2, 296. [Google Scholar] [CrossRef] [Green Version]
  35. Krizhevsky, A.; Sutskever, I.; Hinton, G.E. Imagenet classification with deep convolutional neural networks. NIPS 2012, 60, 84–90. [Google Scholar] [CrossRef]
  36. Simonyan, K.; Zisserman, A. Very Deep Convolutional Networks for Large-Scale Image Recognition. arXiv 2014, arXiv:1409.1556v6. [Google Scholar]
  37. Szegedy, C.; Vanhoucke, V.; Ioffe, S.; Shlens, J.; Wojna, Z. Rethinking the Inception Architecture for Computer Vision. In Proceedings of the 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), Las Vegas, NV, USA, 27–30 June 2016; pp. 2818–2826. [Google Scholar]
  38. He, K.; Zhang, X.; Ren, S.; Sun, J. Deep Residual Learning for Image Recognition. In Proceedings of the 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), Las Vegas, NV, USA, 27–30 June 2016; pp. 770–778. [Google Scholar]
Figure 1. Research Flow Diagram of Proposed Model.
Figure 1. Research Flow Diagram of Proposed Model.
Sustainability 14 06339 g001
Figure 2. Setup to Capture Images of Date Fruits.
Figure 2. Setup to Capture Images of Date Fruits.
Sustainability 14 06339 g002
Figure 3. Sample Images of Eight Different Types of Date Fruit.
Figure 3. Sample Images of Eight Different Types of Date Fruit.
Sustainability 14 06339 g003
Figure 4. Proposed Customized Model for Date Fruit Classification.
Figure 4. Proposed Customized Model for Date Fruit Classification.
Sustainability 14 06339 g004
Figure 5. Confusion Matrix (Ci,j).
Figure 5. Confusion Matrix (Ci,j).
Sustainability 14 06339 g005
Figure 6. Accuracy Rate of All Models.
Figure 6. Accuracy Rate of All Models.
Sustainability 14 06339 g006
Figure 7. Performance of All Models.
Figure 7. Performance of All Models.
Sustainability 14 06339 g007
Figure 8. Precision and Recall of All Models.
Figure 8. Precision and Recall of All Models.
Sustainability 14 06339 g008
Table 1. Details of Different Types of Date Fruits and Their Image Count.
Table 1. Details of Different Types of Date Fruits and Their Image Count.
S. NoDate FruitNo. of Images
1Lubana204
2Khalas205
3Mabroom206
4Raziz203
5Ambir240
6Shishi215
7Khudri224
8Safawi220
Table 2. Precision, Recall, and F1-score of Different Models while Trained on a Date Fruit Dataset.
Table 2. Precision, Recall, and F1-score of Different Models while Trained on a Date Fruit Dataset.
ModelsPrecisionRecallF1-Score
AlexNet0.550.620.58
VGG160.620.670.64
InceptionV30.590.510.54
ResNet0.630.660.64
MobileNetV20.640.670.64
Table 3. Proposed Model Validation Results.
Table 3. Proposed Model Validation Results.
Date FruitsPrecisionRecallF1-ScoreSupport
Lubana11151
Khalas11152
Mabroom10.980.9952
Raziz11151
Ambir0.990.970.9860
Shishi10.970.9854
Khudri0.9710.9956
Safawi0.9710.9855
Accuracy--0.99431
Macro Avg0.990.990.99431
Weighted Avg0.990.990.99431
Table 4. Comparison Between the Proposed Model and Other Deep Learning Models.
Table 4. Comparison Between the Proposed Model and Other Deep Learning Models.
ModelsPrecisionRecallF1-Score
AlexNet0.700.850.77
VGG160.870.810.84
InceptionV30.750.970.77
ResNet0.850.820.83
Proposed Model0.990.990.99
Table 5. Comparison of The Proposed Model with State-of-the-art Approaches.
Table 5. Comparison of The Proposed Model with State-of-the-art Approaches.
PaperDataset Date TypesMethod/ModelClassification TypePrecision (%)Recall (%)Accuracy (%)
[18]Self-collected 5VGG-16Identification and others --99.01
[19]Self-collected4VGG-16Healthy vs. defective 96.6397.3396.98
[9]Self-collected9ALEXNETIdentification --94.2
[20]Self-collected3DNNIdentification--97.2
[10][18]5ResNetIdentification and others99.6499.0899.05
[21]Self-collected1VGG-19Sorting --99.32
Proposed ModelSelf-collected8MobileNetV2Identification99.099.099.0
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Share and Cite

MDPI and ACS Style

Albarrak, K.; Gulzar, Y.; Hamid, Y.; Mehmood, A.; Soomro, A.B. A Deep Learning-Based Model for Date Fruit Classification. Sustainability 2022, 14, 6339. https://doi.org/10.3390/su14106339

AMA Style

Albarrak K, Gulzar Y, Hamid Y, Mehmood A, Soomro AB. A Deep Learning-Based Model for Date Fruit Classification. Sustainability. 2022; 14(10):6339. https://doi.org/10.3390/su14106339

Chicago/Turabian Style

Albarrak, Khalied, Yonis Gulzar, Yasir Hamid, Abid Mehmood, and Arjumand Bano Soomro. 2022. "A Deep Learning-Based Model for Date Fruit Classification" Sustainability 14, no. 10: 6339. https://doi.org/10.3390/su14106339

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop