a

Lorem ipsum dolor sit amet, consectetur adicing elit ut ullamcorper. leo, eget euismod orci. Cum sociis natoque penati bus et magnis dis.Proin gravida nibh vel velit auctor aliquet. Leo, eget euismod orci. Cum sociis natoque penati bus et magnis dis.Proin gravida nibh vel velit auctor aliquet.

  /  Project   /  Blog: Our TechLabs Experience — Coin Detector

Blog: Our TechLabs Experience — Coin Detector


Who are we?

We are a team of three students in Münster and we found us via TechLabs. Leonard and Konrad study information systems and Dario studies chemistry. All of us are (more or less) experienced with coding. We joined TechLabs because we wanted to learn something about the huge topic AI. We believe AI is one of the most relevant parts of technology and will have a significant impact in the future.

What Problem did we intend to solve?

Most people have coins laying around. It is annoying to count them and to calculate the value, so our idea was to program a tool, which can count the coins for you. We wanted the user to just take a photo with a smartphone, send it to a service and get the value of the coins send back.

How did we proceed, and which methods did we use?

At first, we had to think about a general concept to solve the problem. A quick internet search showed us that the You Only Look Once (YOLO) algorithm is very suitable for this kind of object detection and we decided to use it for our solution. YOLO is great for small projects like this one because it is simple to use. You can imagine it as an already fully functional neural network for object detection. We just needed to feed the network with our own data to solve our problem, and did not need to write any code for the training process. We are beginners in the field of AI so YOLO is way more easy to understand than other code based solutions like FastAI or Tensorflow. Our goal was to take a picture with a smartphone and get the value of the coins on the picture back. Unfortunately, it is not possible to run YOLO on a smartphone. Our solution for this problem is to send the picture to a computer via Telegram. The computer calculates the value and answers with the results. With this general approach in mind we started the realization of our idea.

The first thing you often need to do in any AI project is to get data. To get a Data Set we started to take pictures of all the different coins from above. To train a neural network you need to label the data. For that we used an open-source program called LabelImg. Overall, we prepared around 350 pictures. This took the majority of time we spend on this project. One thing we learned is that the data is important in AI project because you need much data for a good performance. But sometimes it is hard to find good data or very time-consuming to make your own dataset.

During our project we participated in online courses about AI. One key thing we learned is that you need to split your dataset in a training set and in a test set. The training set contains 70% of the data and is used for the training process. The other 30% are in the test set. The test set is important to measure the performance of the network. The measurement cannot be done with the training set because the network already “know” the coins.

Before training, we needed to configure the network. YOLO needs a list of the names for the objects and the path of the folder that contains the images.

After that we started training. For that, we used Google Colaboratory. Colaboratory is a free Jupyter notebook environment that runs entirely in the cloud. With Colaboratory we were able to access computing resources for free from our browser. To train the network in Colaboratory you need to set up YOLO and upload all relevant files. These include the config files for YOLO and the dataset. To start the actual training afterwards we just needed one command.

Simultaneously we also experimented with Microsoft Azures’ Custom Vision Service. Custom Vision already provided okay results but lacked advanced features to optimize a model. It was great for getting a first idea where we stand with our dataset. Microsoft also provides great features for analyzing datasets. Therefore, we recognized that it is important to distinguish between the front- and backside of the coin.

That’s because the picture gets compared to other pictures of coins. Obviously, the front and backside look very different and therefore demand to different labels.

After correcting this mistake, we started the training process in Colaboratory again. During the training the performance of the network is displayed. The training should be stopped if the performance does not improve any more. We stopped our training after 6000 iterations, which took around 16 hours. The network generates a weight file every 1000 iterations. The weight file is used to predict the coins on unknown images. Then the predictions are used to calculate the value of the coins on the image.

To make our algorithm practicable, we decided to use a Telegram chatbot. The aim of the chatbot was to be able to send him a picture of coins. The bot then replies with the total sum of coins in the photo. One example of the bot in progress is shown in the picture. Telegram chatbots are especially useful because of the great API. Receiving messages can either be achieved through a webhook or through a rest API which has to be called. We used a loop to get all new messages. The returned json file is then analyzed. If the message is a picture, we check for the field and download the linked picture. Then we call YOLO through the command line and send the messages seen above. For sending messages we used the Rest API again. The Code can be found on our Github which is listed later.

The performance of our network is quite good for pictures of the coins’ front. Because the coins’ back is different for every country, the algorithm sometimes has problems distinguishing between similar looking ones. We stopped the training when the mean average performance reached 89%. This is a good value for our small dataset. The problem is that the test set contains images of exactly the same coins as in the training set. This means the predictions will most likely be true if you use the same coins we used in our dataset. But if you use other coins, which is the case most of the time, the predictions may not have that great performance.

A possibility to fix this problem could be to use a larger training set and to train it for more iterations. It would probably also be necessary to get a model of every coin produced in Europe. Because the backside of Euro coins differs a lot this is one thing that could throw YOLO off.

Another problem is the hosting of the Bot. When we ran YOLO on a mid 2012 Macbook Pro it took about 30 seconds from taking the picture to getting the sum on the phone. It takes so long because we couldn’t enable GPU acceleration due to lacking CUDA Drivers. This is necessary to provide a usable real live service.

What did we learn from our TechLabs Experience?

Good data is most important for AI — that was the first lesson we learned from our TechLabs experience. Most of our project time, we used to prepare and tag our pictures. The amount of code, which we had to write by ourselves was unexpectedly low. For most our problems, we found code online, which was easily modified. The challenge was to find a suitable base program and to understand the principles of different libraries.

Because we basically only needed code for the Server application, we learned a lot about python’s basic libraries. We only knew python as a scripting language for small applications. Now we learned about more object oriented approaches to programming python software and also how to use code written by other people. These experiences will help us code more efficiently and more correct in the future.

All in all, we really enjoyed to be a part of TechLabs during the last semester. Especially great were the numerous meetings and presentations of various themes about Tech-Skills. This was a great opportunity to connect with other students, who are also interested in coding. Also, TechLabs helped us to keep our learning experience rolling. The leaderboard on slack really motivates us and TechLabs also helped us to find suitable online courses.

The project made sure that we directly applied our learnings. That is a big difference to many lectures in university. At TechLabs, the courses were application-orientated. The practical use was clearly evident. The focus is not on the theory and on understanding every detail but on useful methods. Also working self-determined and being able to make independent design decisions during the project is great. Because of that we can fully recommend Techlabs to everyone interested.

The Team and courses

Dario Mauth: TechLabs AI Track

  • DataCamp Python for Data Science
  • Google Machine Learning Crash Course
  • FastAI

Konrad Sarodnick: TechLabs AI Track

  • DataCamp Python for Data Science
  • Google Machine Learning Crash Course
  • Coursera Neural Networks and Deep Learning

Leonard Sensmeier: TechLabs AI Track

  • Google Machine Learning Crash Course
  • FastAI

Github: https://github.com/techlabsms/project-wt-18-07-project_coins

Source: Artificial Intelligence on Medium

(Visited 4 times, 1 visits today)
Post a Comment

Newsletter