Skip to content

Object Detection API

Vladislav edited this page Oct 27, 2017 · 3 revisions

Description

DNN API for object detection was released on June 15, 2017 in tensorflow/models repository, and soon was added to ck-tensorflow. It allows to train and validate your models easily and configure them in quite flexible way. More opportunities and details you may get in according README

Dependencies

Tensorflow Object Detection API depends on the following libraries:

  • Protobuf 2.6
  • Pillow 1.0
  • lxml
  • Matplotlib All these dependencies could be installed with pip.

If you have some troubles with these libraries, visit this page for more detailed information (Dependencies block only).

Also you need specific CuDNN library. On 11 october, 2017 it is 5.1 version (with 8.0 Cuda Toolkit)

Installation via ck

The list of preconfigured models in ck is the following (names of according ck packages):

  • tensorflowapimodel-ssd-inception-v2-pets
  • tensorflowapimodel-faster-rcnn-resnet101-coco
  • tensorflowapimodel-faster-rcnn-resnet101-voc
  • tensorflowapimodel-faster-rcnn-resnet101-pets
  • tensorflowapimodel-ssd-mobilenet-v1-pets
  • tensorflowapimodel-ssd-mobilenet-v1-coco

The most actual list you may get manually with running:

ck list package:tensorflowapimodel*

Any model could be installed with:

ck install ck-tensorflow:package:{model_package_name}

Running models

To work with them simply run tensorflow-api program and choose preferred model. It could be run before installation and all dependencies install automatically (also you can choose one model to install from the list above).

ck run ck-tensorflow:program:tensorflow-api

There is another way to work with your model - module:model.tensorflowapi. Its usage will be shown in the next block. Firstly you should get your model uid (read next block). Then you can train, retrain and validate your model with:

ck train model.tensorflowapi --model_uid={model_uid}
ck train model.tensorflowapi --model_uid={model_uid} --retrain
ck eval model.tensorflowapi --model_uid={model_uid}

Configuring models

All models have their own configuration file. You may find your model in CK-TOOLS folder; configuration file is stored in model/ subfolder.

Information about its location and name is also stored in env.sh file of the model. To get it run the following:

ck show env

With this command receive a list of all installed packages on your machine, find necessary model ENV uid (first column). Then find env.sh file. ck find repo:local gives you folder where all env files are stored. Proceed there and then run cat env/{env_uid}/env.sh. $CK_ENV_MODEL_TENSORFLOW_API_MODE + CK_ENV_MODEL_TENSORFLOW_API_PIPELINE_NAME$ gives you full path to configuration file of your model.

About structure and usage of config file you may read in official guides

Create custom model

With existing ck packages you may create your own one with one of three datasets:

If you want to work with your favorite dataset, but the list above does not contain it, email to Vladislav Zaborovskiy(vladzab@yandex.ru or mailto button)

Add your own model with the following command:

ck add ck-tensorflow:package:tensorflowapimodel-{your_model_name}

Meta file must have correct install_env keys. Follow examples: 1 2 3

It contains 3 necessary variables:

  • $PIPELINE_NAME - name of your config file(stored at ck-tensorflow/script/tensorflowapi-install-model/configs)
  • $MODEL_NAME - displayed at env and in logs
  • $DATASET_NAME - one of three: 'voc','pets','coco'. Also dataset should be mentioned in deps.

Installation script is located at ck-tensorflow/script/tensorflowapi-install-model/ so you need to add to your meta-file the following:

"use_scripts_from_another_entry": {
  "module_uoa":"script",
  "data_uoa": "c412930408fb8271"
}

In your configure file you should replace some strings to allow ck install it automatically: input_path and label_map_path. Please, look for examples in ck-tensorflow/script/tensorflowapi-install-model/configs. Then put your configuration file in the folder above and rename it to $PIPELINE_NAME.template.

Clone this wiki locally