Making Better Coffee using Artificial Intelligence

Alex Osterloh
Google Cloud - Community
3 min readNov 15, 2022

How to quickly build a Latte Art Detector on Google Cloud using Vertex AI, some Python and Cloud Run (almost no coding)

I love my morning cappuccino and try to improve my latte art each day. It’s not yet perfect but certainly better than my ML and App building skills. Thankfully Google Cloud makes it really easy to train your own models using AutoML, no coding required. For running the app I used Python and Cloud Run in the Google Cloud Shell Editor, more on that later.

Few years ago I have already used the AutoML Vision API to detect which graffiti artist created a piece of art. The same principal can be applied to latte art. Training an AI about which coffee is great or not so great is like teaching a young kid the difference between dogs and cats. Just show the kid (or the AI) lot’s of examples and it will learn. So I took all my morning cappuccino creation images and asked my 2000+ co-workers in Munich to add their great and not so great latte art images to a shared folder. In Vertex AI I created dataset based on 300+ images and labeled them as “Pro” and “Beginner”. This took just a few minutes.

Then I clicked “Train” and waited a few hours. I deployed the model to an endpoint and used some predefined Python code to call the model. I used Python Flask and Cloud Run to create and run my simple web application. Not being a developer this took actually the longest time but at least I learned a thing or two (e.g. how to resize images as Vertex AI has a 1.5MB limit on images).

You can try the app with your latte art here: https://latte-art-detector.com/

The app detects if you upload images that are not coffee by first checking with the Google Cloud (pre-trained) Vision API.

Edit (Nov 18th 2022): All coffee images land in a storage bucket that I have already used to retrain the next model version. So keep making great (or not so great) coffee :-)

Cloud Shell Editor for writing code and deploying to Cloud Run

To see my (beginner) Python app, go my Github project: https://github.com/aosterloh/latte-detector

Thanks to Christoph and Dorra in my team to help me get my app off the ground. This is not official Google work. Let me know if I missed something.

--

--