Classification of Roasting Level of Coffee Beans Using Convolutional Neural Network with MobileNet Architecture for Android Implementation

The roasting process has a significant impact on the aroma profile and taste of coffee making it an essential stage in the coffee processing. Currently, the classification of coffee bean roasting levels still relies on subjective human visual assessment, which can lead to errors due to fatigue or negligence. To overcome this problem, a classification system was developed using computer vision technology with a deep learning approach. The present study designed a coffee bean roasting level classification system based on image analysis integrated within an Android application. The Convolutional Neural Network (CNN) model with the MobileNet architecture was used to identify and classify coffee beans based on their roasting level. Two CNN models, namely CNN Alpha and CNN Beta were used in this study. The dataset included 1.600 coffee bean images, with 1.200 images used to train the model and 400 images used to test the accuracy. In this experiment, the input image had an optimal size of 70x70 pixels, a learning rate of 0.0001, and 100 epochs for both models. The model training and testing results in the highest accuracy of 98-88% in 6.40-0.0012 minutes.The application test results obtained 93.55% accuracy, 97.06% precision, and 96.67% recall. These results indicate that this model and application function optimally in classifying coffee bean roasting levels accurately. Overall, this study reveals the potential of integrating CNN with the MobileNet architecture into an Android-based application to change the way of roasting level classification, as well as to improve efficiency and accuracy.


INTRODUCTION
Coffee is a plantation commodity that has a large share in the Indonesian economy, in addition to oil and gas (Marhaenanto et al., 2015).Indonesia occupies the fourth position as the largest coffee producer in the world, after Brazil, Vietnam, and Colombia.About 67% of the total domestic coffee production is exported, while the remaining 33% is used to meet domestic needs.Indonesian coffee exports cover five continents with the main share in the European market.In 2021, the total volume of exported coffee reached 387 thousand tons.Apart from the product market opportunities that are increasingly open, the local coffee market is also very large (BPS, 2022).
One of the important stages in coffee processing is the roasting process.The taste of coffee can be changed accordingly, depending on how the roasting process is done (Batubara et al.,, 2019).Roasting is one of the stages of processing food or agricultural products through heat treatment without oil applied to the material for a certain period of time (Radi et al., 2020).Coffee is an agricultural product, which is usually served as an aromatic beverage (Rivai et al., 2020).Roasting is the process of forming the taste and aroma of coffee beans.The maturity level in the roasting process is generally divided into three parts: light, medium, and dark (Tyas, 2022).A controlled roasting process is one way to maintain the taste and aroma properties of coffee drinks.Some parameters that can be set in the roasting process include time, temperature, and the color level of the coffee beans when they are roasted (Hernández et al., 2008).
Currently, coffee bean classification is still deemed mostly done visually and depends on human subjective judgment.However, this method has a subjective nature, so it has the potential to cause human error due to fatigue or negligence (Radi et al., 2016).Finally, the classification of coffee roasting levels cannot work properly without the help of modern technological innovations.An alternative approach using technology is expected to increase the effectiveness of the classification of roasted coffee beans to be much better and more efficient (Winjaya, 2017).One of the technologies developed to determine the roasting level of coffee is computer vision (Radi et al., 2016).
Computer vision is a technology that enables machines to have the ability to see, identify, and extract information from an object to complete certain tasks (Hendriyana & Maulana, 2021).Computer vision software includes algorithms of image processing and machine learning for identification or interpretation (Radi et al., 2020).The work function of computer vision is similar to that of the human eye, where images or pictures of objects are introduced into the system to extract information and classify them based on their type.In the field of computer vision technology, there are various approaches that can be used, one of which is a methodology that utilizes Artificial Neural Networks, which are inspired by the workings of the human brain and then develop further in the Deep Learning method (Lecun et al., 2015).The Deep Learning method that has achieved significant results so far is the Convolutional Neural Network (CNN) (Azizah et al., 2018).Research on application of computer vision applied on coffee bean have been conducted and provided good result (Radi et al., 2015a;2015b).
Convolutional Neural Network (CNN) is a Deep Learning method that can see and distinguish objects in computerized images (Muresan & Oltean, 2018).This achievement was largely due to advances in more powerful computing, the use of large datasets, and strategies to practice deeper networks.CNN is considered one of the best methods related to object identification and recognition.However, like other Deep Learning methods, CNN also has drawbacks in the training process which requires quite a long time (Santoso & Ariyanto, 2018).To speed up the training process, you must use the right architecture, and one of the architectures that has been proven to have optimal execution is MobileNet (Howard et al., 2019).MobileNet is centered on creating a light and optimal network in terms of speed (Hendriyana & Maulana, 2021).
There have been many studies on the classification of coffee roasting levels using digital image processing.Nugraha & Wiguna (2018), for the first time, developed a system for identifying the roasted level of coffee using an artificial neural network resulting in an accuracy of 76.7%.In addition, Putra et al., (2020) also developed a system for determining the roasting level of coffee based on roasting results using the RGB detection method and minimum distance classification, with the resulting accuracy of 89.63%.Then Prastyaningsih & Kusrini's (2021) research about the identification of coffee bean roasting levels using color feature extraction with an image retrieval system produces an accuracy of 97.67%.However, the fundamental weakness of these models is that the computation is quite heavy, and errors in detecting objects (Raysyah et al., 2021).Michael et al., (2020) succeeded in applying the Convolutional Neural Network (CNN) method with a combination of architectures between LeNet5, AlexNet, and MiniVGGNet for the classification of coffee roasted levels based on Android, resulting in an accuracy of 98%.This model has advantages in terms of speed of detection, relatively easy to modify, and fast computation time.However, the resulting model output is considered large and quite heavy to use in the applications.
Based on the potential of computer vision technology and the CNN method, this research was conducted to develop a coffee bean roasting level classification method for Android implementation.The CNN model that will be developed uses the MobileNet architecture so that the resulting model output is smaller and lighter to use in the applications.This research was expected to present a new concept in the classification of coffee bean roasting levels, namely by utilizing an Android-based classification system so that it can be used anytime and anywhere.This mechanism is expected to simplify and speed up the coffee classification process, thereby increasing its overall efficiency and accuracy.

