DATE PALM IDENTIFICATION USING DENSENET-201 TRANSFER LEARNING METHOD

There are more than 400 types of dates in the world that are similar in size, shape, colour, fruit texture, taste and maturity, making it difficult for people to memorise them. Identification with artificial intelligence can make labelling dates easier. This research proposes the DenseNet-201 transfer learning method with freeze all the pre-trained layers, re-train all the pre-trained layers, and hyperparameter models for date variety identification. The date dataset was collected from the market with a total of 3,300 images of 11 types of dates, including Ajwa, Bam, Golden, Khalas, Khenaizi, Lulu, Mabroum, Medjool, Safawi, Sukari and Tunisian. The purpose of the research is to identify, analyse the test images and compare and recommend the best performance model to identify the type of dates. The experimental results have resulted in the recommendation that the DenseNet-201 method with the hyperparameter model shows the best performance with an accuracy value of 99.39%.


INTRODUCTION
In the digital era, developments in any field cannot be separated from the development of information science technology [1].One of them is the development of technology in the field of image processing techniques.Image processing techniques play a role in the fields of health, agriculture, plantations, education, business and security.Examples of the development of image processing techniques in agriculture and plantations are techniques for improving the quality of fruits.
Date palm fruit is one of the fruits that is considered important for human nutrition because it has health benefits.Some of the advantages of dates for health are as a treatment for heart disease and cancer [2], the addition of platelets, and fiber-and nutrient-rich supplement drinks.
Date palm fruit has various types; throughout the world, there are more than 400 types of dates produced in various producing countries [3].According to BPS, Indonesia as an importer of dates was recorded in 2021 at 50,133 tonnes [4], and generally dates are crowded in the market before the month of Ramadan.Dates on the market are of various types; especially in Samarinda City, there are more than 11 types of dates.
In addition to various types, dates also generally have similar characteristics ranging from size, shape, colour, texture of the fruit [5], and maturity level [6].The classification of date palm fruit types is usually done manually by farmers [7].This makes it difficult for people to memorise the types of dates because it requires expertise, takes time, and requires strong memorization effort [5].As for Indonesia, which is far from date palm farming, sellers and buyers need certainty about the type of date palm.Such a seller desires for labeling so that the buyer gets satisfaction from the aspect of the type of date chosen and purchased.
With the development of computer science and computing, some researchers are proposing more effective ways to calculate dates.Previous researchers who raised the topic of classification of date palm types using the transfer learning method were the ResNet-152V2 model [8].And previous researchers who focused on the classification of date palm types using the CNN method [5], [8], [9], and [10], and using ANN, SVM and KNN methods [10].
Previous studies using CNN modeling and transfer learning that still show gaps include: researchers [10] capture datasets on single images using standard cameras with the same exposure and single-sided shooting.Based on the monitoring of the authors and researchers [10].Using the most number of date datasets with (9 types of dates) compared to other previous studies.While this study took images of dates using the Samsung A5 mobile phone camera with low specs, lighting varies depending on solar lighting and taking each image in two sessions.And using 11 types of dates with a total image of 3,300 images.
In several previous studies, only the transfer learning method of the ResNet-152V2 model has been used, while other models of transfer learning methods still not used for classification and identification of date palm types.And this study wants to compare performance results between methods that have been used by previous researchers, namely CNN, ANN, SVM, KKN and ResNet-152V2.
The contribution of this research is to apply digital image processing methods to identify and analyse date palm images using the DensNet-201 transfer learning method.And this study wants to propose the DenseNet-201 transfer learning method to identify date palm types with three models, namely the freeze all the pre-trained layers model, the re-train all the pre-trained layers and hyperparameters.The identification and analysis of date palm types are carried out on the image of the test results.The purpose of this study is to identify and analyse the image of test results and compare and recommend from model performance results to identify types of dates.The benefit of this study is to find out the type of date palm from the date palm image quickly and effectively as an alternative to determining the labelling that will be done by the seller (distributor), so as to provide satisfaction for buyers for the accuracy of labelling based on the type of date.

