Skip to content

nithiroj/azure-undp-weed-detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Azure UNDP Weed Detection

Datasets

Data being used in this project is V2: Nonsegmented single plants (1.7GB) from PAPER: A Public Image Database for Benchmark of Plant Seedling Classification Algorithms.

It contains about 960 unique plants of 12 classes:

└── NonsegmentedV2
    ├── Black-grass
    ├── Charlock
    ├── Cleavers
    ├── Common Chickweed
    ├── Common wheat
    ├── Fat Hen
    ├── Loose Silky-bent
    ├── Maize
    ├── Scentless Mayweed
    ├── Shepherd’s Purse
    ├── Small-flowered Cranesbill
    └── Sugar beet

More information can be found from Plant Seedlings Dataset.

Training Weed Detection Model

The details can be found in notebooks/UNDP.ipynb and can be run with Colab.

Open In Colab

Azure Architectures

Azure Functions

Azure Notification Hubs

Requirements:

Azure Notification Hub Setup

  1. Configure Azure Notification Hub and connect app to the notification hub. (See Tutorial: Send push notifications to Android devices using Firebase SDK version 0.6).
  2. Replace <ConnectionString> and <HubName> in undp/classify/__init__.py with DefaultFullSharedAccessSignature and name of the hub you have configured.

Docker Setup

cr. fastai

  1. Open your terminal and change directory to undp
  2. Build Docker image

    docker build --tag <DOCKER_HUB_ID>/<DOCKER_IMAGE_NAME>: .

  3. Test Docker image

    docker run -p 8080:80 -it <DOCKER_HUB_ID>/<DOCKER_IMAGE_NAME>:

  4. Open browser:

    localhost:8080/api/classify?name=https://raw.githubusercontent.com/nithiroj/azure-undp-weed-detection/master/assets/maize-251.png

  5. Push the image to Docker Hub

    docker login

    docker push <DOCKER_HUB_ID>/<DOCKER_IMAGE_NAME>:

Azure Functions Setup

cr. fastai

  1. Login to Microsoft Azure with Azure CLI

    az login

  2. Run following command to see list of available location for <LOCATION_ID>, e.g. centralus.
  3. Create resource group

    az group create \
    --name <RESOURCE_GROUP> \
    --location <LOCATION_ID>

  4. Create storage account

    az storage account create \
    --name <STORAGE_ACCOUNT> \
    --location <LOCATION_ID> \
    --resource-group <RESOURCE_GROUP> \
    --sku Standard_LRS

  5. Create a Linux App Service Plan

    az appservice plan create \
    --name <APP_PLAN_NAME> \
    --resource-group <RESOURCE_GROUP> \
    --sku B1 \
    --is-linux

  6. Create the App & Deploy the Docker image from Docker Hub

    az functionapp create \
    --resource-group <RESOURCE_GROUP> \
    --name <FUNCTION_APP> \
    --storage-account <STORAGE_ACCOUNT> \
    --plan <APP_PLAN_NAME> \
    --deployment-container-image-name <DOCKER_HUB_ID>/<DOCKER_IMAGE_NAME>:

  7. Configure the function app

    storageConnectionString=$(az storage account show-connection-string \
    --resource-group <RESOURCE_GROUP> \
    --name <STORAGE_ACCOUNT> \
    --query connectionString --output tsv) az functionapp config appsettings set --name <FUNCTION_APP> \
    --resource-group <RESOURCE_GROUP> \
    --settings AzureWebJobsDashboard=$storageConnectionString \
    AzureWebJobsStorage=$storageConnectionString

  8. Run your Azure Function

    https://<FUNCTION_APP>.azurewebsites.net/api/classify?name=<IMAGE_URL>

Delete Resource Group

When you are done, delete the resource group

az group delete \
--name <RESOURCE_GROUP> \
--yes

Demo

The demo can be tested by replacing <IMAGE_URL> with your image url.

https://undpinferenceapp.azurewebsites.net/api/classify?name=<IMAGE_URL>

For example:

https://undpinferenceapp.azurewebsites.net/api/classify?name=https://raw.githubusercontent.com/nithiroj/azure-undp-weed-detection/master/assets/maize-251.png

Note:

  • More samples of images are avilable in assets/
  • The demo will be available until the end of June 2020.