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.
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
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.
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.
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.
Tip
To keep your data organized, you can configure a tag in your data management service config panel. This tag will be applied to all data synced from that machine in the future. If you apply the same tag to all data gathered from all machines that you want to use in your dataset, you can filter by that tag in the Viam app DATA tab, or when querying data.
This is not required, since you can use other filters like time or machine ID in the DATA tab to isolate your data.
Train and test a machine learning (ML) 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.
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.
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
).
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.
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!