Train a webcam image classifier
ActivitiesProjects
Collect labeled examples of household objects and test whether the trained model recognizes new examples through a webcam.
You can build a working image classifier right in a web browser without writing code, using a webcam or uploaded image files to show a few distinct objects or poses. In standard classroom exercises using Teachable Machine, the project follows a straightforward loop: pick two or more visual categories, collect labeled examples for each one, train a standard image model, and test how it classifies new camera views.
Setting up classes and capturing examples
Start by choosing at least two classes (groups of related images) and renaming the default boxes so each label clearly describes the distinction you want the model to learn. Simple, easily demonstrated contrasts work well for a first try: cups versus sports balls, different hand shapes, or a person wearing a hat versus without one. You can add more classes if you want the model to sort among several categories.
For each class, choose webcam capture (granting browser camera access if prompted), place your subject in frame, and hold down the recording button to capture a burst of frames. Holding the button for two to three seconds at a time quickly builds a set. Repeat the process for every class, or upload existing image files instead of shooting everything live. Teaching exercises vary on how many samples to collect, from a few dozen images per class to at least 100, though no single count guarantees accuracy. If an off-subject or poorly matching frame slips in, delete it before training.
Avoiding unintended shortcuts
How you film each category matters as much as how many frames you collect. If every training photo shows a single red coffee cup held still in the same spot, the classifier may latch onto the red color or the visible handle rather than generalizing to other cups. To push it past those shortcuts, move and rotate the object while recording, show its other sides, vary angles and backgrounds, and include several different instances of the category whenever the label is meant to cover more than one specific item.
Training, testing, and refining
Once every class has its examples, start training and keep the browser tab open until it finishes rather than switching away. Then use the preview panel to test the classifier against unfamiliar views: hold up a different object from the same category, or turn an object to a new angle or position, and watch how the class confidence-percentage bars respond.
When a prediction misses or wavers, note the specific view that tripped it up. Go back to the classes, remove weak examples or record new ones covering that angle, background, or object, then retrain and test again.
Static frames and browser-based models
Even though the input comes from a live webcam feed, the image model classifies individual static frames and has no built-in sense of motion. It can tell apart a visible hand shape held in a single frame, whereas a gesture whose meaning depends on a sequence of movement over time is a different kind of problem.
Google originally built Teachable Machine as a webcam image-recognition teaching tool and expanded it in 2019 with Teachable Machine 2.0, adding sound and pose models alongside images. In that 2019 release, training ran directly in the browser, keeping examples on the user's computer unless saved to Google Drive, and the resulting TensorFlow.js model could be exported for use in websites and apps.