Classification System
This research was conducted to develop a coffee bean roasting level classification system which is then the development of this system is largely based on the Convolutional Neural Network model with MobileNet architecture.The results of the system classification were then used as a model in making Android-based applications.
Figure 1 shows a system scheme for developing a coffee bean roasting level classification system using a Convolutional Neural Network with MobileNet architecture.Google Colaboratory was used to make the design of executable models that are free and high on computational resources.In addition, image datasets were then collected using smartphones.The image dataset was used to train and validate the model.Finally, the model was ready to classify the roasting level of coffee beans, then it was implemented into an application built using Android Studio to determine the predicted results of the coffee bean roasting level.Further, an analysis of the results of the CNN model training and application testing was carried out to evaluate the suitability and efficiency of the developed classification system.After obtaining the model with the best testing accuracy, the model would be implemented into an Android application to make it easier to assess the roasting level of coffee beans accurately.Application performance would be tested using a new image that was not used during the training and testing process.After that, it would be assessed whether the integration of CNN with the MobileNet architecture into an Android-based application was successful or not.It was expected that the designed system and application would change the method of classifying coffee bean roasting levels.

System Performance
The performance results of the designed system would be evaluated based on the extent to which the performance was as expected.In addition, the advantages and disadvantages of the designed system would be measured using accuracy, precision, and recall parameters.Accuracy is characterized as the degree of truth in a study, which indicates how precise the results are.Precision describes the speed at which data is achieved by comparing the number of correct predictions compared to the total amount of data.Recall measures how many actual positives were correctly identified (Ibrahim et al., 2022).Here is the mathematical equation to calculate accuracy, precision, and recall: (1) x 100% (2) where TP (true positive) is data that is actually classified by the system as a positive (true) value; TN (true negative) is true data is classified by the system as a negative (true) value; FP (false positive) is incorrect (negative) data but classified by the system as true (positive) data; and FN (false negative) is the data is correct (positive) but is classified by the system as incorrect (negative) data.

RESULTS AND DISCUSSION
The system that had been designed was used to classify the roasting level of coffee beans from the coffee image dataset which was divided into four categories, namely green, light, medium, and dark.The CNN architecture used in this study had 2 models with CNN Alpha having 3 convolution layers and 2 hidden layers, while CNN Beta having a total of 4 convolution layers and 2 hidden layers.
The success rate of the model was measured by the accuracy parameter.Model accuracy could be determined through testing using data testing.The outline of the block diagram of this research can be seen in Figure 3, which consists of three parts: input, the process is in the form of processing and training, and the output is in the form of a model.The data testing was used to test the accuracy of the model.Figure 3

