Train and predict automation model pipeline
Introduction
Welcome to the Model Automation Training and Prediction tutorial!
In this guide, you'll learn how to automatically train a computer vision model and use it to make predictions on local images directly from your Python code.
This tutorial provides you with the necessary steps to achieve the following:
Automatically run training with given or default parameters.
Download pre-trained model weights from Team files where all generated artifacts will be saved.
Perform inference with a pre-trained model on local images to obtain object detection predictions.
Upload annotated images to Supervisely
π» We wll use a 196 lines of Python code in main.py to demonstrate the entire process.
Before we dive into the tutorial, let's learn how to debug it.
How to debug this tutorial
Step 1. Prepare ~/supervisely.env file with credentials. Learn more here.
Step 2. Clone repository with source code and demo data and create Virtual Environment.
Step 3. Open repository directory in Visual Studio Code.
Step 4. change β
workspace ID, team ID, and project ID β
in local.env file by copying the ID from the context menu. A new project with annotated images will be created in the workspace you define. Learn more here.
Step 5. Start debugging src/main.py
Go to Run and Debug section (Ctrl+Shift+D). Press green triangle or F5 to start debugging.
Suppervisely allows you to connect your own computers with GPU to the platform and use them for model training, inference and evaluation β¨ for FREE. It is as simple as running a single command in the terminal on your machine.
π Watch the short video to learn how to connect your machine.
Prepare labeled data
You can use on of our demo projects.
If you already have the labeled data β just upload it into Supervisely platform using one of the 70+ import Supervisely Apps from our Ecosystem. You will find there the imports for all popular data formats in computer vision.
Python code
Import libraries
Load environment variables
Load environment variables with credentials, team ID, project ID, and workspace ID. Init api for communicating with Supervisely Instance.
Define variables
Set the path to the image you want to predict on
Train model
Explore training artefacts in Team files
Training process generates artifacts including model weights (checkpoints), logs, charts, additional visualizations of training batches, predictions on validation, precision-recall curves, confusion matrix and so on. At the last step of the training dashboard you will see the location and direct link where the resulting directory with training artifacts is saved.
It is automatically uploaded from the computer used for training back to the platform to Team Files. You can find it there at any time.
Download model weights from Team files
Get model predictions and visualize
Upload prediction in Supervisely format
Explore result project with model predictions in Supervisely.
Last updated
Was this helpful?