How to easily download bulk images for training a model on Teachable Machine
Teachable Machine (TM) is Google’s generous way to make machine learning more accessible. You can train models to recognise images, sounds and body poses by classifying your own input images. As an example, you could teach TM to identify your left and right head movements as two separate classes, which could then be used to control a mini-game of snake in ml5 in your browser. Oh wait, that’s exactly what my internet hero The Coding Train did. Cool stuff!
When making a pose project (using body tracking), TM gives you the choice of uploading images or inputting live images with your web camera to detect human poses. It is usually more accurate when you use the camera because you can input a lot more data with less effort. However, this could be an issue if you want people who aren’t a direct clone of you to use your product! If your clone colony are going to be the target users, then it’s perfect for you! Sorry if you’re designing for humans, though. Ugh, people!! The worst, right?
In order to get a broader range of input data and human shapes and colours and sizes, I wanted to see if I could make a model with image input using lots of different images. In order to input images, I was going to need a lot of photos with a wide range of humans… but where do we get such images? If only there was some way to type in a search term and get some kind of image repository to pop up in response. This would be a great business venture for anyone interested. Oh, wait, Google Images. Ah! It already exists.
My next thought was ‘how do I use this image repository to make my job easier?’ Well, internet stranger, it’s quite simple really. After searching ‘how to download images for machine learning training’, things were looking… Python-y. I decided that 4pm on a Tuesday was not really the time to start learning how to code in Python. This was out of the question, the one day I spent in University trying to use Python was more than enough for me. BUT I found a Chrome extension that did what I needed, and it is fittingly called ‘Download All Images’. I say a silent prayer for the creators who make Chrome Extensions that make my very privileged life far simpler.
Here’s how I did it.
Install the Chrome Extension
Do that here
Search for something on Google Images
The more generic, the better. The idea is to get LOTS of images. So, if you search for something niche like ‘Jim Carrey painting in his Los Angeles home’, you’ll have a good experience, but it is not really useful for a machine learning model. Unless you are Jim Carrey and you want a computer to play your painting jams every time it sees you painting. Hi, Jim Carrey! Big fan.
I digress… where were we? I googled ‘Yoga Tree Pose’ to keep things simple and zen.
Ironically, I wanted to use Google Images to get a more diverse range of data, but when you type in yoga-related words, the opposite happens. It’s just skinny white ladies defying human flexibility. My bad. Perhaps I should have chosen a more racially diverse human pose.
Click on the extension and open the zip file
Click on the ‘Download all Images’ extension while in your image search (do this by clicking the little puzzle at the top right of your Chrome Browser to find the extension). Doing this will automatically save a zip file of all of the images on the page to your downloads folder on your mac (or whatever the Windows equivalent is, I don’t actually know how computers work).
Here’s what I unzipped:
Delete all of the irrelevant images
I ended up with 140 images of people doing a tree pose. You could keep scrolling into the Google abyss and repeating the process until you have a good selection. The extension also scanned the icons on the webpage, so go ahead and get rid of them.
Create a new project on Teachable Machine
Go here and click ‘get started’. Choose what kind of project you want to make. Your downloaded images won’t be of much use if you want to do an audio project, but still worth checking out. God, don’t we love Google? And by God, I mean Larry Page and Sergey Brin.
Drag the images into your first class
Give your class a cool name like ‘Tree pose’ or ‘My tears’. Load them up! You can also input images with your face/body via a webcam.
Make your own samples
After going through the motions of the chrome extension and the unzipping and the systemic racism, I decided to stand up on my actual legs and allow them to support my body weight to take live images. Do this at your own discretion. Consult with your Design Doctor to see if it is safe for you to take your gaze off your Figma wireframes for more than a minute.
*Change the settings if you can’t hold the mouse down AND pose at the same time.
Train the Model
The next thing you need to do is train your model. Don’t close the tab while this is happening. Depending on the number of your samples, this could take a little while. Once you have trained the model, you can test to see if it can differentiate the two classes. Or maybe you want three or four classes! That’s up to you.
Testing the Model
Once you have trained your model, you can test it out and see if your poses are recognisable. In the end, I had to re-train the tree pose with my own input images manually. I am not sure of how well this bulk upload of images works for poses, I will have to try again someday. Regardless, I think Teachable Machine is such a powerful tool for people from across all disciplines. The interface makes it really understand how your data is being processed and it is definitely worth trying! I will definitely wear a longer skirt the next time I experiment with Teachable Machine!
If you found this interesting, check out other Experiments with Google to see some very cool applications of this tech and lots of other exciting experiments! Also, feel free to let me know if I explained something incorrectly or didn’t quite grasp some of the lingo. I want to keep learning and growing in this field and I am open to any and all corrections in the comments!