Test Design Results
For model training, implementation tests were carried out including testing image sizes with sizes 50x50, 70x70, and 150x150 with the specified parameters.Then, testing the learning rate for Adam Optimizer was conducted with values 0.0001, 0.001, and 0.01 using a predetermined image size.In addition, varying the number of epochs with values of 10, 100, and 1000 with a predetermined image size and learning rate.The results of this test are shown in Table 1.Based on the test results, it was found that the optimal image input to be used was 70x70, the learning rate value was 0.0001 and the epoch value was 100 for both models, then model prediction test was carried out.

CNN Model Training and Testing Results
In this test, an epoch value of 100 was used with the same learning rate parameter, namely 0.0001 and the input image used was 70x70 pixels.The dataset comprises 1.600 images of coffee beans.Out of this total, 1.200 images are utilized for training the model, while 400 images are reserved for testing the accuracy of the model.The results of this test are shown in Table 2.

Testing Results Using the Application
After the best model was implemented into the Android application.Then the testing process was conducted aimed to test whether the model that was integrated into the Android application system was successful in making predictions or not and seeing the performance of the application.Figure 4 is a testing process, where the input used was a photo image directly using a smartphone or available image data.After that the input image would be resized to a size of 70x70, to match the size of the image during training.The images would then be classified based on the model resulting from the training process (see Figure 3).The result of this testing or classification process is the form of the name of the roasting level and its percentage of accuracy.The testing process was carried out using a smartphone that had been installed with a coffee bean roast-level classification application.Figure 5 demonstrates the application interface for the classification of coffee bean roasting levels.Figure 6 shows the results of the classification process for the roasting level of coffee beans with the output being the name of the coffee roasted level and the percentage of accuracy.The coffee image data used was limited to 120 test data images from different datasets, where each roasting level had 30 images.The results of these tests can be seen in Table 3.The system successfully classified all images with dark, green, and light roasted levels.Meanwhile, for the medium image, 26 images were successfully classified and 4 were identified incorrectly.There was an incorrect prediction in the medium image because the color at the medium maturity level was almost similar to light so some were predicted to be light as shown in Table 3.While those in Table 4 are the results of system performance obtained by calculating accuracy, precision, and recall.Based on the testing, the accuracy value obtained was 93.55% and the precision, and recall values were 97.06% and 96.67% respectively.

CONCLUSIONS
The coffee bean roasting level classification system developed using CNN with the MobileNet architecture can be used to predict the maturity level of coffee.The model training and testing results in the highest accuracy of 98-88% in 6.40-0.0012minutes.While the application performance test shows the best accuracy of 93.55% and the value of precision, recall is 97.06% and 96.67% respectively.These results indicate that the coffee bean roasting level classification system using the Convolutional Neural Network method with the MobileNet architecture can be considered to work well.For better results, model evaluation and optimization can be done by increasing the number of iterations and evaluating the amount of training data.

Figure 2
Figure 2 shows the flow of research stages.The coffee images used in the model training process are roasted coffee from 'Cap Kadal Roaster' home roasting and have been labeled by experts into three classifications: light, medium, and dark.The collection of these photographed images is then divided into three parts: training dataset, validation dataset, and testing dataset.The image dataset to be used in this study was 1000x1000 pixels in JPG image format.The dataset contained 1,600 coffee bean images, which were divided into four categories representing their respective different roasting levels.Out of the image number, 1,200 images were used to train the model, while 400 images were used to test the accuracy of the model.In evaluating application performance, 120 new images were used from different data.The coffee bean roasting level classification system using Convolutional Neural Network (CNN) with MobileNet architecture would be tested using several training scenarios and using training data that had been divided into training data and validation data to identify and classify the roasting level.Furthermore, an evaluation of the accuracy of the training was carried out to ensure the success of the training process.The model with the best training scenario would illustrates the three parts of the research block diagram, which shows the overall research outline, namely: input, process through processing, and training, and the result is a model.

Figure 3 .
Figure 3.The research block diagram on the CNN model uses the MobileNet architecture

Figure 5 .
Figure 5. Application interface to identify coffee roasting level

Table 1 .
Test accuracy results

Table 2 .
Training and testing results

Table 3 .
The results of the test data classification

Table 4 .
The results of the test data analysis

Table 3
is a table of classification results for test data.