Previous
Create a dataset
Many machines have cameras through which they can monitor their environment. With machine leaning, you can train models on patterns within that visual data. You can collect data from the camera stream and label any patterns within the images.
If a camera is pointed at a food display, for example, you can label the image of the display with full
or empty
, or label items such as individual pizza_slice
s.
Using a model trained on such images, machines can make inferences about their environments. Your machines can then automatically trigger alerts or perform other actions. If a food display is empty, the machine could, for example, alert a supervisor to restock the display.
Common use cases for this are quality assurance and health and safety applications.
Follow this guide to use your image data to train an ML model, so that your machine can make inferences about its environment.
Now that you have a dataset with your labeled images, you are ready to train a machine learning model.
1. Train an ML model
In the Viam app, navigate to your list of DATASETS and select the one you want to train on.
Click Train model and follow the prompts.
You can train a TFLite model using Built-in training.
Click Next steps.
2. Fill in the details for your ML model
Enter a name for your new model.
Select a Task Type:
UNKNOWN
per image.
Select this if you only have one label on each image. Ensure that the dataset you are training on also contains unlabeled images.Select the labels you want to train your model on from the Labels section. Unselected labels will be ignored, and will not be part of the resulting model.
Click Train model.
3. Wait for your model to train
The model now starts training and you can follow its process on the TRAINING tab.
Once the model has finished training, it becomes visible on the MODELS tab.
You will receive an email when your model finishes training.
4. Debug your training job
From the TRAINING tab, click on your training job’s ID to see its logs.
Your training script may output logs at the error level but still succeed.
You can also view your training jobs’ logs with the viam train logs
command.
Once your model has finished training, you can test it.
Ideally, you want your ML model to be able to work with a high level of confidence. As you test it, if you notice faulty predictions or confidence scores, you will need to adjust your dataset and retrain your model.
If you trained a classification model, you can test it with the following instructions. If you trained a detection model, move on to deploy an ML model.
If the results exceed the confidence threshold, the Run model section shows a label and the responding confidence threshold.
Now your machine can make inferences about its environment. The next step is to act or alert based on these inferences.
See the following tutorials for examples of using machine learning models to make your machine do things based on its inferences about its environment:
Was this page helpful?
Glad to hear it! If you have any other feedback please let us know:
We're sorry about that. To help us improve, please tell us what we can do better:
Thank you!