DataSentics 20.07.2020

Beer Inspector AI: How to Define a "Good" Beer? (Part 1)

DataSentics have found the answer to the most worrying question of the beer lovers': how to measure the beer's quality? The first criterion is beer ratio, ranked in the glass where the bartender drafted the beer. The hop drink head structure is also essential. Ideally, it should be airtight, thick, and without air bubbles. Another indicator of the quality of the beer is its lacing on the glass. Even though these criteria are clear and univocal, the controllers hired especially for examining the brand's beer and giving the feedback are subjective. That's why Beer Inspector, the tool that helps rate the beer objectively, is very useful. The app's assessment is based on the beer photo taken three times in count of beer characteristics. Beer Inspector classifies the beer on the image and offers reports and complete documentation to its user.

Filled with mingled cream and amber,
I will drain that glass again.
Such hilarious visions clamber,
Through the chamber of my brain.
Quaintest thoughts, queerest fancies
Come to life and fade away.
What care I how time advances;
I am drinking ale today.

This was a poem about the main topic of this article, beer, called “Lines on Ale” by an American writer and poet Edgar Allen Poe. Czech beer is a phenomenon that has made our small republic famous all over the world. However, it is also a subject of many arguments and quarrels, whether it is too cheap or expensive, which brand tastes the best or whether drinking “one” before driving should be prohibited or not.

Let’s not discuss these subjective topics and just move on to the main objective: defining and measuring beer’s quality, since that is the reason to pay a bit more for a beer in the pub, isn’t it? It doesn’t matter what brand, size, or colour of the beer you prefer, a bit more expensive beer in the premium restaurant should be “better” than one in a local pub.

But what is the definition of a “good” beer that we, consumers, can notice on a glass of lager? According to beer brewers, there are three visual indicators that the beer was drafted correctly, which are assessed by hired controllers and must be fulfilled to get the “good” beer.

The first one is quite obvious: beer ratio. Every beer brand usually has its own glass that its beer should be drafted in. There should be accurate and clear marks of the bottom and top lines on this glass for the correctly drafted beer (or at least one). That means that if the beer line is strictly on the 0.5l mark of the glass, you should always get this much beer, no more, no less. In this scenario, both incorrect possibilities are equally wrong (subjectively, you would probably not mind getting more beer).

Since the marking system with one line would depend a lot on the skill of the bartender, most brands use two lines. For example for the Pilsner Urquell brand, the correct beer ratio is defined as a range between the lowest and highest point of the company logo on the glass. In other words, the correct beer ratio of the drafted beer is a range between 55 and 78 percent of the glass’s height! Now imagine the difference in the volumes in the limit cases!

Equally important is the beer head structure. Beer head (also head or collar) should be dense, thick, airtight, optimally there should not be any noticeable air bubbles, because their bursting leads to thinner beer head and faster warming. Correct beer head structure should prevent losing beer head a few seconds after your beer was brought to your table and that the beer head will still “sit” on top of the beer until you “finish” it.

Beer head lacing (also lacing or lace) on the glass is the last visual indicator and directly corresponds to the beer head structure. If the beer head structure is correct, then you should see a beer head lacing (nearly) every time you sip the lager. Beer head lacing has several forms. It can be in the shape of a circle or semicircle around the circumference of the glass or simply a blob.

These three attributes are very important for breweries because they can easily get feedback about their created products, and how these products are handled by bartenders - since bad pub ratings with their drafted beer can affect their sales. Therefore they hire controllers, whose work is to take a stroll in their city and check the brand’s drafted beers in the pubs and restaurants.

And here is the dilemma. Every feedback is subjective because all the controllers judge the drafted beer by their own standards, which can be affected by their current mood or simply liking that pub or bartender. Also, there isn’t any proof that would support the controller’s statements about that specific drafted beer.

Beer Inspector logo.

That’s when Beer Inspector comes to play! It is a tool for objective photo-based assessing of drafted beer and storing the results in a database for reporting and further optimisation. Beer Inspector utilises deep learning methods to train a model on a given large image dataset, which then assesses a taken photo. So the only thing that a hired controller needs to do is take a picture of the drafted beer three times - one image per visual indicator. One picture is taken from a distance to correctly measure the beer ratio, one close up photo of the beer head is for structure, and then after taking a few sips, the last one is for beer head lacing on the glass.

For beer ratio, this tool has to solve many additional subtasks first, such as rotation of the image, different shooting heights, or the beer caps (when the beer head is higher than the edge of the glass). Then it detects the front of the glass, beer, and then correctly calculates the beer ratio.

Original image and image with detected beer ratio.

Classifying beer head structure has some issues too. How big, and how many bubbles mean that the beer head can be considered bad? The solution is to detect the beer head in the glass, select only this area from the image and divide it into many small parts. Then each of these parts is classified whether it is good or bad beer head structure. Finally, these results are summed up and we receive the beer head ratio, which represents how many parts of the beer head were classified as good. Now we only need to select some threshold value.

Obsah obrázku jídlo, nápoje, dezert 
Popis byl vytvořen automaticky

Original image and image with classified beer head grids.

It is almost the same story with the beer head lacing on the glass. Photos and calculated results are then stored in the database for reporting and further study for method and/or model improvements.

And that’s it! In summary, Beer Inspector’s advantage is that it objectively classifies drafted beer from the photo and brings full documentation and reports to the customer.

The next part will be focused on the technical solution!

Read part 2