Click here to Skip to main content
15,867,568 members
Articles / Artificial Intelligence / Machine Learning
Article

Training a Custom Object Detection Model on Azure Custom Vision Part 1: Gathering Data and Training the Model

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
15 Mar 2022CPOL6 min read 5.3K   2   1
In this article we demonstrate how to train a model to detect the presence of a human in images.
Here we start with a data set that will let our model learn when and where a human is present in an image so we can use it to determine if a pedestrian has stepped in front of our vehicle. Then, we demonstrate how to use Azure Custom Vision train an object detection that can detect the presence and location of pedestrians.

This article is a sponsored article. Articles such as these are intended to provide you with information on products and services that we consider useful and of value to developers

Artificial intelligence (AI) has become a fundamental part of our daily lives. AI is everywhere, from social media and web searches to smart assistants, map directions, and facial recognition. However, understanding how these smart applications function has typically been limited to AI experts with significant knowledge of machine learning and deep learning.

Microsoft provides Azure Cognitive Services to remove these barriers, offering machine learning algorithms as a unique service. The availability of these services has revolutionized the ability to understand and build intelligent applications. Functions once limited to seasoned AI experts are now available to developers at all experience levels. Now, developers can access these services with just a cloud subscription, enabling them to build AI features into their applications without coding advanced machine learning algorithms.

Azure Cognitive Services includes several pre-trained API services, making it nearly impossible to review all of them within this article’s scope. Instead, this article series focuses on the Custom Vision service. Its goal is to enable a machine learning model to determine when and where a human is present in an image. Then, the model can recognize when a pedestrian steps in front of a vehicle. The model runs on an IoT device to monitor the road ahead of a vehicle continuously.

This demonstration’s code is available on GitHub.

First, this article will explore the process for training an object-detection model using Azure Custom Vision. Then, in the second article, we’ll test the model to ensure it’s ready for deployment. Finally, in this series' third and final article, we’ll deploy the model on a Raspberry Pi, ready to mount in a vehicle for real-time pedestrian detection.

What is Azure Custom Vision?

Azure Custom Vision is an image recognition service that enables building and training an image identifier model for a custom domain without any machine learning expertise. The Custom Vision service customizes a pre-trained image recognition model using the provided set of images for a use case.

Because it uses a pre-trained model, the service requires neither extensive data sets nor training durations to train a functioning use-specific model. Moreover, the Custom Vision service provides a simple user interface (UI) to train and test the model, then add the trained model to an application.

Setting up the Custom Vision Service

To train a human detection model with Azure Custom Vision, you need:

Azure accounts offer 12 months of free popular services and $200 credit to fully explore Azure for 30 days.

Creating a Custom Vision Resource in Azure

Before training the object detection model with Custom Vision, we must create a Custom Vision resource in Azure. This single resource allows uploading training images, training the image recognition model, and testing the model. You can do all this without writing a single line of code.

To create a custom vision resource, log in to the Azure portal with your Microsoft account. Once logged in, click Create a resource.

Image 1

On the next page, click Custom Vision. Then, on the Custom Vision page, click Create.

Image 2

On the Create Custom Vision page, select your subscription and resource group. If you haven’t previously created a resource group, click Create new to create a new resource group and name it.

Next, select a region, name your resource, and pick the Free tier for training and prediction. Once you’ve entered all the required details, click Review + create in the bottom left corner.

Image 3

Your service will take a few seconds to validate the settings. When the validation is complete, click Create.

Image 4

The deployment may take some time, depending on your connection. Once successful, click go to your resource to find your training and prediction services in your resource group.

Image 5

We have successfully deployed the Custom Vision services. The next step is to create an Azure Custom Vision account.

Creating an Azure Custom Vision Account

Now that your services are running in Azure, you can create a project in the Custom Vision portal and begin training your model. However, you need an Azure Custom Vision account before building the project.

So, go to the Azure Custom Vision service.

Image 6

Here, sign in with your Microsoft account linked to the Azure subscription and accept the Terms of Service.

Image 7

Successful login indicates that your Custom Vision account is ready. You can now create a project in the portal.

Creating a Project in the Custom Vision Portal

On the Custom Vision portal home page, click NEW PROJECT.

Image 8

On the next page, name your project — in this case, "pedestrian-detection" — and select a resource. Since this is a classic object recognition problem, select Object Detection as the project type and choose General (compact) [S1] as the domain since you can only export the model trained on the compact domain.

Once you’ve filled all the required fields, click Create project.

Image 9

When the project is complete, the project homepage loads. Your setup is now finished, and you can start training your model.

Building a Model to Detect Humans

The Custom Vision service requires uploading a set of user-selected images and tagging them accordingly. These images will customize the image recognition model for the specific use case.

Since the goal is to detect the presence of a person in the picture, the image data set must contain humans. For this purpose, use the INRIAPerson dataset available on Kaggle. Download the photos from the dataset before proceeding.

On the project page in the Custom Vision portal, click Add images.

Image 10

Select several images from the INRIAPerson training dataset and upload the files.

Image 11

Next, tag the uploaded images.

Click the first image to open an expanded window with the image inside. Hover over it to select the object of interest — in this case, the person — and tag it as human.

Image 12

Repeat this procedure for the rest of the photos.

Once you have tagged all the images, click Train in the portal’s upper right corner.

Image 13

Next, choose Quick Training, then click Train.

Image 14

The model takes some time to train. Once the training is complete, the model’s performance statistics will display.

Image 15

Next Steps

The Azure Custom Vision service simplifies training a machine learning model without writing a single line of code. This service empowers a broader range of developers to embed intelligent features within their applications, reducing development time and eliminating the need for extensive AI expertise.

The article showed how to train a simple machine learning model that identifies when and where a human is present in an image. The following article will demonstrate how to test this model and re-train it as necessary.

To learn how to drive app innovation and reap lasting business benefits with a faster approach to AI, check out Forrester study: Fuel Application Innovation with Specialized Cloud AI Services.

This article is part of the series 'Real World Custom Vision View All

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Student
Ireland Ireland
C# Corner MVP, UGRAD alumni, student, programmer and an author.

Comments and Discussions

 
QuestionNice works Pin
Abdulkader Helwan23-Mar-22 3:08
professionalAbdulkader Helwan23-Mar-22 3:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.