Quickstart Guide

Usually, there are a lot of steps you need to do before you can train a new computer vision model - gathering data, cleaning data, annotating data, possibly augmenting data, and exporting data in the right format. All of this takes time.

Note: If you are new to computer vision models and model training, read our introductory article.

This quickstart guide is intended to get you up and running and training models right away, so we have simplified the process to 4 steps:

We’ll provide you with a ready-made dataset, in the correct format, so you can focus on training. We’ll guide you through training a license-plate detection model, using a subset of the same dataset we used to train the license plate model in our catalog. And finally, we’ll also walk you through setting up a project, publishing your new model, and testing it out in an application. We’ll finish with a summary and some next steps. Let’s get started!

Step 1: Set Up Your Machine

First, make sure your system is ready to train by completing the set up guide.

Step 2: Download the Dataset

Get the dataset here. Move it someplace convenient and note the path.

Note: Make sure you’re logged in! You can test this with aai user show. Use aai user login to login if you’re not.

Step 3: Train Your Model

The command you’ll use to start training is

$ aai dataset train dataset_sample_584.zip --labels license_plate vehicle --numSteps 2000 --batchSize 4 --id <username/modelname> 

Make sure to use your own username for the –id flag, and you can put whatever you want for modelname.

Running the above command should result in something similar to the following:

image

This training took approximately 30 minutes using a CPU. You will see loss information printed out for each step, so you can tell how far along in the training process you are at any given time.

Note: For more details on interpreting the this output, see our documentation on training output.

Step 4: Use Your Model in a Project

Once training has finished, the first thing to do is publish the model to your personal models, using the following command:

$ aai model publish <username/modelname>

Now the model has been added to your personal account. For more information on how to use models, see this page.

You can also use the model locally by navigating to an existing project directory and using

aai app models add <username/modelname> --local-version <version>

This model can be used in any object-detection based project. For more information on working with projects, see here.

Run aai app install and aai app start to run the example app and test the new model output!

Summary

The dataset used in this tutorial has 584 images. The rule of thumb is that at least 20 epochs are needed in training a model; this translates into about 2,900 steps using a batch size of 4 (you can read more about model fundamentals and determining the necessary number of steps on our FAQ and overview documentation). With 2000 steps we’re about two thirds of the way there, but the model is already able to detect a fair number of vehicles, and some license plates! Some of the bounding boxes, especially for license plates, are not perfectly centered, but we’re off to a good start in only about 30 minutes.

Next Steps

This guide is meant to be an introduction to the model training tool. At this points you have a couple different options. You can

  1. Train the model further, or

  2. You can begin training a new model

Continue Training

If you would like to improve this model, the first step is just to run it longer. Simply navigate back to the training directory, and enter

$ aai dataset train resized_dataset_sample_584.zip --labels vehicle license_plate --numSteps [old_steps + new_steps] --batchSize 4 --id <username/modelname> --continue-from-version <version>

Note: Your numSteps will be the total number of steps, so it is equivalent to the steps you ran previously plus the number of steps you wish to run in the current iteration. Make sure you enter the version of the model you want to continue from as well (e.g. '0.1').

To update the version of a model already used in a project, navigate back to your app directory and run

$ aai app models update

Train a New Model

Generating a dataset and annotating it are where you will spend most of your time when creating your own models. If you don’t have a data set yet, follow these steps to generate one:

  1. Check out our documentation on data capture guidelines,

  2. Optionally, use our data generation starter application to generate your dataset, and

  3. Read our guide on data annotation using our annotation CLI tool.

You can make your own dataset from scratch, or you can add images and annotations to the dataset we provided. You would do this to potentially improve the performance of license plate detection model on certain vehicles or plates, or in certain environments.

Repeat the training process you followed in the first stage of this guide using your newly generated dataset.