Product
September 11, 2024

Launch: Custom training scripts on Viam

Written by
Jack Damon
Operations Manager

Introduction

We just launched support for training models with custom Python scripts, allowing you to control the model training process on Viam and leverage any Python-based framework.

Viam provides tools for each stage of model development and usage: from data collection and labeling to model training, deployment, and on-device inference. Previously, users could use Viam to train image classification and detection models with TFLite. With this update, Viam users can now:

Support for custom training scripts provides greater control over your entire model development process on Viam, with the ability to define custom model architectures, specify loss functions, implement domain-specific data preprocessing and feature engineering, and utilize any preferred machine learning framework.This opens up many possibilities for training and deploying a wider range of specialized models.

How to use custom training scripts on Viam

You can upload your custom training script via either the Viam CLI or web app.  Let’s show how to use the CLI and web app to upload a training script to Viam and submit a training job. 

1. Compress your training script project directory

The upload is expected to be a gzip-compressed tarball (.tar.gz). If you’re using macOS, you can create this by running the command tar -czvf your-directory-name.tar.gz your-directory-name/ in the terminal. If you’re using a different operating system, the command might differ slightly, so please adjust accordingly.


2. Upload your training script to the Viam registry w/ the Viam CLI

To upload a custom training script to the registry, use the viam training-script upload command. This command allows you to specify various parameters to customize your upload.  `path`, `org-id` and `script-name` are required, and the rest are optional.  

You can see the full list of arguments in our documentation.

viam training-script upload --path=my-training.tar.gz --org-id=
--script-name=my-training-script --framework=tensorflow 
--type=single_label_classification --description="This is a sample training script for single label classification." --visibility=private --version=1.0.0

Uploading your training script to the Viam registry
Uploading your training script to the Viam registry

3. Submit a training job

Go to a dataset page, click “Train model”, and choose your custom training script.

4. Your trained model will be accessible when the training job is complete.

When the training job is complete, you can access and deploy the model to any of your machines configured on Viam.

Benefits of custom training scripts

Custom training scripts on Viam enable several key advantages:

  • Flexibility: Develop tailored solutions with custom preprocessing steps and model architectures specific to your data and problem domain.
  • Framework freedom: Leverage any Python-based machine learning framework (e.g., PyTorch, TensorFlow, Scikit-learn) that best suits your needs.
  • Seamless integration: Move efficiently from data collection to model training and deployment within a single platform, streamlining your ML workflow.
  • Iterative improvement: Easily retrain and update models as more data becomes available, enabling continuous refinement of your AI solutions.

Conclusion

The introduction of custom Python training scripts to Viam lets developers create domain-specific AI models while integrating with Viam’s data collection and model deployment infrastructure. Whether you're working on time series analysis, computer vision, or a different, novel AI application, Viam's model training infrastructure can now support your specific requirements and accelerate the path from collecting data to building and deploying solutions.

Interested in collecting data, building custom models, and deploying to your hardware? Sign up for free and start building on Viam today.

On this page

Get started with Viam today!