(uplifting music)
- Welcome to Azure AI Essentials.
In this video, I'll walk you through
foundational concepts to help you get started
building AI-powered applications on Azure,
whether you want to leverage APIs and SDKs,
or create an app without writing a single line of code.
Today, we're gonna look at how to create an application
that can detect objects in images or videos.
Object detection models can be used to enable
autonomous cars to detect objects around them,
to help inspect machinery,
to streamline inventory management,
or even to track ball and player movements
during a basketball game, as you can see here.
While we're using object detection as our example here,
most of the concepts you'll learn
can also be applied to other types of AI models.
You'll follow similar steps
with other types of Vision models,
like image classification,
as well as when you're adding Language, Speech,
and Decision capabilities to your applications.
With Azure Cognitive Services,
you can integrate pre-built AI models
into your applications, with just an API call,
or you can build custom models
with no machine learning expertise needed.
With Cognitive Services,
you have a choice of APIs or SDKs
for your preferred programming language,
and for some Cognitive Services,
you have the option of a UI-based portal experience.
When it comes to deployment,
you have flexibility to run in the cloud,
on-prem, or on the edge,
with container support for many Cognitive Services.
Azure Cognitive Services provide
pre-built models that make it easy to embed
intelligence into your apps.
First, you'll need to create a Computer Vision resource
in the Azure portal.
Once you create your resource,
you'll get two important pieces of information
that you'll need to make API calls.
Subscription keys are secret values
that are used by client apps to authenticate.
And the endpoint is the HTTP address
at which your resource can be accessed.
For our object detection application,
we can use pre-built models
accessed through the Computer Vision API.
To call the API, you can use the client library,
which is available in multiple languages.
The client library can be installed
using a simple script,
and you can then get access to all
the computer vision functionalities
without having to handle low-level interactions
with the server yourself.
A successful response will be returned in JSON format.
Here, you can see that common objects
were detected for this image.
The output for each object is a bounding box
to describe where the object is in the image,
and a confidence score
to show confidence level of the object
being correctly identified.
The pre-built Computer Vision models
provide rich information about the image,
including tags, a full sentence description,
detection of any inappropriate content, and more.
For many scenarios, these pre-built models
will be sufficient,
but often you'll want to create a custom model
optimized for a particular domain and use case.
For example, a retail company may want to train a model
to detect specific products they carry.
With Cognitive Services, you can create
a custom model in minutes,
and you can rely on built-in security and privacy
for both your data and trained models.
For our object detection application,
we'll use Custom Vision, another Cognitive Service.
Custom Vision is available as a set of SDKs
as well as through a web-based interface,
which we'll use here.
Either can be used to create, train,
and test a custom model using your own training data.
The first step is to collect images to use
to train the model.
Training the model with more images
should increase the accuracy,
and we recommend starting with at least 30
high quality images per object
and a similar number of images per object.
To make sure your model isn't biased
and can generalize well,
it's important to get a diverse set of images
showing objects of different sizes,
in different contexts, with a variety of backgrounds,
lighting conditions, and camera angles.
The next step is to go to the Custom Vision portal,
create an object detection project,
and upload your images.
To prepare your training set, draw a rectangle
called a bounding box,
around the object in the image,
and tag it with the name of the object.
Repeat until you've tagged all images.
Now you're ready to train, test, and publish your model.
Creating the optimal model is an iterative process.
Once you train your model,
you'll get some performance metrics,
which you can use to help evaluate your model.
Then, you can continue to refine,
by adjusting or adding to the training dataset
and retraining the model.
There are two outcomes you want to avoid
when training an AI model,
an underfit, and an overfit model.
An underfit model is one that performs worse
than a random guess.
An overfit model performs very well, if not perfectly,
when run on your training data,
but it won't perform well with a different set of data.
Both outcomes indicate problems with the training data.
Testing your model on new images
is a good best practice to help you build
an accurate model.
Precision and recall are two different measurements
of the effectiveness of your object detector.
You can also adjust the probability threshold,
which is the level of confidence
that a prediction needs to be considered correct.
A high probability threshold tends to result
in high precision with lower recall,
in other words, you'll get some false negatives.
A low probability threshold will do the opposite
and give you more false positives.
You'll want to set the threshold
according to the needs of your project.
Once you're happy with your model,
there are two ways to add your model to an application.
One option is to publish your model,
get a prediction endpoint,
and then call that endpoint from your application.
This method is often the best choice
when optimizing for performance.
Here, we're gonna use the second method
and export the model,
because we'll be running this model on an edge device.
This is a good option when you need very low latency
for your use case.
If you wanna deploy your model on-prem or on the edge,
many Cognitive Services including Custom Vision,
support containers, so you can deploy anywhere
that Kubernetes is supported.
Simply select the docker option
when you're exporting your model.
As you've seen, it's easy to get started
adding intelligence to your applications,
and Azure Cognitive Services provide many options
for you to develop on your terms,
code-free or in the language of your choice,
using pre-built models or customizing with your own data,
and finally, deploying anywhere
in the cloud, on-prem, or on the edge.
Thanks for taking the time to watch
and we'll see you next time on Azure AI Essentials.
(uplifting music)