Azure Custom Vision, part of the Azure AI suite of products, enables you to label data for, train, and deploy computer vision models. With Azure Custom Vision, you can train object detection and classification models in the Azure cloud.
In this guide, we are going to show you how to train a computer vision model using Azure Custom Vision. To train a model, we will:
- Label data for use in model training in the Roboflow platform, which provides an extensive suite of tools you can use to efficiently label data.
- Enable Azure Custom Vision on an Azure account.
- Import data into Azure Custom Vision.
- Train a model in the Azure Custom Vision web interface.
- Test and evaluate the model.
Without further ado, let’s get started!
Train a Model with Azure Custom Vision
For this guide, you will need an Azure account. If you have not already enabled Custom Vision use in your account, we will show the requisite steps later in the guide.
You will also need a free Roboflow account. Roboflow is an end-to-end computer vision platform that provides tools for data gathering, labeling, and understanding, as well as model training and deployment offerings. You can export your data from Roboflow at any time directly into Azure Custom Vision.
Step #1: Label Data for Use in Model Training
Before we can train a model, we need images to label. If you need images, check out Roboflow Universe, a community of public data for use in training computer vision models. You can find over 150 million images across 200,000 datasets on Universe.
In addition, you can use Roboflow Collect to collect data on the edge. Roboflow Collect provides an intelligent data gathering solution with which you can:
- Collect images that match a provided text prompt (i.e. “car”).
- Collect images that are similar to an image you have already collected.
- Prevent gathering duplicate images.
Fill in the pop up that appears with the name of your project, the type of object you want to identify, and the model type you want to train. (Note: You can only train object detection and classification models in Custom Vision. With that said, you can train segmentation models in Roboflow.)
Next, upload your images and any annotations you have to the Roboflow platform. You can label unannotated images in Roboflow and inspect and adjust annotated images. Roboflow supports annotations in over 30 different formats.
To upload your images, first drag in a folder of your images to the Roboflow web interface:
Once you have dragged your images into the web interface, click “Save and Continue”. Your images will then be uploaded to the Roboflow platform. The amount of time this process takes depends on the number of images in your dataset.
After your images have been uploaded, you can start annotating your data. Click on an image to start annotating.
To draw a bounding box, press “b” on your keyboard or select the bounding box tool in the right control panel. Then, click where you want to start drawing a box and drag until you have finished drawing the box. You can then create or choose a class to assign to the box.
To learn more about the Roboflow annotation tool, check out the complete guide to using Roboflow to annotate data.
Once you have labeled your data, click “Versions” in the sidebar of the Roboflow product to generate a project version. Here, you can preprocess your data and apply augmentations. Learn more about preprocessing and augmentation best practices.
We recommend leaving the preprocessing steps as defaults for your first model version, and reading our guidance on augmentations to evaluate which ones may be appropriate for the model you are training.
For this guide, we will apply a 90 degree rotate augmentation. This augmentation will help our model to perform effectively at different angles, a key consideration for aerial imagery like we are using in the example solar panel dataset in this guide.
Click “Generate” at the bottom of the page to generate a dataset.
Your dataset will be generated. We will come back to the dataset in the next step.
Step #2: Create an Azure Custom Vision Instance
Go to the Azure dashboard and search for “Custom Vision” in the search bar. This will take you to the Custom Vision homepage. Before we can use Custom Vision, we need to create a Custom Vision instance on our account. Click the “Create custom vision” button.
Next, you will be asked to fill out information about your project. First, you will be asked to select whether you want to train, deploy, or both train and deploy with Custom Vision. Select the option relevant to your project.
You will need to attach your Custom Vision instance to a resource group, select a project name, and choose the pricing tier for your instance. Learn more about Azure Custom Vision pricing.
Once you have filled out the form, click “Review + create” to create a new Custom Vision instance. You will be taken to a page that reports the status of your deployment. The deployment step can take a few moments.
Once your Custom Vision instance has deployed, you are ready to start using Custom Vision.
Step #3: Import Labeled Data into Custom Vision
You can import your data directly from Roboflow into Custom Vision. Go to your Roboflow dashboard and click the “Settings” button. Then, click "Third Party Keys".
A page will appear in which you can save your Azure Custom Vision account information.
Go back to the Azure Custom Vision dashboard. The product has its own user interface separate from the main Azure cloud platform. Then, click the settings icon in the top left. A list of Resources associated with your Custom Vision instance will appear. Click on the resource without "-Prediction'' at the end.
You will need two pieces of information from the page:
- Your API key
- Your endpoint name
Add these values into the Roboflow platform. Then, go back to the Roboflow dashboard, select the project on which you are working, and select Versions in the sidebar.
Select the dataset version you generated earlier. Then, click “Export Dataset”. A window will appear in which you can choose the format in which to export your data. Choose “Azure Custom Vision”.
The amount of time it takes to export your data to Custom Vision will depend on how many images you have annotated in Roboflow. A progress bar will appear that shows the status of the export job.
When the export has completed, go back to the Custom Vision dashboard. Here, a new project will appear that was created by the Roboflow platform. Click on the project to see the images imported. To see the annotations on an image, click on the image.
Step #5: Start a Training Job
With your labeled data in Azure Custom Vision, you are ready to start a training job. Click the green “Train” button in the top left corner of Custom Vision. A pop up will appear in which you can choose the option you want to use for training.
Once you have configured your training job, click “Start” to start training.
The status of your training job will be reported on the dashboard. Training times will vary depending on the number of images in your dataset. Once training has completed, you will see a report showing the precision, recall, and mAP of your model.
Step #6: Test Your Model
You can test your computer vision model within Custom Vision. To do so, click the “Quick Test'' button in the top right corner. A pop up will appear in which you can paste an image URL or choose a file to upload.
Once you have selected a file on which to test your model, your model will run and predictions will show on the image. The image below shows model predictions for an image from our solar panels project:
We have successfully trained a model in Azure Custom Vision! You can access all of your trained models from the Performance tab in your Custom Vision project.
To deploy your model, click the Publish button and choose a name for your model deployment. Then, click the “Publish” button in the pop up:
Click “Prediction URL” to see how to run an image through your model and retrieve predictions using the Custom Vision API.
In this guide, we trained a computer vision model in Azure Custom Vision. First, we labeled images using Roboflow. Then, we enabled Custom Vision on Azure. We imported our dataset from Roboflow into Custom Vision and trained a model. We tested the model in the Azure Custom Vision platform. Finally, we showed how to deploy the model on Custom Vision.
When you are ready to deploy your model trained in Azure Custom Vision, check out our Azure Custom Vision deployment guide.
Roboflow also offers tools to train and deploy your model. It only takes a few clicks to train a model with Roboflow and you can test your model without having to deploy an endpoint manually. You can train models using the dataset you uploaded and annotated in Roboflow earlier in the guide. Learn more about Roboflow’s model training and deployment offerings.
When you are ready to start writing logic that uses your model, check out supervision. supervision is an open source Python package that provides a range of utilities for use in building computer vision applications. supervision is actively maintained by the Roboflow team.
With supervision, you can:
- Filter predictions by class, box area, confidence, and more.
- Plot object detection and segmentation predictions on an image.
- Use ByteTrack for object tracking.
- Use SAHI for small object detection.
- And more.
To see the full range of capabilities available in supervision, read the supervision documentation.
Furthermore, check out Templates, a collection of detailed guides that show how to implement various logic that uses predictions, from sending emails when a prediction is returned to reading analog dials.