- Date: February 4, 2024
- Categories: Fun
The code for this project is published on Github
Background
I have recently admittedly been thinking about projects to work on. I knew I wanted to make something, but an idea “worthy of a portfolio piece” just hadn’t came to my mind. And then I saw a LinkedIn post (one of those cringey inspirational ones) that spoke about caring less about making grand things, and just focussing on basic concepts that you actually enjoy creating.
At that moment it hit me, I want to make a project that uses the Hyper Text Coffee Pot Control Protocol! 418 is an easter egg HTCPCP/1.0 status code, that indicates that the server is unable to brew a coffee, as it is indeed a teapot. I started to ponder what I actually wanted to make, and then came across two Github issues (Go, NodeJS) where some boring developers wanted to actually…get rid of the easter egg HTTP code…to make space for extra ones in the future…what?!
I then stumbled across the Save 418 Movement and realised that heck, even Google implements the 418 status code… I HAD to join in and make a “useful” application of the 418 HTCPCP/1.0 protocol…
Tea Pot Or Not?
So what actually is this application? Well put simply, it’s a basic Flask API that you provide an image to, and then it will return one of three messages:
- 418 I’m a teapot
- 200 Here’s your coffee
- 200 I’m not a teapot
The messages will be driven by the provided photo, by using machine learning to detect if the image contains a photo of a teapot, a coffee machine or neither.
Implementation
Honestly, I could’ve used this project as a grand plan to learn how to create, train and validate machine learning models in Python, but I wanted to create the project in a few hours…There’s plenty of time to learn about Machine Learning models in the future, but in my hungover state at the time, I just wanted to quickly slap up an API to determine if something is a teapot or not!
With the above in mind, I started to research a bit about pretrained Machine Learning models. I first found an image dataset called Open Images V7, which has generously been placed in the public domain and contains literally millions of pre-annotated images ready to be used for training machine learning models.
At this point, I wanted to try and download a subset of the data (specifically just teapot images and coffee machines). I searched tons and tons of guides on doing this, but eventually I got bored of all the console errors I was getting.
Scrap that plan… On to doing what a developer does best, and just copying someone else’s work. I discovered a Github repo for Ultralytics which provides it’s owned YOLO state-of-the-art model that has been trained on the Open Images V7 dataset. Following a few examples, I started to play around with it in a new Python file.
Now all I needed to do was build an API that can accept a file via a BREW/POST API request, and then classify the objects in the image, and return a response based on the result.
The End
And that’s it really, the resulting code is published on my Github. I don’t actually think there is anything to show off here, just under a hundred lines of code that “borrows” someone else’s model and returns a response on it. The only real learning from this project was some extra context on the basics of machine learning models, the desire to learn more about machine learning, and most importantly…The history of the Hyper Text Coffee Pot Control Protocol.
Rest assured, I’m diligently looking for any opportunity to implement a HTCPCP/1.0 418 response in my current companies codebase, probably an internal tool or something… Thanks for reading!