Context aware identification

Experimental
Experimental: parameters and/or its behaviour may change or be removed without notification. Please contact team.nai@naturalis.nl for more information.

The context-aware functionality is enabled when the client passes the location_coordinates, day_of_year and hour POST parameters. All three parameters should be present for the context output to be outputted. The context-aware output is a separate output and does not replace the original, only image-based, output. This makes it possible to make comparisons between non-context and context-predictions. For example, when the top prediction changes in the context output, a client could warn the user that the context of the observation makes the top result unlikely. Alternatively, clients could show the context-aware identification as default when context parameters are passed.

location_coordinates

The location of the observation as a comma-separated str of latitude and longitude coordinates, e.g. “58.06571551164821,7.980022129724626”. If location_coordinates is not available, context-aware predictions are not supported.

day_of_year

The day of the year of the observation as an int, ranging from 0 to 365. If day_of_year is not available, context-aware predictions are not supported.

hour

The hour of the observation as an int, ranging from 0 to 23. If hour is not available, set it to 0.

Example

Get test image
​

Requires curl and jq.

curl -X POST \
 -F "image=@AO_1120028.jpg" \
 -F "location_coordinates=58.06571551164821,7.980022129724626" \
 -F "day_of_year=163" \
 -F "hour=3" \
 "https://multi-source.identify.biodiversityanalysis.eu/v2/observation/identify"
import json

import requests


def example_request():
    url = (
        "https://multi-source.identify."
        "biodiversityanalysis.eu/v2/"
        "observation/identify"
    )
    image = "AO_1120028.jpg"
    data = {
        "location_coordinates": "58.06571551164821,7.980022129724626",
        "day_of_year": 163,
        "hour": 3
    }

    with open(image, "rb") as image:
        response = requests.post(
            url=url,
            files={"image": image},
            data=data,
        )
    return response.json()


if __name__ == "__main__":
    json_response = example_request()
    print(json.dumps(json_response, indent=2))

Requires the Python requests library. Available with pip install requests.

The result of the context-aware model is returned as a separate list of sorted taxa in the prediction structure under the field taxa_context.

In this example, the context output changes the top prediction from Acleris literana to Diurnea fagella with near-certain probability, so a client could show the context-aware result as the more likely identification.

{
  ...,
  "predictions": [
    {
      "region_group_id": "individual0",
      "taxa": {
        "items": [
          {
            "probability": 0.515671,
            "scientific_name": "Acleris literana",
            "scientific_name_id": "GBIF:1739931"
          },
          {
            "probability": 0.354096,
            "scientific_name": "Diurnea fagella",
            "scientific_name_id": "GBIF:1841296"
          },
          {
            "probability": 0.128037,
            "scientific_name": "Microlepidoptera indet.",
            "scientific_name_id": "NIA:89408d1bebec59d1bb1fde742d2903b3cdafff2f9f16774ecba420e6"
          },
          ...
        ],
        "type": "multiclass"
      },
      "taxa_context": {
        "items": [
          {
            "probability": 0.999994,
            "scientific_name": "Diurnea fagella",
            "scientific_name_id": "GBIF:1841296"
          },
          {
            "probability": 6e-06,
            "scientific_name": "Microlepidoptera indet.",
            "scientific_name_id": "NIA:89408d1bebec59d1bb1fde742d2903b3cdafff2f9f16774ecba420e6"
          },
          ...
        ],
        "type": "multiclass"
      }
    }
  ],
  ...
}