AlexNet convolutional neural network to classify the types of Indonesian coffee beans

Various types of Indonesian coffee are already popular internationally. Recently, there are still not many methods to classify the types of typical Indonesian coffee. Computer vision is a non-destructive method for classifying agricultural products. This study aimed to classify three types of Indonesian Arabica coffee beans, i.e., Gayo Aceh, Kintamani Bali, and Toraja Tongkonan, using computer vision. The classification method used was the AlexNet convolutional neural network with sensitivity analysis using several variations of the optimizer such as SGDm, Adam, and RMSProp and the learning rate of 0.00005 and 0.0001. Each type of coffee used 500 data for training and validation with the distribution of 70% training and 30% validation. The results showed that all AlexNet models achieved a perfect validation accuracy value of 100% in 1,040 iterations. This study also used 100 testing-set data on each type of coffee bean. In the testing confusion matrix, the accuracy reached 99.6%.


Introduction
Indonesia has an opportunity to develop the coffee processing industry because it has a large market. It is also supported by potential raw materials [1]. Therefore, strategic efforts, such as down streaming, are needed to increase added value and production capacity. Indonesia is one of the largest coffee beansproducing countries in the world [2]. Based on data from the World Food and Agriculture Organization (FAO), in 2017-2018, Indonesia was listed as the fourth-largest producer of coffee beans, after Brazil, Vietnam, and Columbia [3]. Indonesia's tropical climate provides its advantages in coffee production because the coffee plant is very suitable for planting in tropical climates, precisely in the tropical areas north and south of the equator [4]. Coffee production in Indonesia is spread across various regions, from Sabang city to Merauke city [5]. Coffee produced in these areas has a distinctive taste and chemical compounds that advantage each producing area [6]. Several types of coffee produced by Indonesian farmers are already known in the world.
Some of Indonesia's best coffees include Gayo, Kintamani, and Toraja coffee. Aceh is one of the best coffee bean producers in Indonesia. The name is Gayo coffee because this coffee is grown in the Gayo highlands, with an altitude of 1,200-1,700 m above sea level [7]. This Aceh coffee has a watery texture and is not too thick with the right sour taste. Kintamani Arabica coffee comes from the Bali area. This coffee has a unique taste; the sour and fresh taste of the fruit is its specialty. Kintamani Arabica coffee has a medium thickness and a light and soft taste. Currently, Japan, Saudi Arabia, and Europe are the main destinations for coffee exports from Bali [8]. Toraja coffee is one of the coffees that has been known to the world community [9]. Japan and the USA are two countries that have become the main customers of Toraja coffee exports. The specialty of Toraja coffee is that its bitter taste is only felt when the coffee is drunk and will disappear afterward without leaving a trace or after taste effect. Coffee that grows in the Sulawesi area has an earthy taste, the sensation of soil or forest taste, and a low sour taste [10]. The best coffees from Indonesia have a fairly high price in the market. Therefore, there is a need to identify the best types of coffee from Indonesia because coffee products are vulnerable to being counterfeited. One method of detecting agricultural product varieties is computer vision [11]. The computer vision method has advantages such as being low-cost, non-destructive, rapid, accurate, and effective [12][13].
Many studies have proven the effectiveness of computer vision and artificial intelligence in detecting the physical characteristics of agricultural products [14]. Hendrawan et al. [15] have successfully used computer vision to inspect the quality of Luwak coffee green beans using an artificial neural network with an accuracy result of the mean square error validation of 0.0442. Hendrawan et al. [16] have also succeeded in detecting the quality of soybean products using computer vision based on texture analysis with a validation error value of 2.39%. Javanmardi et al. [17] have proven the effectiveness of computer vision combined with convolutional neural network (CNN) modeling to classify corn seed varieties. The results show that CNN performs better than artificial neural networks, support vector machines, weighted k-nearest-neighbor, boosted tree, bagged tree, and linear discriminant analysis. The classification accuracy reached 98.1%. Huang et al. [18] have also proven that CNN performs better than traditional machine learning in classifying corn seed defects with up to 95% accuracy. Lin et al. [19], in their research, used CNN to classify rice species. CNN's accuracy reaches 99.4%, where this accuracy value is higher than the support vector machine and k-nearest-neighbor. This result is also in line with the research conducted by Qiu et al. [20], which also showed that CNN performed better than other traditional machine learning in identifying single rice seed varieties. Analysis in classifying the purity of coffee beans using CNN has also been carried out by Huang et al. [21]. As a result, with an accuracy of 93%, CNN succeeded in distinguishing the good and bad coffee beans. Lopez et al. [22] conducted a study to detect adulteration levels in Arabica and Robusta coffee beans using CNN. The CNN model can classify the purity of coffee beans with an accuracy above 98%. Many studies on deep learning have shown CNN's performance to classify agricultural products' physical characteristics accurately. The use of computer vision and CNN methods can be used to classify the types of Indonesian coffee beans based on external appearances in a non-destructive, rapid, low-cost, and accurate manner. This study aimed to classify three types of Indonesian coffee beans, i.e., Gayo Aceh, Kintamani Bali, and Toraja Tongkonan using CNN.

