I’m getting ready for my last event of the year, and I just realize that in the latest update of Model Builder, we have the chance to build our own Image Classifier scenario. Let’s start with the official Model Builder definition (see references):
ML.NET Model Builder provides an easy to understand visual interface to build, train, and deploy custom machine learning models. Prior machine learning expertise is not required. Model Builder supports AutoML, which automatically explores different machine learning algorithms and settings to help you find the one that best suits your scenario.
Working with images was supported for a while in Machine Learning.Net. In the Machine Learning .Net Samples, we have sample scenarios like
Image Classification Model Training – Preferred API (Based on native TensorFlow transfer learning)
In this sample app you create your own custom image classifier model by natively training a TensorFlow model from ML.NET API with your own images.
We even have an amazing tutorial, to create our own image classification model from zero
Tutorial: Generate an ML.NET image classification model from a pre-trained TensorFlow model
Learn how to transfer the knowledge from an existing TensorFlow model into a new ML.NET image classification model. The TensorFlow model was trained to classify images into a thousand categories. The ML.NET model makes use of part of the TensorFlow model in its pipeline to train a model to classify images into 3 categories.
Training an Image Classification model from scratch requires setting millions of parameters, a ton of labeled training data and a vast amount of compute resources (hundreds of GPU hours). While not as effective as training a custom model from scratch, transfer learning allows you to shortcut this process by working with thousands of images vs. millions of labeled images and build a customized model fairly quickly (within an hour on a machine without a GPU). This tutorial scales that process down even further, using only a dozen training images.
And now, I found that Model Builder, also supports an Image Classification Scenario.
It follows the Model Builder standard workflow, starting with the selection of the scenario:
And then selecting a folder with the Images.
Important: Model Builder expects image data to be JPG or PNG files organized in folders that correspond to the categories of the classification.
To load images into Model Builder, provide the path to a single top-level directory:
- This top-level directory contains one subfolder for each of the categories to predict.
- Each subfolder contains the image files belonging to its category.
Once the folder is selected, we can see a preview of the images and labels loaded from the folder.
For more information about how to organize images for this scenario, refer to Load training data into Model Builder.
And now we start the training process. This may take a while, depending on your hardware. I’m using the sample set of drawings that we used on the InsiderDev Tour, for Custom Vision. These are 24 drawings images, with 3 labels, and in a PC with a I7, 32GB of Ram and an SSD, the training process took a little longer than 2 minutes.
Once the training is complete, we have a decent accuracy in our model, so it’s time to test. Before Model Builder last step, we have the chance to test the model with some test images.
Using one of the images that I created at Ignite in Orlando, the trained model get’s a human with a 99% of accuracy.
And, the final step is to add the generated model and code to our project. I’ll write about how to use this generated code on the near future.
Greetings @ Burlington
- ML.Net Model Builder https://dotnet.microsoft.com/apps/machinelearning-ai/ml-dotnet/model-builder
- ML.Net Samples https://github.com/dotnet/machinelearning-samples/blob/master/README.md
- Tutorial: Generate an ML.NET image classification model from a pre-trained TensorFlow model https://docs.microsoft.com/en-us/dotnet/machine-learning/tutorials/image-classification
- ML.Net Load training data into Model Builder https://docs.microsoft.com/en-us/dotnet/machine-learning/how-to-guides/load-data-model-builder