Train a Model

You can add classification tags or bounding boxes to images collected by machines, add them to a dataset, and use the annotated data to train a Single Label Classification Model, Multi Label Classification Model or Object Detection Model within Viam.

When training machine learning models, it is important to supply a variety of different data about the subject. In the case of image classification, it is important to provide images of the object being identified in different situations, such as from different angles or in different lighting situations. The more varied the provided data set, the more accurate the resulting model becomes.

Train a model

After creating a dataset, navigate to the DATA tab and the DATASETS subtab. Then click on the dataset you want to train a model from and click on the Train model button on your dataset’s page.

On the Train a model menu:

  1. Enter a name for your new model.
  2. Select a Model Type and one or more labels to train on:
    • Single Label Classification: The resulting model predicts one of the selected labels or UNKNOWN per image. If you are only using one label, ensure that the dataset you are training on also contains unlabeled images.
    • Multi Label Classification: The resulting model predicts one or more of the selected labels per image.
    • Object Detection: The resulting model predicts either no detected objects or any number of object labels alongside their locations per image.
  3. 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.

The trained model

Train a new version of a model

If you deploy a model to a machine, 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 machine. If you train a new version of that model, Viam will automatically deploy the new version to the machine and replace the old version.

If you do not want Viam to automatically deploy the latest version of the model, you can change packages configuration in the Raw JSON machine 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": "YYYYMMDDHHMMSS",
  "name": "<model_name>"
}

Delete a model

You can delete a model from the models page in the Viam app:

  • To delete a trained model, click the icon to the right of the model name under the Models section of the page, and select Delete.

    Delete a trained model

  • To delete a model that has failed training, click the trash can icon to the right of the model name under the Training section of the page.

    Delete a failed model

Next steps



Have questions, or want to meet other people working on robots? Join our Community Discord.

If you notice any issues with the documentation, feel free to file an issue or edit this file.