METHOD
This research uses research methods consisting of dataset collection, pre-experiment, training data, data testing, validation data, resize and reshape, identification, DenseNet-201 algorithm, hdf5 files, data test and performance output.The flow of research methodology can be seen in Figure 1.
In operating the Densenet-201 transfer learning algorithm, it uses the working principle that the model can be trained using local or cloud systems with Google Collaboratory.Dataset training is done with Graphical Processing Unit (GPU) to make it faster.Next, create a model using the tensorflow library as an end-to-end open source platform for transfer learning in python.And modelling using tensorflow to solve image recognition, image classification, and image identification problems.In model design, tensorflow is used for dataset preprocessing, model layer construction, and training.Dataset preprocessing can include normalisation and augmentation of each image.The model layer is built using keras application sequential model, then trained using the GPU.Finally, the model is evaluated using the Scikitlean library to display the test results in a confusion matrix.

Data Collection
In this study, we used a dataset of images of the types of dates collected.Date palm fruit is obtained from the market in Samarinda City which consists of 11 types of dates, namely Ajwa, Bam, Golden, Khalas, Khenaizi, Lulu, Mabroum, Medjool, Safawi, Sukari, and Tunisian dates.Figure 2 shows an example of the type of date palm.The total number of images is 3.300 images from 11 types of dates, with each type totaling 300 images.
Shooting is done directly using the Samsung A5 smartphone camera.The image was taken on a single date, using a white paper background, different distances, different lighting on each image, two sides in taking the image and different image sizes.The distance of taking each image on each date is different, the distance between dates and HP cameras is between 5 cm to 15 cm.And each date is photographed from two sides, and each side is photographed once.Examples of date palm size in the dataset include; portrait with the largest image size of 3120 x 4160 and the smallest 1840 x 3264 and landscape with the largest size of 4096 x 2304 and the smallest 3264 x 1836.

Pre Experiment
In the pre-experiment, researchers carried out several activities before the experimental process, namely sorting images that were blurred to separated for not use, labeling the collected images, and classifying each image included in the folder of each class.Furthermore, data sharing consisted of training datasets of 2.970 images (90% of 3.300 images) and testing datasets of 330 images (10% of 3.300 images).While the validation dataset obtained 10% of the total training dataset, which was 297 images.

Pre Process Training and Testing
At this stage, the size of each image is changed in the training dataset, the validation dataset with the resizing process and the testing dataset with the resizing and reshaping process.In this study, the original size was changed to small [11] in order for image processing at the time of identification to be faster, but not to change the information contained in it.Resize is used to resize the resolution of the original image to the size that suits the needs of the method.Reshape is used to change back the image resolution size from the previous image size and modify the dimensions of the original matrix according to the needs of the method [12].In this study using resize 224 and reshape 255.

DenseNet-201 Algorithm Architecture
At this stage, researchers used the DenseNet-201 algorithm to acquire a dataset of date palm fruit types.The DenseNet-201 performance process between each layer and the other layers is feed-forward, vanishing gradient problems can be reduced, feature propagation can be strengthened, feature reuse can be increased, and the number of parameters can be reduced [13].The advantage of the DenseNet-201 algorithm are used to identify the type of date palm.The architecture of the DenseNet-201 algorithm can be seen in Table 1 and Figure 3.
Inside there are four dense blocks and three transition layers.One dense block consists of batch normalization, ReLu activation, and convolutional with a 1 x 1 filter and a 3 x 3 filter.
In dense block 1 there are 6 blocks, dense block 2 has 12 blocks, dense block 3 has 48 blocks, and dense block 4 has 32 blocks.Inside the block there is a concatenation layer as a link between one block and another block by adding from one previous layer.Figure 3. DenseNet-201 Flowchart And the connection between dense blocks is a transition layer consisting of convolutional with a 1 x 1 filter and average pooling with a 2 x 2 filter, then the classification layer consists of global average pooling with a 7 x 7 filter and ends with full connected and softmax [5].