Materials and methods
This study used a low-cost scanner to collect coffee beans image data. A low-cost digital commercial scanner (Brother DCP-T710W 24 bit color processing, Up to 1,200 × 2,400 dpi) was used for image acquisition. The image was obtained from the image acquisition process with a resolution of 1,721 × 1,721 pixels in JPEG format. In total, 1,500 image data with three coffee beans types, i.e., Gayo Aceh, Kintamani Bali, and Toraja Tongkonan were used as training and validation data. All image data, then divided into two parts, i.e., 70% for training data and 30% for validation data. Figure 1 shows an example of Indonesian coffee beans. It can be seen that Indonesian coffee beans in each type look almost the same and is difficult to distinguish by observations from external appearances. The deep learning method was used to model image data in categorizing the types of Indonesian coffee beans. A CNN pretrained network was used in this study, i.e., AlexNet. The CNN AlexNet algorithm was described in the research of Hendrawan et al. [23]. The CNN structure for classifying the types of Indonesian coffee beans, in general, can be seen in Figure 2. Some of the parameters that were set on each CNN pre-trained included: optimizer (SGDm, Adam, RMSProp) [24], initial learning rate (0.00005 and 0.0001) [25],  [26], sequence padding value = 0, sequence padding direction = right, L2Regularization = 0.00001, learning rate drop factor = 0.1, learning rate drop period = 10, and momentum = 0.9. After the CNN modeling process had been carried out, the best model was tested on 100 data sets in each type of coffee bean. The testing data set was image data of coffee beans taken separately from training and validation data. The performance of the CNN model was measured from the classification accuracy of the testing-set data using the confusion matrix method [27].

Results and discussion
The performance of CNN's pre-trained network can be seen in Table 1. AlexNet models were used to classify the types of Indonesian coffee beans. Sensitivity analysis was carried out by varying the optimizer method, i.e., SGDm, Adam, and RMSProp, and varying the initial learning rates of 0.00005 and 0.0001. The obtained results showed that Alexnet CNN models produced perfect classification with 100% accuracy. The fastest training process was achieved using the Adam optimizer and learning rate of 0.00005, which was about 153 minutes. The training process in the six CNN models can be seen in Figure 3. From Figure 3, all CNN models showed an effective training process performance where the accuracy value increased with increasing iteration. The opposite applied to the loss value, where the loss value decreased with increasing iteration. The six best CNN models showed almost the same patterns. The training and validation performance chart patterns appeared to move quickly at the initial epoch. They converged at the next epoch, where the accuracy value moved increasingly converging to 100%, and the loss value converged to 0. The validation value, both accuracy, and loss moved according to the training value. In terms of the stability of the training dan validation process, AlexNet with SGDm optimizer and learning rate 0.00005 (Figure 3a), as well as AlexNet with SGDm optimizer and learning rate 0.0001 (Figure 3d), showed a fairly stable training and validation process with less fluctuation compared to other CNN models. In Figure 3b, Figure 3c, and Figure 3e, and Figure 3f, it can be seen that the AlexNet model has a slightly fluctuating and less stable training performance. This fluctuation can be caused by various factors, such as over-fitting in training and validation data, insufficient datasets, noisy data, network structures that are too large, or batch size values that are too small. However, as long as these fluctuations occur at the beginning of the iteration, this condition does not significantly affect CNN's training and validation performance to classify the types of Indonesian coffee beans. According to Takase [28], fluctuations in validation loss during the training process are normal in machine learning as long as the training pattern shows a steady increase in performance during iterations. After the best results were obtained in the training and validation process, the next step was to test the CNN model's performance using the testing-set data. Of the six best CNN models when tested using the testing-set data, they all produced the same performance, the same accuracy value, and the same error value. So that for the confusion matrix in this study, one confusion matrix result was shown representative of the best six CNN models. The results of the confusion matrix can be seen in Figure 4. From the confusion matrix results, it appeared that the average accuracy of the testing-set data was 99.6%, where this accuracy value was very high for classifying the types of Indonesian coffee beans. In detail, the types of Indonesian coffee beans of Gayo Aceh and Toraja Tongkonan, the CNN model could calculate 100% without the slightest error accurately. While in the type of Kintamani Bali, the CNN model only made an error of 1% and could still classify Kintamani Bali coffee beans with an accuracy of 99%. With this very high accuracy result, it can be concluded that the CNN model built can work effectively to classify the types of Indonesian coffee beans, i.e., Gayo Aceh, Kintamani Bali, and Toraja Tongkonan. In future work, the combination of the CNN model and the low-cost digital commercial scanner can be used to detect the types of Indonesian coffee beans with the advantages of being nondestructive, rapid, accurate, low-cost, and real-time. (a)