Previous
Create a dataset
Many machines have cameras through which they can monitor their environment. With machine leaning (ML), you can train models on patterns within image data. 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 that contains your labeled images, you are ready to train a machine learning model.
Find your training dataset
In the Viam app, navigate to your list of DATASETS and select the one you want to train on.
Train an ML model
Click Train model and follow the prompts. You can train a TFLite model using Built-in training.
Click Next steps.
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.
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.
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 the results exceed the confidence threshold, the Run model section shows a label and the responding confidence threshold.
You can test both detection models and classifier models using the following resources together:
tflite_cpu
ML model with the model you just trainedmlmodel
vision service using the tflite_cpu
modelWith the right training dataset, your ML model can perform well as soon as training completes. However, edge cases always exist. You are unlikely to account for all false positives or false negatives during your first round of training. Instead, keep track of edge cases as you run your model. Add images capturing edge cases to your training dataset, annotate them, and re-train your model using the new data. Using this approach, each subsequent model version becomes more accurate than the last.
To capture images of edge cases and re-train your model using those images, complete the following steps:
Add edge case images to your training dataset. You can find edge cases in your existing data on the DATA page or capture new images and add them to your training dataset.
Visit the DATASET tab of the DATA page and annotate the image.
Repeat the steps above to train and release a new version of your ML model. Your machines will automatically update to the new version of the model soon after release.
Now your machine can make inferences about its environment. The next step is to deploy the ML model and then 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!