Experiment Scenarios
As a first step in this study before running an experimental scenario and determining the DenseNet-201 algorithm for date palm type identification, the author has conducted trials on several transfer learning algorithms.Aiming to find the best performance of transfer learning algorithms, and will be improved for date type identification.The transfer learning algorithm that was tried is a popular algorithm used by researchers with different image objects and produces quite good performance.The transfer learning algorithm that was tried with the results of its accuracy is as follows; ResNet-152V2 of 94.24%, VGG-19 of 93.33%, VGG-16 of 94.24%, MobileNet of 96.36%, Inception-V3 of 91.82%, and DenseNet-201 produced the highest accuracy of 97.29%.
And based on the results of pre-research experiments, the DenseNet-201 algorithm was obtained which produced the highest accuracy.In this study, we will improve the performance of the DenseNet-201 algorithm in what researchers [14] setting up pre trainede model that has been trained on a large imagenet dataset, then the pre trained model has actually produced very well.
The experimental scenario in this study uses the development of a pre-trained model.In practice there are three model training approaches that will be used as training models in this study, namely the model freezes all previously trained layers, the tuning model retrains all previously trained layers and the model freezes some previously trained layers and retrains others [15].
The experimental scenario that will be carried out is first with a freeze model all the pre trained layers, Second with the re-train model of all the pre-trained layers and third with the hyperparameter model.
The experimental process on all three experimental scenario models is the first model, freeze all the pre trained layers set the trainable layer using false, Both models re-train all the pre-trained layers set the trainable layer using true and the third hyperparameter model in the training operation process freezes some of the pre-trained layers, and re-trains the others and freeze some of the pre-trained layers and retrain the others [15] and batch size adjustment, and learning rate [16].The configuration at the time of experimentation with the DenseNet-201 algorithm can be seen in Table 2. DenseNet-201 Parameters.
In general, the iteration settings on the DenseNet-201 algorithm are carried out, namely in the top base model DenseNet-201 using weights= imagenet, include top= false, and input shape=244 x 244 x 3, in the model base model layers using dense 64, in the compilation section using the Nadam optimizer, setting the learning rite 0.0001, the training and validation process using batch size 38 and because of the multi-type class, the loss function used categorical cross entropy, in the identification section using ReLu activation function and layer output activation function using softmax.

Training and Testing
At the training stage, the training process is carried out on each model architecture according to the experimental scenario.The training and testing process was carried out with Acer laptops with specifications Acer Aspire 3 A315-41-R69L, layer 15.6 inch HD (1366x768) resolution, AMD Ryzen 3 3200U processor, Radeon Vega 3 graphics type with 3 NCU GPU clocked @1Ghz, 4GB DDR4 memory, 1TB HDD storage capacity, using 256GB SSD and Google collaboratory Pro with notebook settings hardware accelerator GPU and runtime shape high RAM.The dataset was shared in preexperiments that were stored into drive folders consisting of 90% data train and 10% test data.While the validation data was obtained 10% of the train dataset taken using random state 42.
The DenseNet-201 algorithm is a trained model of the ImageNet database in the hardware library.In the first experimental scenario for the training process using pretrained by freezing all layers that have been trained before, in the second experimental scenario the model is retrained all layers that have been trained before and in the third experimental scenario the hyperparameter model is training last layers (training the first layer from last) starting from training the first 5 layers from the last to training the first 60 layers from the last.The pre-trained model used in the training process uses a fully connected output layer, due to the number of classes in the multitype date palm image.

Test Data
Based on figure 1 of the research method flow, the results of the best training process are stored in a file in the form of hdf5 that is ready for the testing process.Before the testing process, dataset testing was carried out preprocessing resize 224 x 224 and image reshape 255.After preprocessing, testing operations are carried out on the best training results by producing performance outputs in the form of train and validation images, identification test output images, identification report cards (accuracy, precision, recall, and F1-score) and kappa scores.

Model Performance Performance
Based on figure 1 of the research method flow, the final result of the experimental process produces the output of model performance performance in identifying date palm type images.Performance outputs are images of testing output identification results, identification report cards (accuracy, precision, recall, and F1score) and kappa scores [17].
Accuracy is the percentage of the number of data records that are classified properly and correctly using algorithms and classification results after testing the dataset [18] and [19].Accuracy is applied to assess the performance of algorithms in the classification of an image [20].
Precision is the proportion of cases that are predicted to produce a positive result, where the value is also positive in the actual data [20] and [21].
Recall is the proportion of the number of positive cases that are actually and correctly predicted [18], [20] and [22].According to Sokolova (2006) cited by [20] that F-measure is called the F1-score, and it represents the harmonic mean of precision and recall.Cohen's kappa is a measurement test tool that expresses consistency between two measurement methods or measures consistency between two measurement models.And also can be a measurement tool carried out by two raters (rater).Cohen's kappa coefficient is applied only to the results of qualitative data measurement (categorical) [23].

