Get Inferences from Cisco Meraki Camera

Once a model has been trained and deployed, images can be sent to the Plainsight Image API endpoint to get inferences.
For information on how to create a model using a Cisco Meraki Camera see: Get Snapshot from Cisco Meraki Camera
To send new images to a model, see Predictions API.
Below is a Python Example of how to get inferences from snapshots from a Cisco Meraki Camera.
To get images from the camera to send to the model API endpoint, see Get Snapshot from Cisco Meraki Camera
Once images have been acquired, they are ready to be sent to the model to get inferences.

Get Inferences

Before sending images to the Predictions API, a Plainsight API Key, and the Plainsight Image API Endpoint URL are needed.
Note: All examples below are in Python.
Required imports include:
import io
import json
import requests
import base64
  1. 1.
    Create a header that contains the API key.
    • Example:
      • headers = {
        "Authorization" : "Bearer [API KEY]",
        "Content-Type": "application/json"
  2. 2.
    Encode image as base64.
    • Example:
      • with open("/[PATH TO FILE]/[IMAGE NAME]", "rb") as f:
        im_bytes =
        im_b64 = base64.b64encode(im_bytes).decode("utf8")
  3. 3.
    Set data to send to endpoint.
    • Example:
      • data = json.dumps({"image": im_b64})
  4. 4.
    Send a POST API request.
    • Example:
      • requests.request('POST', [IMAGE API URL], headers=headers, data=data)
  5. 5.
    Parse the response to JSON format.
    • Example:
      • payload = response.json()
  6. 6.
    Display response.
    • Example:
      • print(payload)