>> In this video, we will take a look
at the deep learning support in
ML.NET by building an image classification model.
Deep learning with ML.NET has enabled developers to
use Machine Learning across
a wide variety of domains all the way from sound, vision, text,
NLP which is Natural Language Processing, and a lot more.
So now you can use deep learning to classify or understand sounds,
you can classify music,
you can predict music or music notes,
you can understand vision so you
can classify images or you can detect objects.
If it is going to make online cataloging
or inventory management much more easier,
it can also understand text.
So you can do semantic,
or analysis, or you can do entity recognition,
or you can do sentiment analysis,
or you can do price prediction,
or you can classify documents,
and you can also teach machines to learn as well.
So deep learning has opened up a large set
of scenarios that were not possible before.
Image classification is a very popular example of deep learning.
Simply put, image classification allows
you to classify images into one or more category.
In this example, what we're doing is we are classifying
images into whether the image
is a flower and we're categorizing the type of flower,
whether it's daisy, a rose, or a tulip.
The way to build a model with deep learning is around,
you have your input data which is your training data
which has lots of images which we have labeled in folders,
and we feed all these images
into a training process which is going to train a custom model
for you that you can use to predict
what category of flower does a particular image belong to.
So let's see an example of how can we
build custom model for image classification.
This is a Console app where I'll
build this Machine Learning model or this deep learning model.
What I have over here is a dataset where I
have went ahead and captured a bunch
of flower images and I've categorized them into each flower type.
So here it's a folder of daisy which has
all pictures of a daisy flower.
Here's a picture of dandelion which has all pictures of dandelion.
Here's a picture of folder of
rose which has all the roses pictures.
What we're going to do in this example is we're going to
train the model on this data set.
So it's going to understand all characteristics of what
makes this flower a daisy flower or not and
then we're going to use the trained model on
entirely new data to predict what's going to be the flower type.
As we have learned in the ML.NET journey,
the first step is to create an ML context.
So you can create a context.
The second step is around loading the images.
So here I'm loading all the images that
I just showed you from this flower photos folder.
The next step is around choosing
your algorithm and specifying your label,
column, or the column to predict.
In this case, what I'm doing is
the label key is basically the image path
or the folder names and then the model I'm going
to choose is a resonate model.
So in this case, I'm
doing transfer learning where I'm using one of
these pre-built models from
the ecosystem to build a model for my own scenario.
Once I have defined this pipeline,
I can go ahead and call
pipeline.Fit which is going to train this model and then I
can evaluate the model
by printing out the metrics
of what was the accuracy of the model like.
The last step is around trying the model which
is creating a prediction engine and then
calling the predict function on one of the images that I
have in my image for a prediction folder.
So let's go ahead and run this app and then see how the model was
trained and how does it perform on my test dataset as well.
So let's go ahead and start this application.
So what's happening behind the scenes in the training process
is this program is taking all the images and it's
extracting all the features from
all the images and then it's going to run
a classification algorithm at the end of the process to
classify all these images into one of the many categories.
So what has happened so far is now
the training process is about
to finish and we get some output metrics over
here where the accuracy of the model was around
83 percent with some helpful guide
that the closer to one it is the better it is.
What you're seeing over here is the model was run on some images.
In this case, the model was also run on
this rare flower picture which looks like a rose over here.
Then what the output of the model
or the prediction was a label of rows with
a confidence level or accuracy level of
62 percent that it's a rose.
So what we find over here was
a program to use
deep learning to train an image classification model.
This concludes our series on ML.NET.
I hope you learned a lot about
Machine Learning and are excited to
use Machine Learning in your apps.
Be sure to check out our other series on
C#.NET, ASP.NET, and more.