Coffee, the elixir of life. The magical substance that the average Finn consumes 12 kilograms per year. At Evermade, we take coffee pretty seriously: our office manager is an ex-barista and sometimes we like to experiment with different kinds of fancy coffee drinks. Every day from Monday to Friday, we brew multiple pots of coffee. But sometimes you walk in the kitchen just to find that all the coffee has been drunk. Our analytics developer Juha wanted to fix this unpleasant situation and have some fun along the way: he immersed himself in machine learning and AI to build a coffee bot during his summer holiday. Let’s take a look at how it works!
First, Juha downloaded hundreds of images of coffee makers from the internet. Half of the coffee pots were empty, half had coffee in them. The images were simply labeled “yes” and “no”. Training the neural network is done with the FastAI Python library on Google Colaboratory. The network’s architecture is built just like the connectivity pattern of neurons in the human brain: little by little, the system learns to identify more complex patterns.
The actual bot responsible for coffee detection runs on a Mini PC tucked in the corner of our kitchen counter. Whenever one of us sends the bot a request, it captures a photo with a web camera using OpenCV and passes that photo onwards to be processed by the model.
The system has learned to recognize if there is coffee, and the status can be checked by opening an internal website dedicated to the bot. In the future, it could also be programmed to capture photos at regular intervals and automatically notify us when there’s fresh coffee in the kitchen. The bot could also learn to recognize how much coffee there was in the pot, and for example, remind us to go brew some more.
Did you know that the first webcam developed in 1991 was created to point at a coffee pot in the old Computer Lab of the University of Cambridge? Juha’s idea of an AI coffee bot was born of a similar situation: not feeling like getting up to check the kitchen, but also wanting to learn something new.
“I had lots of free time during my summer holiday, so I decided to learn the basics of two completely new things to me: Python and machine learning. The idea of a machine learning coffee bot came from two coworkers of mine, Pekka and Patrik – both serious coffee lovers. When learning something new, I always like to approach the topic simultaneously from both practical and theoretical ends. This project was a great excuse to dive deeper into the practical realm of how to actually use machine learning and how to deploy such a system to production” Juha explains.
Coffee is the stuff that helps our devs maintain a steady coding flow for hours and our designers constantly come up with creative ideas. Thanks to the coffee bot, anyone needing an energy boost will be able to check the status of coffee without ever leaving their seat. Next, we’ll program the bot to send us a Slack message every time there is fresh coffee in the kitchen. Thanks, Juha!