Chain API

Since release v0.9.3.1, DeepDetect supports chaining multiple models and actions. This allows for instance to detect objects then run other models on object crops. A typical application is detecting faces, then estimating every face’s age.

Let’s define the key elements:

  • /chain is the REST resource defined by DeepDetect to execute a tree-like succession of models and actions
  • a model is represented by a service, as in regular API /predict calls
  • an actions is a stateless piece of code that takes a model’s output, transforms it as needed, and pass it on to the next set of models. As an example, the crop action crops objects after a model has detected them. Available actions are listed at the bottom of this page.

For more information on writing chains, please read the JSON chain description.

Chain API Results

You can use the Platform UI to test your chains and preview their results.

Chain Services status

Chain are using services already running in DeepDetect server, these services status will be display on the platform UI:

Chain API Services ready

If some services are not available on the running DeepDetect server, their status will be updated accordingly:

Chain API Services not ready

Chain location configuration

Chain location is described on your platform config.json file. By default this value is /chains/, which must be served by a reverser proxy on the same domain as the running DeepDetect server.

If you need to modify this value, you can edit config/platform_ui/config.json file:


{
  ...
  "deepdetect": {
    ...
    "chains": {
      "path": "/chains/"
    }
  }
}

This path is served by nginx, the location of this path on default platform install is $DD_PLATFORM/chains/.

Chain json file

Each chain is stored in a json file stored in $DD_PLATFORM/chains/, the platform is listing the json files existing at this location.

Here is an example for faces-crop-age_real.json:


{
  "name": "faces-crop-age_real",
  "calls": [
    {
      "parameters": {
        "input": {
          "connector": "image",
          "keep_orig": true
        },
        "mllib": {
          "gpu": true
        },
        "output": {
          "bbox": true,
          "confidence_threshold": 0.3
        }
      },
      "service": "faces"
    },
    {
      "id":"crop",
      "action": {
        "type": "crop"
      }
    },
    {
      "parent_id": "crop",
      "parameters": {
        "input": {
          "connector": "image",
          "keep_orig": true
        },
        "output": {
          "confidence_threshold": 0.01,
          "best": 1
        }
      },
      "service": "age_real"
    }
  ]
}

Related