Train a Model
You can tag images collected by robots and use the labeled data to train a Single Label or Multi Label image classification model within Viam.
Label a dataset
To label a dataset, go to the DATA tab in the Viam app.
On the Images subtab, you can filter available images, using the Filtering menu and select the attributes that match where, how, and when the data was collected.
Important
Datasets are views, not materialized. If the underlying data matching the filter changes because data is deleted or more data is added, the dataset will also change.
Therefore the data you are viewing may change as you label and train on the dataset.
If you would like to create a model that identifies an image of a star in a set of images, tag each image with a star with a star
tag.
You can also optionally tag images without a star with a notstar
tag.
This allows you to filter down the data in your dataset further by adding the explicit tags as a filter, for example star
and notstar
.
To tag an image, click on the image. More information about the image will open up to the right side, including Tags.
Click on the Tags dropdown and create a new tag or select an existing tag to apply it to the image.
Repeat this with all images in your dataset.
Train a model
When you’ve tagged all the images click on the TRAIN MODEL button in the top right corner.
A Training side menu opens. The model that you configure to be training will train on all images part of the current filter.
- Select New Model.
- Specify a Model Name.
- Select a Classification Type:
- Single Label: predicts one label per image
- Multi Label: predicts multiple labels per image
- Select one or more tags to train on.
The selected tags will be the possible tags the model predicts for a given image.
- If you selected Single Label, the model will predict one of these labels or
UNKNOWN
. - If you selected Multi Label, the model can predict one or more labels for each image.
- If you selected Single Label, the model will predict one of these labels or
- Click TRAIN MODEL
The model now starts training and you can follow its process in the Training section of the Models page.
Once the model has finished training, it becomes visible in the Models section of the page.
Train a new version of a model
If you deploy a model to a robot, Viam automatically assumes that this is the latest
version of the model and that you would always like to deploy the latest
version of the model to the robot.
If you train a new version of that model, Viam will automatically deploy the new version to the robot and replace the old version.
Note
The previous model remains unchanged when you are training a new version of a model and is not used as input. If you are training a new model, you need to again select the images to train on because the model will be built from scratch.
If you do not want Viam to automatically deploy the latest
version of the model, you can change packages
configuration in the Raw JSON robot configuration.
You can get the version number from a specific model version by clicking on COPY on the model on the model page. The model package config looks like this:
{"package":"<model_id>/allblack","version":"1234567891011","name":"<model_name>"}
Next Steps
To deploy your model to your robot, see deploy model.
Have questions, or want to meet other people working on robots? Join our Community Discord.
Was this page helpful?
Glad to hear it! If there is anything we could be doing better, please create an issue.
We're sorry about that. If you'd like to talk to us for help, please join the Community Discord. To ensure we know what's wrong with this page, you can also open an issue.