RESULT AND DISCUSSION
At the stage of results and discussion of this research, performance results were obtained from the performance of the DenseNet-201 method in each proposed model in the form of identification values accuracy test, precision, recall, and F1-score and kappa score.

Test Results of DenseNet-201 Model Freeze
All the Pre-Trained Layers Method.
In the model experiment, freeze all the pre-trained layers in practice using a model training approach by freezing all previously trained layers by setting the trainable layer to false.The configuration of parameters used during experiments can be seen in Table 2.
The performance results of the Densenet-201 model freeze all the pre trained layers algorithm can be seen in Table 3 with details, namely accuracy test of 0.9697, average precision of 0.9727, average recall of 0.9691, average F1-score of 0.9709 and kappa score of 0.96.In the experiment, the re-train model of all the pre-trained layers in practice uses a model training approach by retraining all previously trained layers by setting the trainable layer using true.The configuration of parameters used during experiments can be seen in Table 2.The performance results of the Densenet-201 model re-train all the pre-trained method are accuracy test of 0.9879, average precision of 0.9881, average recall of 0.9881, average F1-score of 0.9854 and kappa score of 0.9867 or can be seen in Table 4.To achieve maximum results in the hyperparameter model, the first step is to test the optimizer parameters on 6 parameters, namely Adagrad, Adam, Adamax, Nadam, RMSprop, and ssd for date type identification, the best performance has been produced on the optimizer Nadam.According to [24] Nadam significantly outperformed Adam, and supports the hypothesis that using Nesterov's momentum will increase Nadam.
The second step, the results of the first step were improved by adjusting the damp optimizer, adjusting dense=128, batch size=38, and learning rate=0.0001and finding the best freezing layer in experiments starting from train last 5 layers to train last 60 layers with multiples of 5 layers.In the last train 60 layers have been produced the best model with the highest accuracy results.
From the second stage of experiments on the DenseNet-201 method, the hyperparameter model produced performance with an accuracy test of 0.9939, an average precision of 0.9945, an average recall of 0.9945, an average F1score of 0.9927 and a kappa score of 0.9933 or can be seen in Table 5.Based on the evaluation of the results of the experimental scenario, the DenseNet-201 hyperparameter model produced the best performance with test accuracy results of 99.39% compared to the test accuracy results of the re-train all the pre-trained layers model of 98.79% and the freeze all the pre-trained layer model of 96.97%.
So, this study recommends the DenseNet-201 hyperparameter model method that is suitable for date palm identification by producing a test accuracy performance of 99.39%.The performance results of the DenseNet-201 method of the hyperparameter model are described in detail as follows.

Train Graph and Validation on DenseNet-201 Hyperparameter Model Method
In the experiment, the DenseNet-201 method based on the hyperparameter model produces performance output in the training process in the form of train and validation graphs and in the testing process in the form of identified image results.Based on observations in the training process, the smallest train loss was 0.0010 by producing a train accuracy of 1.000 and the smallest validation loss of 0.0152 by producing a validation accuracy of 0.9933 with a computational time of the operating process of 12s / epoch and 164ms / step.After the training process is complete on the model, it is ready to be used for the date palm image identification testing process.In the testing process with a computational time of 3s and 150ms / step, a loss accuracy test of 0.0152 and a test accuracy of 0.9939 was produced.The test accuracy test result was 0.9939.Shown in Table 5 Performance Results of DenseNet-201 Method Architecture in Hyperparameter Model.

Data on DenseNet-201 Hyperparameter Model Method
From the prediction data in Figure 5 confusional matrix, it can be seen that the testing data for each class has 30 images.So the total number of testing data amounted to 330 images identified based on predictions and reality correctly according to the class amounted to 328 images.

