Training a Drink Classifier with Fastai

submited by
Style Pass
2024-05-01 06:30:03

I recently started a new course called Practical Deep Learning. The course is taught by Jeremy Howard, a machine learning legend and founder of fast.ai. One of the first lessons in the course was training a classifier to detect birds in images. As part of learning the materials, I thought i’d be a fun experiment to extend this model to classify the top 10 most popular cocktails. Let’s get started 🍸🍹.

In order to accomplish this goal, we’ll be fine tuning a resnet18 model on images collected via the DuckDuckGo search engine. From there, we’ll feed the model our images to see how it performs.

In order to train the model, we need some images of cocktails. Luckily, DuckDuckGo provides a nice way to do this. We’ll use a python package called duckduckgo_search to accomplish fetching some images for training. Let’s define a function that takes a search term and max_images and returns a list of image urls for download

Let’s now collect 100 images of each drink type for training. We’ll also cleverly create drink directories so that we can use the parent directory name for training later. The last thing we’ll do is use the fastai verify_images function to remove any images that weren’t downloaded correctly.

Leave a Comment