deploy-MLmodels-on-iotedge/object-detection-azureml
YanZhangADS 86675c56d9
Yzhangdev (#1)
* add image classification sample

* add file

* enhance doc

* fix file extension

* show docker ps output

* remove module_name

* remove tag view

* enhance doc

* fix ws workspace

* fix get_docker_client()

* fix code

* adjust wait time to 30s

* modify image-classification-azureml
2019-10-11 11:09:07 -04:00
..
01_AzureSetup.ipynb Yzhangdev (#1) 2019-10-11 11:09:07 -04:00
02_IoTEdgeConfig.ipynb Yzhangdev (#1) 2019-10-11 11:09:07 -04:00
04_DeployOnIOTedge.ipynb Yzhangdev (#1) 2019-10-11 11:09:07 -04:00
05_TestMLModule.ipynb Yzhangdev (#1) 2019-10-11 11:09:07 -04:00
06_TearDown.ipynb first commit 2019-09-27 13:44:25 +00:00
031_DevAndRegisterModel.ipynb Yzhangdev (#1) 2019-10-11 11:09:07 -04:00
032_DevelopModelDriver.ipynb Yzhangdev (#1) 2019-10-11 11:09:07 -04:00
033_BuildImageForMLModule.ipynb Yzhangdev (#1) 2019-10-11 11:09:07 -04:00
Makefile Yzhangdev (#1) 2019-10-11 11:09:07 -04:00
README.md Yzhangdev (#1) 2019-10-11 11:09:07 -04:00
deployment_MLmodule_template.json Yzhangdev (#1) 2019-10-11 11:09:07 -04:00
dev_env_template Yzhangdev (#1) 2019-10-11 11:09:07 -04:00
dockerps_container_run.png Yzhangdev (#1) 2019-10-11 11:09:07 -04:00
environment.yml first commit 2019-09-27 13:44:25 +00:00
test_image.jpg first commit 2019-09-27 13:44:25 +00:00
testing_utilities.py first commit 2019-09-27 13:44:25 +00:00

README.md

Object Detection on Azure IoT Edge with AzureML

In this tutorial, we introduce how to deploy a people detection service on Azure IoT Edge using Azure Machine Learning (AzureML) service. Specifically, the physical IoT Edge device is a Ubuntu VM, which is the same host server this repository is downloaded to.

We deploy a pre-trained MaskRCNN (Pytorch) object detection model to the edge device. When the image data is generated from a process pipeline and fed into the edge device, the deployed model can make predictions right on the edge device without accessing to the cloud.

Azure IoT Edge enables user to deploy and manage business logic on the edge in the form of modules. Any business logic, including trained machine learning model, need to be built into a docker image. When deployed, each running docker container is called a module. In this workflow, we deploy one module - the people-detector-service module on IoT Edge. The model file and other required driver files will be generated when running 031_DevAndRegisterModel.ipynb and 032_DevelopModelDriver.ipynb notebooks.

We perform following steps for the deployment.

  • Step 1: Create Azure resources including IoT Hub, IoT Edge identity, AzureML workspace, etc.
  • Step 2: Provision and Configure IoT Edge Device.
  • Step 3: Develop an ML model, register it in Azure Container Service (ACR) and build it into a docker image through AzureML. This docker image will be used to create a docker container (module) running on the edge device.
  • Step 4: Deploy the ML module on IoT Edge Device.
  • Step 5: Test the deployed ML Module.
  • Step 6: Tear down Azure resources and clean up the edge device.

To get started with the tutorial, please proceed with following steps in sequential order.

Prerequisites

  1. Linux (x64) with GPU enabled.
  2. Anaconda Python
  3. Docker installed.
  4. Azure account.

The tutorial was developed on an Azure Ubuntu DSVM, which addresses the first three prerequisites.

Steps

Please follow these steps to set up your environment and run notebooks. They setup the notebooks to use Docker and Azure seamlessly.

  1. Add your user to the docker group:

    sudo usermod -aG docker $USER
    newgrp docker
    

    To verify whether you have correct configuration, try executing docker ps command. You should not get permission denied errors.

  2. Navigate to the repo's directory

  3. Create the Python virtual environment using the environment.yml:

    conda env create -f environment.yml
    
  4. Activate the virtual environment:

    source activate deployment_env
    
  5. Register the created conda environment to appear as a kernel in the Jupyter notebooks.

    python -m ipykernel install --user --name deployment_env --display-name "Python (deployment_env)"
    
  6. Login to Azure:

    az login --use-device-code
    
  7. If you have more than one Azure subscription, select it:

    az account set --subscription <Your Azure Subscription>
    
  8. Start the Jupyter notebook server in the virtual environment:

    jupyter notebook
    
  9. Select correct kernel: set the kernel to be Python [conda env: deployment_env](or Python 3 if that option does not show).

  10. After following the setup instructions above, run the Jupyter notebooks in order starting with the first notebook 01_AzureSetup.ipynb.

Cleaning up

To remove the conda environment created see here. The last Jupyter notebook also gives details on deleting Azure resources associated with this repository.

Reference

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repositories using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.