Giter VIP home page Giter VIP logo

detection-amlworkbench's Introduction

Bird Detection with Azure ML Workbench

Object detection using Faster R-CNN APIs in CNTK and Tensorflow. For more detailed walkthrough see also code story Bird Detection with Azure ML Workbench.

Train

If you are using az ml, to push models to Azure Blob Storage, add the following to your .runconfig file:

EnvironmentVariables:
  "STORAGE_ACCOUNT_NAME": "<YOUR_AZURE_STORAGE_ACCOUNT_NAME>"
  "STORAGE_ACCOUNT_KEY": "<YOUR_AZURE_STORAGE_ACCOUNT_KEY>"

For more info on Azure ML Workbench compute targets seedocumentation.

CNTK

To train on different pre-trained models, use this command below: This submits multiple jobs on each registered pre-trained model in a row

  python Detection/FasterRCNN/run_sweep_parameters.py <your_compute_target>

You can also switch the base model by giving an input argument like

az ml experiment submit -c <your_compute_target> Detection/FasterRCNN/run_faster_rcnn.py AlexNet
az ml experiment submit -c <your_compute_target> Detection/FasterRCNN/run_faster_rcnn.py VGG16

Tensorflow

Here is how to submit training experiment using Tensorflow Object Detection APIs:

az ml experiment submit -c <your_compute_target> tf_train_eval.py --logtostderr --train_dir=/azureml-share/traindir_no_aug  \
--input_type image_tensor --pipeline_config_path=./kw_data/faster_rcnn_resnet101_no_aug.config   \
--eval_every_n_steps=500 --eval_dir=/azureml-share/eval_no_aug

Use different config files in ./kw_data to train with different parameters. Change _eval_every_n_steps_if you'd like to run evaluation more oftem

Note: you will need to update conda_dependancies.yaml to point to the location of TF object detection dist packages.

Predict

CNTK

Run a prediction web service:

$ cd CNTK_faster-rcnn/Detection/
$ docker build -t cmcntk .
$ docker run -v /:/cmcntk -p 80:80 -it cmcntk:latest
# note this will persist the model files in /

Now you should have a service running on http://localhost

To get prediction of an image:

  1. In the same storage account, upload your test image into a container named data
  2. Make a POST request against the running prediction web service by providing the path of the file in the Azure blob storage container, e.g. birds/testimages/IMG_0010.JPG
$ curl -X POST http://<localhost or a public ip>/predict -H 'content-type: application/json' -d '{"filename": "birds/testimages/IMG_0010.JPG"}'

TensorFlow

Register provider:

az provider register -n Microsoft.MachineLearningCompute

Create environment:

VM:

az ml env setup -l [Azure Region, e.g. eastus2] -n [your environment name] [-g [existing resource group]]

Azure Container Service (ACS) Kubernetes cluster:

az ml env setup --cluster -n [your environment name] -l [Azure region e.g. eastus2] [-g [resource group]]

Set environment:

az ml env set -n [environment name] -g [resource group]

Create model management:

az ml account modelmanagement create -l [Azure region, e.g. eastus2] -n [your account name] -g [resource group name] --sku-instances [number of instances, e.g. 1] --sku-name [Pricing tier for example S1]

Create the web service:

az ml service create realtime --model-file [model file/folder path] -f [scoring file e.g. score.py] -n [your service name] -s [schema file e.g. service_schema.json] -r [runtime for the Docker container e.g. spark-py or python] -c [conda dependencies file for additional python packages] -d [additional files]

To test the service:

curl -X POST -H "Content-Type:application/json" --data {"input": "[IMAGE URL]"} http://<localhost or a public ip>/score

Data Credit

The data used in experiments was collected by Dr. Rachael Orben of Oregon State University and Abram Fleishman of San Jose State University and Conservation Metrics, Inc. It was collected as part of a large project investigating early breeding season responses of red-legged kittiwakes to changes in prey availability and linkages to the non-breeding stage in the Bering Sea, Alaska.

Data for CMTK training is here.
Data in TF Records format for training in Tensorflow is here

detection-amlworkbench's People

Contributors

evanlouie avatar olgaliak avatar ritazh avatar sozercan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

detection-amlworkbench's Issues

Faster RCNN Model Is Retrained Everytime Docker instance is Run

Everytime the FasterRCNN server starts the whole model is being retrained, this is really inefficient CNTK's load model function should be used instead to load a pre-trained model if my model has already been trained.

Should add the following function to enable this

def load_object_detector(cfg):
    """
    Loads an object detector from cfg
    """
    detector_name = _get_detector_name(cfg)
    eval_model = None
    print("training {}".format(detector_name))
    if detector_name == 'FastRCNN':
        from FastRCNN.FastRCNN_train import prepare, train_fast_rcnn
        prepare(cfg, use_arg_parser=False)
        eval_model = load_model(cfg['MODEL_PATH'])
    elif detector_name == 'FasterRCNN':
        from FasterRCNN.FasterRCNN_train import prepare, train_faster_rcnn
        prepare(cfg, use_arg_parser=False)
        eval_model = load_model(cfg['MODEL_PATH'])
    else:
        print('Unknown detector: {}'.format(detector_name))

    return eval_model

Dataset link

Can you please provide a new link to the dataset?
The current one is not working.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.