Crafting an Indonesian Currency Object Detection Model with CreateML Framework

Falah Hasbi Assidiqi
6 min readFeb 4, 2024

--

Digital transformation is a process that is impossible to ignore today and has become a central focus in the world of business. The paradigm shift from conventional businesses to technology-based businesses has changed the way entrepreneurs operate their businesses. Digitization is a complex process, but through this process, it can create bright opportunities for the future. In short, I want to try to capture the moment of my struggle to create solutions related to the digitalization of processes in the business world, especially for MSMEs. I want to create a series of articles (maybe 3, hehe …) about the lessons I learned while developing this idea.

Before going any further, I have created a Point of Sales (POS) application that utilizes technology and connectivity from the Apple environment to support MSMEs in carrying out sales transaction processes. This system utilizes connectivity between Apple devices (iPhone and Apple Watch) using a framework specifically available for developing Apple environment applications. During the transaction process, I also provide the option to pay using QRIS and use AI to detect the nominal amount of rupiah if the buyer pays with physical money. Btw, the AI detection that I use in this application is only limited to detecting the nominal rupiah, not for detecting the authenticity of currency, because until this application was created, there is no special indicator that can be seen by the camera to detect the authenticity of currency.

In this first article, I want to focus on writing about how I created an AI model for object detection from scratch. The artificial intelligence model created in this application uses the transfer learning method, namely by using a pre-trained neural network and then taking some parts of the model to be used in recognizing new models (Abas et al., 2018). This method begins by collecting the dataset needed to create an AI model which is then divided into 14 classes, namely denominations of 1000, 2000, 5000, 10000, 20000, 50000, and 100000 issued in 2016 and 2022. This dataset collection is done by photographing individual banknotes one by one, a total of 534 images representing each existing class. An example of an image dataset used in creating this model is shown in Figure 1 below.

Figure 1. Sample Image Dataset

The data that is collected is then labeled for each image according to its respective class. The data labeling for training this model uses the CVAT.ai website, which provides various features for labeling data, including providing colored boxes around each object in the image. The results of this labeling will be stored in an XML file containing the filename, image size, label name, and coordinate points of the boxes that have been created. Figure 2 below shows an example of labeling the dataset.

Figure 2. Dataset Labeling Process

Next, the labeled dataset is divided into three parts: training set, validation set, and testing set. This division aims to divide the AI’s task in creating a model. The process of dividing the dataset uses the Roboflow.com site to simplify the process of random division by uploading all images and annotation files to the site. Creating this model divides the dataset into 70% (374 images) training set which is used for the chosen AI model to fit the information provided, 20% (107 images) validation set to help re-adjust the model that has been trained on the training set once per iteration, and 10% (53 images) testing set which is used to test the AI model. Additionally, I also performed preprocessing on the data by automatically orienting and modifying the images to be 640x640 pixels. This is done so that the images have consistent uniformity in terms of size and orientation, as well as saving storage space. The process of dividing data and preprocessing on the Roboflow site is illustrated in Figure 3 below.

Figure 3. Dividing Data and Preprocessing

The next step that is done in creating the AI model is downloading the data that has been divided and preprocessing it with the CreateML format. This format is chosen because the AI model training is done using the CreateML framework, which is a platform used to create machine learning models developed by Apple. After the data has been successfully downloaded, the next step is to enter the data into CreateML according to the division of data types that has been done.

The AI model training in CreateML starts with setting parameters including the choice of algorithm, number of training iterations, and other parameters. In creating this model, I used the YOLOv2 architecture algorithm because this model has the ability to detect objects in real-time. This YOLOv2 architecture uses a Convolutional Neural Network (CNN) to extract features from the input image, which produces bounding boxes and confidence scores for each detected object. This training process begins with the initialization of network weights, which are adjusted during training to optimize model performance. Next, the images are passed through the network and information from the images is extracted through convolutional layers.

During the model training process, continuous monitoring of metrics such as loss function is carried out to ensure the model does not overfit. Overfitting occurs when the model overfits the data, which makes it unable to generalize well to new data. In addition, I also set the number of training iterations to 6000 times. This is done so that the model can adapt to the dataset used optimally, improve accuracy, and optimize its detection capabilities. Monitoring of the loss function during training is shown in Figure 4 below.

Figure 4. Monitoring Loss Function

Based on Figure 4 above, the loss function obtained during training of this model did not experience overfitting because its value continued to decrease as the number of training iterations increased. The final value of the loss function was 0.7. This is a good value because a low loss function value indicates that the model is able to predict accurately during AI model training. After the model was successfully created, it was tested using 53 images representing rupiah coins issued in 2016 and 2022. The number of test images is 10% of the total dataset used to create an AI model in this application. The results of testing the machine learning model in this application are shown in Figure 5 below.

Figure 5. The Result Training Model

Based on Figure 5 above, the accuracy of the rupiah bill recognition model using the CreateML framework with the YOLOv2 architecture is 94%. Overall, the rupiah bill recognition model that has been created has very good performance, even though there are two misdetections which are the result of inaccurate training data. However, this is still understandable because the two misidentified objects are images of the back of a Rp.100,000 rupiah bill issued in 2016, but the model detected them as images of the back of a Rp.100,000 rupiah bill issued in 2022, which have a high level of similarity.

In conclusion, the journey of developing an AI-driven object detection model for Indonesian currency using the CreateML framework has been a rewarding endeavor. The meticulous process of dataset collection, labeling, division, preprocessing, and training has yielded a robust model with a commendable 94% accuracy in recognizing Indonesian Rupiah bills. As we delve into the next chapter of this series, our focus will shift towards seamlessly integrating this powerful model into the iOS app ecosystem.

--

--