DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Cover image for ML.NET and the magic of Model Builder using the ASL alphabet
Pablito Piova
Pablito Piova

Posted on

ML.NET and the magic of Model Builder using the ASL alphabet

Image description

ML.NET Model Builder is an intuitive graphical Visual Studio extension to build, train, and deploy custom machine learning models.

First I share a link on how to install ML.NET Model Builder and also the link of the extension for Visual Studio 2022.

Model Builder uses automated machine learning (AutoML) to explore different machine learning algorithms and settings to help you find the one that best suits your scenario.

You don’t need machine learning expertise to use Model Builder. All you need is some data, and a problem to solve. Model Builder generates the code to add the model to your .NET application.

I share the link of the complete documentation provided by the ML.NET team.

I hope you can review the links and now get to work with Model Builder.

In our beginning, we need to classify images recognizing the Alphabet Sing Language, so I looked for a dataset with images to train the model, and guess what, I found it in Kaggle, haha. I share the link so that you can download this image dataset.

Now we continue going to our Visual Studio and creating a console application in Net 6.

Image description

In Solution Explorer, right-click your newly created console application project and select Add > Machine Learning to launch Model Builder.

Image description
Once you’re presented with the scenario screen, select Image **Classification **and proceed to the next step.

Image description

You continue with the Environment tab. For image classification scenarios, you can choose 3 options:

  • Local (CPU): Use our local machine to train the model.

  • Local (GPU): Use our local machine with GPU to train the model. I share a link of How to install GPU support in Model Builder.

  • Azure: We can use Azure cloud resources to train our models with Model Builder. I share a link to create processes in Azure Machine Learning.

In this example we use Local CPU to train the model.

Image description
In the Add data screen, load your data by selecting the button next to the Select a folder text box and use the file explorer to find the unzipped directory containing the subdirectories with images.

Image description

After completing the load images, we are ready to start training the model. For this sample of 87,000 images, the training took approximately 3 hours.
Below you can see in the image how Model Builder used the algorithm to train these models. It is a deep neural network based on the ResNet50 (DNN + ResNet50) architecture for image classification.

Image description

On the evaluation screen, you can get an overview of the results of the training process, such as the time it took for the model to train and the accuracy. Additionally, you can use the β€œTry your model” experience to see if the model is working as expected. In my case I used images taken by my webcam testing the letters of my nickname β€œ P I O V A ”.
The model classifies the image and shows me the probabilities of the prediction.

Result prediction letter P

Image description

Result prediction letter I

Image description

Result prediction letter O

Image description

Result prediction letter V

Image description

Result prediction letter A
Image description

Image description

In this case the prediction is not correct. In both images the probability is not as expected.

We should keep training and testing the model until we are satisfied with the results.

If you are satisfied with your model, select the Consume screen to add the code and make predictions.
In the Consume screen, select the Add Projects button to add the auto-generated projects to your solution.

Image description

Thank you very much for reading, I hope this demo is useful for you.

Additional Resources

Top comments (0)

50 CLI Tools You Can't Live Without

The top 50 must-have CLI tools, including some scripts to help you automate the installation and updating of these tools on various systems/distros.