ML.NET and the magic of Model Builder using the ASL alphabet
Tags: machinelearning, dotnet, modelbuilder, mldotnet
Published: 2021-12-23 16:18:12


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ty7s42p2z88w7g06v7kl.jpg)

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 ](https://docs.microsoft.com/en-us/dotnet/machine-learning/how-to-guides/install-model-builder?tabs=visual-studio-2022)on how to install ML.NET Model Builder and also the [link ](https://marketplace.visualstudio.com/items?itemName=MLNET.ModelBuilder2022&ssr=false#overview)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 ](https://docs.microsoft.com/es-es/dotnet/machine-learning/automate-training-with-model-builder)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 ](https://www.kaggle.com/grassknoted/asl-alphabet)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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/40rqx9jubebtt32ws5ew.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7ilhw7n3cfyrj475rkio.png)
Once you’re presented with the scenario screen, select Image **Classification **and proceed to the next step.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1l8ib4806vn62wcohjdq.png)

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 ](https://docs.microsoft.com/en-us/dotnet/machine-learning/how-to-guides/install-gpu-model-builder)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 ](https://docs.microsoft.com/en-us/dotnet/machine-learning/resources/azure-training-concepts-model-builder#what-is-an-azure-machine-learning-experiment)to create processes in Azure Machine Learning.

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0qgw212vgrsq691nkgv6.png)
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/do3t3xb6cudrdeqy85xl.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/26i597mvbm5vcufydosl.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3u1pdzpao7areqs9sq3r.png)

**Result prediction letter I**


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q7mstuzqsh95fkbpd0oe.png)

**Result prediction letter O**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0u0fn63ifltirw90e6cw.png)

**Result prediction letter V**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yvrykn0bkmon5hhl0bck.png)

**Result prediction letter A**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fp2cfu7vudr1cj12bjat.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m92unzqgxepk52m2eybz.png)

**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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sneme5mn29csghjhceka.png)

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

## Additional Resources

- [ML.NET Model Builder | Machine learning in Visual Studio (microsoft.com)](https://dotnet.microsoft.com/en-us/apps/machinelearning-ai/ml-dotnet/model-builder)

- [What is Model Builder and how does it work? — ML.NET | Microsoft Docs](https://docs.microsoft.com/en-us/dotnet/machine-learning/automate-training-with-model-builder#how-do-i-understand-my-model-performance)

- [dotnet/machinelearning-modelbuilder: Simple UI tool to build custom machine learning models. (github.com)](https://github.com/dotnet/machinelearning-modelbuilder)

- [ML.NET YouTube Playlist](https://www.youtube.com/watch?v=pxUzw6JyqcM&list=PL1rZQsJPBU2TwElfOzqOsUW1yuxKNA091)