Google Teachable Machine (No-Code)
Create an image classification model using Google's Teachable Machine and deploy it to a mobile app with PalletML.
An image classifier is a machine learning model that recognizes images. When you give it an image, it responds with a category label that represents the content of that image.
In this tutorial, you will use Teachable Machine to train a powerful image classification model that you can deploy as an app using PalletML - all without writing any code!
You train an image classifier by showing it samples of labeled images. For example, you can train an image classifier to recognize different flowers by showing it a variety of pictures of roses, tulips, sunflowers, etc.
There are three general steps involved in training an image classification model with Teachable Machine:
- 1.Gathering sample images
- 2.Training the model, and
- 3.Testing the model
After you've trained the model to your satisfaction, you can export it as a file and deploy it to mobile using Pallet.
Let's start by gathering example images for training.
Training takes place within the browser. The data stays in your machine without being moved to the cloud.
Once you decide what objects you want your model to be able to recognize, you need to collect and organize sample images for each label. It's common to sort these sample images into subfolders by label (or class).
For example, say we want to create a classifier that can recognize 5 different types of flowers: daisies, dandelions, roses, sunflowers, and tulips. We would collect and organizes pictures of each of these different types of flowers into the following folder structure:
If you want to get started quickly without creating your own image dataset, we've included a structured dataset of flower images for you to use for training. Download it from the following link and unzip the folder to your computer: Flower Photos.zip (Google Drive)
Now that you've prepared a dataset, we can easily create an image classifier using Teachable Machine.
Add a class for each label in your dataset. (For the flowers dataset above we would add 5 classes). Then rename each class to something meaningful, such the name of a label.
Next, Upload each folder of sample images to the corresponding class. You can either browse for the folder of images, or simply drag and drop the entire folder into the window.
Now Train your model. This step will take a few minutes.
Remember, all of the training happens locally on your computer, and machine learning is a computationally heavy process, so don't worry if the webpage appears to be sluggish for a few minutes.
Once your model finishes training, you can immediately test it in the Preview pane that becomes available on the right. Just toggle the Input to File, and browse for - or drag & drop - a sample flower picture. The sample picture can come from your dataset or anywhere else, like Google Image Search.
If your model is not performing as well as you'd like, you may want to try adding more example pictures to each class and retraining. Otherwise, it's time to turn your model into an app!
To deploy your model to mobile using Pallet, you first need to save it to a file.
Click Export Model in the Preview pane on the right.
In the window that pops up, select the TensorFlow Lite tab, and under Model conversion type ensure the Floating point option is selected. Then click Download my model.
Your TensorFlow model will be converted to TensorFlow Lite (optimized for mobile devices), packaged with your labels, and downloaded to your computer (this step should only take 1-2 minutes).
converted_tflite.zipfile to confirm that you have a TensorFlow Lite model and labels.
You're all set to deploy your model to Pallet!
In this tutorial you learned how to create a standard, yet powerful image classification model using Teachable Machine, and deploy it as a mobile app using PalletML.
However, Teachable Machine's training process is constrained in ways that limit the predictive power of models it produces.
To learn more about limitations of tools like Teachable Machine, and how to create more powerful models that can be used in the real-world, continue on to the next section. (coming soon...)