google-visiongoogle-cloud-automl

Automl image prediction problems


I get different results when using a model to get image annotation predictions from web UI and from API. Specifically, using the web UI I actually get predictions, but using the API I get nothing - just empty output.

It's this one that gives nothing using the API: https://cloud.google.com/vision/automl/docs/predict#automl-nl-example-cli

Specifically, the return value is {} - an empty JS object. So, the call goes through just fine, there's just no output.

Any hints as to how to debug the issue?


Solution

  • By default only results with prediction score > 0.5 are returned by the API.

    To get all predictions you will need to provide extra argument 'score_threshold' to predict request:

    For the REST API:

    {
      "payload": {
        "image": {
          "imageBytes": "YOUR_IMAGE_BYTES"
        },
        "params": { "score_threshold": "0.0" },
      }
    }
    

    For the python call:

    payload = {'image': {'image_bytes': content }, "params": { "score_threshold": "0.0" }}
    

    With this argument all predictions will be returned. The predictions will be ordered by the 'score'.

    Hope that helps,