Machine Learning on Azure

A repository of exercises to support the training.

View the Project on GitHub dvwl/ml-on-azure-course

Module 10: Custom Object Detection Models

Create an Azure Storage Account

In this unit, you'll use the Azure portal to create a storage account for storing and loading image data for use in training an object detection model using Azure Machine Learning studio.

Create an Azure Storage Account

  1. Sign in to the Azure portal using the account that you've prepared for this learning path.

  2. On the resource menu, or from the Home page, select the hamburger button in the upper left then select Storage accounts from the drop-down menu. The Storage accounts pane appears.

  3. On the command bar, select Create. The Create a storage account pane appears.

  4. On the Basics tab, enter the following values for each setting.

  1. Select Next : Advanced. On the Advanced tab, enter the following values for each setting.
  1. Select Next : Networking. On the Networking tab, enter the following values for each setting.
  1. Select Next : Data protection. On the Data protection tab, enter the following values for each setting.
  1. Select Next : Encryption. Accept the defaults.

  2. Select Next : Tags. Here, you can associate key/value pairs with the account for your categorization to determine if a feature is available to selected Azure resources.

  3. Select Review + create to validate your options and to ensure all the required fields are selected. If there are issues, this tab will identify them so you can correct them.

  4. When validation passes successfully, select Create to deploy the storage account.

  5. When deployment is complete, which may take up to two minutes, select Go to resource to view Essential details about your new storage account.

    Storage Overview

Take note of the Storage Account Name as this value will be needed later on when we create a Datastore in Azure Machine Learning Studio.

Create an Azure Storage Container

Now that we have an Azure Storage Account, we'll create a container that will allow us to store unstructured blob data. This format is ideal for storing and serving image data in a distributed fashion. We'll reference this data in upcoming steps when we create a Datastore in Azure Machine Learning studio.

Create an Azure Storage Container

  1. In the Azure portal, navigate to the Azure Storage Account that was created in the previous unit.

  2. In the left menu, scroll to the Data Storage section, then select Containers.

    Containers Section

  3. Select the + Container+ Button, you'll be prompted to provide a name for your container. You'll want to keep track of this name is a secure and accessible document as it will be referenced later in the module. The container name must be lowercase, must start with a letter or number, and can include only letters, numbers, and the dash (-) character.

    Set the level of public access to the container. The default level is Private (no anonymous access).

    Select Create to create the container:

    Create Container

  4. Once the container is created, select Access Keys under the Security + networking section of the left-side panel.

    Access Keys Section

  5. This will bring up the following screen. Select the Show keys icon and copy the key to the clipboard and then record it somewhere safe and accessible. This key will be needed later.

    Show Keys

  6. Select the Containers section on the left-side panel and select the newly created container as highlighted below:

    Container Select

  7. Download and extract the following provided image data. You'll need to decompress the included soda_data_compressed.zip file, then follow the steps in the image below to upload the contents of the soda_data\train_img directory as shown. Once you have selected these files for inclusion, select the now highlighted Upload button to begin the transfer from your machine to the Azure Storage Container.

    Upload Image Data

  8. Once completed, you should see that 245 images have been added to the Azure Storage Container (0.jpg - 244.jpg). Note that at a minimum you'll need at least 10 images to train an AutoML for Images model in Azure Machine Learning studio

    Uploaded Image Data

  9. At this point, you should have noted the Storage Account Name, Blob Container Name, and Access Key. These values will be used in the next section when we create the Azure Machine Learning Workspace.

Create an Azure Machine Learning Workspace

Azure Machine Learning is a cloud service for accelerating and managing the machine learning project lifecycle. Machine learning professionals, data scientists, and engineers can use it in their day-to-day workflows: Train and deploy models and manage Machine Learning Ops.

You can create a model in Azure Machine Learning or use a model built from an open-source platform, such as Pytorch, TensorFlow, or scikit-learn. Machine Learning Ops support can help you monitor, retrain, and redeploy models.

There are many advantages of using the Azure Machine Learning platform to create computer vision models, these include:

