How to train and deploy ML/computer vision models

You can use Viam’s built-in tools to train a machine learning (ML) model on your images and then deploy computer vision on your machines.

Diagram of the camera component to data management service to ML model service to vision service pipeline.

For example, you can train a model to recognize your dog and detect whether they are sitting or standing. Then, you can configure your machine to capture images only when your dog is in the camera frame so you don’t capture hundreds of photos of an empty room. You can then get even more image data of your dog and improve your ML model by training it on the larger dataset.

You can do all of this using the Viam app user interface. You will not need to write any code.

Create a dataset and label data

Collect data

1. Collect images

Start by collecting images from your cameras and syncing it to the Viam app. See Collect image data and sync it to the cloud for instructions.

Label data

2. Label your images

Once you have enough images of the objects you’d like to classify, use the interface on the DATA tab to label your data. If you want to train an image classifier, use image tags. For an object detector, use bounding boxes.

Label data

2. Create a dataset

Use the interface on the DATA tab (or the viam data dataset add command) to add all images you want to train the model on to a dataset.

Train and test a machine learning (ML) model

Train models

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.

Train models

2. Deploy your ML model

On the Configure page add the built-in ML model service and select your ML model. The service will to deploy and run the model. Once you’ve added the ML model service to your machine, choose your newly-trained model from the dropdown menu in the ML model service’s configuration card.

Configure a service

3. Configure an mlmodel vision service

The vision service takes the the ML model and applies it to the stream of images from your camera.

Add the vision / ML model service to your machine. Then, from the Select model dropdown, select the name of the ML model service you configured in the last step (for example, mlmodel-1).

Deploy your model

4. Test your classifier

Test your ML model classifier with existing images in the Viam app, live camera footage, or existing images on a computer.

Next steps

See the following tutorials for examples of how to use the tools described on this page:

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.