Image Analysis of Test Results on DenseNet-201 Hyperparameter Model Method
Randomly recorded experimental images from the testing process based on predictive images and actual images can be seen in Figure 6 and Figure 7.
In Figure 7 cropping from Figure 6 in Figure (a), there is an image name written in red with the name of the date palm type "Tunisia (Golden)".If interpreted it means that the image is actually a Golden type, but artificial intelligence machine models have predicted or read it, the type of Tunisian date palm.Or the image of the Golden type is also identified in the type of Tunisian date palm because there are similarities in the oblong shape, blackish-brown skin color and texture of dates.
In  In Figure 7 the cropping result from Figure 6 in Figure (c), there is an image name written in red with the name of the date palm type "Khenaizi (Safawi)".If interpreted it means that the image is actually a Safavid type but artificial intelligence machine models have predicted or read it Khenaizi date type.Or the image of the Safavid type is also identified in the type of Khenaizi date palm because there are similarities in the round shape, texture of dates and at certain times there is a similarity in brownish skin color.
In Figure 7 the cropping result from Figure 6 in (d), there is an image name written in green with the name of the date palm type "Ajwa (Ajwa)" as one example of the image from the test results.If it is explained that the image is correct type of Ajwa date and the prediction results of the model machine are correct type of Ajwa date.Or it can be called the image of the type of Ajwa date is correctly identified into the class of Ajwa date types.
From the explanation above, it confirms that the types of dates have many similarities ranging from size, shape, color, fruit texture [5] and the level of maturity [6].

CONCLUSION
Date palm image identification can be completed with DenseNet-201 transfer learning.Hyperparameter optimizer is best for date type identification using Nadam parameter optimizer.Overall, the experimental results on the DenseNet-201 algorithm with the freeze all the pre-trained layer model, the re-train all the pretrained layers model and the hyperparameter model are classified as having good performance because they produce accuracy values above 0.95 for date palm type identification.The experimental results on the DenseNet-201 hyperparameter model method can identify date palm images with the best performance results with an accuracy test of 99.39%.
And for further research, other transfer learning methods can be used by applying various pre-trained models, tuning, and more types of dates.This research can also be developed with web-based transfer learning methods and smartphone-based or mobile.

Figure 1 .Figure 2 .
Figure 1.Flow of Research Methods ISSN 2089-8673 (Print) | ISSN 2548-4265 (Online) Volume 12, Issue 3, December 2023 Jurnal Nasional Pendidikan Teknik Informatika : JANAPATI | 355 And specifically in this study which is the difference between the three experiments proposed, namely; the fist experiment uses the Densenet-201 freeze all the pre trained layers model with adjustments made in the trainable layer configuration section with false tuning, configuration batch size 38 tuning, and epochs 30 tuning.The second experiment used the Densenet-201 re-train all the pre-trained layers model with tuning in the trainable layer configuration section with true tuning, configuration batch size 38 tuning, and epochs 30 tuning.And the third experiment uses the Densenet-201 hyperparameter model, in the training operation process, finding the best freezing layer by model freezing some of the pre-trained layers, and re-training the others with the configuration part of the trainable layer using false, the model part of the base model layers with tuning train last 60 layers (best tuning layer found), configuration batch size 38 tuning, and epoch 50 tuning.
a. Train Accuracy and Validation Accuracy Figure 4. b.Train Loss and Validation Loss The results of the train process stage obtained the output diagram of the train accuracy and validation accuracy graphs which can be seen in figure 4.a and obtained the output of the train loss and validation loss graph diagrams which can be seen in figure 4.b.

Figure 7
cropping results from Figure6on (b), there is an image name written in green with the name of the date palm type "Tunisia (Tunisia)" as one example of the image from the test results.If it is explained that the image is correct type of Tunisian date palm and the results of the prediction of the model machine are correct type of Tunisian date palm.Or it can be called the image of the type of Tunisian date palm correctly identified into the class of Tunisian date types.

Table 3 .
Performance Results of DenseNet-201 Model Freeze All the Pre-Trained Layers Method

Table 4 .
Performance Results of DenseNet-201 Model Re-Train All the Pre-Trained Layers