An Enterprise grade platform service that facilitates the following capabilities when training and deploying CV models:

Learn more about Machine Learning on Azure.

Create an Azure Machine Learning Workspace

  1. Sign into the Azure portal by using the credentials for your Azure subscription.

  2. In the upper-left corner of the Azure portal, select the three bars, the + Create a resource.

    Create Resource

  3. Use the search bar to find machine learning, then select the Machine Learning result:

    Marketplace Result

  4. In the Machine Learning pane, select the Create button to begin the deployment process:

    Create Workspace

  5. On the Basics tab, enter the following values for each setting:

  1. On the resulting page you'll be able to validate the details of your deployment. When you're satisfied, select the Create button to start the deployment. This process may take a few minutes to complete.

    Create Machine Learning Workspace

  2. Once the deployment has completed, navigate to your new Azure Machine Learning resource. You can easily locate this resource by typing “Azure Machine Learning” in the Azure search bar and choosing the Machine Learning icon. This will list all available Azure Machine Learning resources in your Azure Subscription.

    Find Resource

  3. When you've successfully navigated to the newly deployed instance, notice in the Overview section there will be a button labeled "Download config.json". Select this button to download the configuration and store it somewhere secure and accessible so that it may be used in the next module.

    Download Config

  4. While in the Overview section of the Azure Machine Learning workspace resource, select Launch Studio to open your workspace in the browser and prepare for the next unit.

    Launch Studio

Create an Azure Machine Learning Compute Instance

In this section, we'll create an online compute resource in Azure Machine Learning that will act as a pre-configured development environment. This environment will provide the ability to execute Python code and run live Jupyter notebooks. We'll refence this development environment in other modules.

Create an Azure Machine Learning Compute Instance

  1. If you haven't already launched the Azure Machine Learning studio from the Machine Learning Overview mentioned at the end of the previous section, sign in to Azure Machine Learning studio now, and select your workspace.

  2. On the left-hand pane, locate the "Manage" section and select "Compute".

    Select Compute

  3. On the resulting screen, select + New to create a new compute instance.

    Select New

  4. In the compute name section, provide a unique value. In the Virtual machine type section, select GPU. Choose an appropriate machine from the list of populated options (suggested to choose Standard_NC6). This instance will execute and train our custom object model using a Jupyter notebook in later steps. When you've provided the appropriate values, select Create to begin the deployment of the compute instance.

    Select Create

  5. The deployment should take a couple minutes to complete, but you're welcome to proceed to the next unit if you don't want to wait. You should notice the State of the instance will eventually change from Creating to Running. Once in the Running state, your compute instance is ready to access and use in upcoming sections of the Learning Path.

    Select Create

    Select Create

Create an Azure Machine Learning Datastore

Datastores allow for the ability to securely connect to your storage services in Microsoft Azure without putting your authentication credentials or the integrity of your original data source at risk. They store connection information, like your subscription ID and token authorization in a secure Key Vault that's associated with the Azure Machine Learning workspace. In this way, you can securely access your storage without having to hard code connection information into your scripts. In this section, we'll create a Datastore that will later reference in a Jupyter notebook that will run on our previously deployed compute instance.

Create an Azure Machine Learning Datastore

  1. If you aren't already launched into the Azure Machine Learning studio that was used in the previous section, sign in to Azure Machine Learning studio now, and select your workspace.

  2. Select Datastores on the left pane under Manage

    Select Create

  3. Select + New datastore

    Select New Datastore

  4. Complete the form to create and register a new datastore. The form intelligently updates itself based on your selection for Azure storage type and authentication type. Name the Datastore computervisionimagesraw. For Datastore type, choose Azure Blob Storage and ensure the From Azure subscription option is selected. You'll need to reference the values saved previously and select the appropriate Storage account and Blob container from the respective drop-down. For Authentication type, select Account key and provide the value of the Access Key used by your storage account. The completed form should look like the following:

    New Datastore

    When you've verified the form information is correct, select Create to create the Datastore.

  5. You'll see the newly created Datastore is now populated in the Datastores section of your Azure Machine Learning studio instance.

    Datastore Created