Applications - Edges
  • 25 Oct 2024
  • 14 Minutes to read
  • Dark
    Light

Applications - Edges

  • Dark
    Light

Article summary

There are a variety of application edges which return a paginated list of application-specific objects.

Application Performance

Three application endpoints return performance statistics such as precision, recall, and F1 score for all previously released models calculated against different data sets.

All performance endpoints accept the same query arguments and return data in the same format.

Argument

Example

Definition

start
unix timestamp

1494885870

(optional) Earliest model release timestamp which to return performance results.
Defaults to 0.

end
unix timestamp

1494886421

(optional) Latest model release timestamp which to return performance results.
Defaults to current time.

limit
integer

10

(optional) Maximum number of records to return.
Defaults to returning all available records.

reverse
boolean

TRUE

(optional)
True - return records in descending time order.

False - return records in ascending time order.
Defaults to False.

  • Example Response

{
  "data": [
    {
      "app_id": "app123",
      "data_count": 849,
      "loss": null,
      "model_performance": {
        "F1": 0.87,
        "FN": 104,
        "FP": 104,
        "TN": 838,
        "TP": 745,
        "accuracy": 0.88,
        "precision": 0.87,
        "recall": 0.87
      },
      "model_performance_per_subject": {
        "bicycle": {
          "F1": 0.98,
          "FN": 1,
          "FP": 7,
          "TN": 604,
          "TP": 237,
          "accuracy": 0.99,
          "precision": 0.97,
          "recall": 0.99
        },
        "bus": {
          "F1": 0.98,
          "FN": 15,
          "FP": 4,
          "TN": 684,
          "TP": 146,
          "accuracy": 0.99,
          "precision": 0.97,
          "recall": 0.99
        },
        "emergency_services": {
          "F1": 0.83,
          "FN": 9,

Release Validation Performance

Release Validation performance reports model performance scores tested against the validation data set at the time each model was released.

  • Endpoint

GET /1/applications/{application_id}/performance/releaseValidation
Host: https://api.cogniac.io

Current Validation Performance

Current Validation performance reports model performance scores tested against the current validation data set.

  • Endpoint

GET /1/applications/{application_id}/performance/currentValidation
Host: https://api.cogniac.io

New Random Performance

New Random performance reports model performance against a set of data that each model has not encountered in either a test or validation set at the time of mode release.

  • Endpoint

GET /1/applications/{application_id}/performance/newRandom
Host: https://api.cogniac.io

Application Detections

The Application Detections endpoint returns the latest assertions on media from either a user or the application's current best model.

The following query parameters are supported:

Argument

Example

Description

start

1234567890.0

(optional) Unix timestamp. Return media updated after this timestamp.
Defaults to 0.

end

1234567890.0

(optional) Unix timestamp. Return media updated prior to this timestamp.
Defaults to current time.

probability_upper

0.75

(optional) Subject-media association probability ceiling.
Defaults to 1.0.

probability_lower

0.25

(optional) Subject-media association probability floor.
Defaults to 0.0.

limit

10

(optional) Number of results to return per page.
Defaults to 10.

reverse

True

(optional) True = return results in descending order based on assertion timestamp. False = return results in ascending order.
Defaults to False.

consensus_none

'True'

(optional) When set to True, will return only media assertions that have not reached consensus.
Defaults to False.

only_user

True

(optional) When set to True, will return only media assertions made by users.
Defaults to False.

only_model

False

(optional) When set to True, will return only media assertions made by the latest best model.
Defaults to False.

Only one of only_user and only_model can be True.

  • Endpoint

GET /1/applications/{application_id}/detections
Host: https://api.cogniac.io

This endpoint will return a list of the most recent assertions on media items that were processed by the application:

  • Example Response

{
  "data": [
    {
      "detections": [
        {
          "app_data": null,
          "app_data_type": null,
          "app_id": "0Am1V3kr",
          "created_at": 1497662139.841296,
          "detection_id": "QMQYDAVPXP:0",
          "focus": null,
          "media_id": "XVLNY8FEKGT1VZC3XN2JGS2ZVAWH",
          "model_id": "Hpo-d-6fa6-2Xg6MZdpxEC2Jvx3K1-YN_mtsv0_4782.tgz",
          "prev_prob": null,
          "probability": 0.001000835148309544,
          "subject_uid": "cat_a1",
          "uncal_prob": 0,
          "user_id": null
        }
      ],
      "media": {
        "author": null,
        "author_profile_url": null,
        "created_at": 1497662135.660577,
        "external_media_id": null,
        "filename": null,
        "frame": null,
        "image_height": 1200,
        "image_width": 800,
        "license": null,
        "md5": "05180dac616104ff004027a5f274d6ad",
        "media_format": "JPEG",
        "media_id": "XVLNY8FEKGT1VZC3XN2JGS2ZVAWH",
        "media_src": "twitter",
        "media_timestamp": 1497662135.629489,
        "media_url": "https://cogniac-media.s3.amazonaws.com/XVLNY8FEKGT1VZC3XN2JGS2ZVAWH",
        "meta_tags": [
          "twitter"
        ],
        "network_camera_id": null,
        "original_landing_url": null,
        "original_url": null,
        "parent_media_id": null,
        "parent_media_ids": [],
        "preview_url": null,
        "resize_urls": {
          "454": "https://cogniac-media.s3.amazonaws.com/XVLNY8FEKGT1VZC3XN2JGS2ZVAWH_max_454",
          "750": "https://cogniac-media.s3.amazonaws.com/XVLNY8FEKGT1VZC3XN2JGS2ZVAWH_max_750"
        },
        "set_assignment": "training",
        "size": 168423,
        "source_url": null,
        "status": "success",
        "tenant_id": "skjdfh853k4jt",
        "title": null,
        "uploaded_by_user": null,
        "video": false
      },
      "focus": {
        "box": {
          "x0": 50,
          "x1": 275,
          "y0": 634,
          "y1": 870
        }
      },
      "updated_at": 1497662139.841296
    }
  ],
  "paging": {
    "next": "https://api.cogniac.io/1/applications/0Am1V3kr/detections?&end=1482263487.41&reverse=False&start=0&limit=5&only_user=False&only_model=False&probability_upper=1.0&probability_lower=0.0&cursor=1481857295.877328&consensus_none=False"
  }
}

Application Detections (URL Callback)

In addition to polling for recent Application detections, you can also specify a callback URL to receive postback detections in realtime as they occur. Please enter your listening URL's in the detection_post_urls field of the Application object, for example "detection_post_urls":["http://127.0.0.1:9999/my_model_output.net", "https://product_model_detections.co"].

Posts are retried for thirty seconds, but URL's that fail retried posts after thirty seconds are blacklisted for five minutes.

  • Expected Callback Json


{
  "media": {
    "media_id": "dfc37db6723376ab953b10cd40097a68",
    "parent_media_ids": ["c8ee0f4f05f3fdcf36f69a3fd81fd84f"]
  },
  "focus": {
    "box": {
      "x0": 50,
      "x1": 275,
      "y0": 634,
      "y1": 870
    }
  },
  "subjects": [
    {
      "subject_uid": "dog",
      "probability": 0.79,
      "updated_at": 1481857269.646634
    },
    {
      "subject_uid": "cat",
      "probability": 0.49,
      "updated_at": 1481857269.646634
    }
  ]
}

Application Feedback

Feedback is used to train and improve the performance of the Application. Feedback is a human task, where users can review predictions from an Application and correct any wrong predictions.

The Cogniac mobile app and web app have optimized feedback interface, and we advise users to utilize the existing interfaces for high-volume feedback tasks (particularly early during the training process).

Application's Pending Feedback Count

Query this endpoint to get the list of feedback requests that you want the user to provide feedback on.

Argument

Example

Description

limit

5

(optional) Limit between 1 and 10,
Defaults to 10.

Application's Pending Feedback

  • Endpoint

GET /1/applications/{application_id}/feedback?limit=5
Host: https://api.cogniac.io
  • Successful Response

[
  {
    "media": {
      "media_id": "eb51e7275210d74f5a0116e32c8b32d4",
      "resize_urls": {},
      "media_url": "https://cogniac-media.s3.amazonaws.com/eb51e7275210d74f5a0116e32c8b32d4"
    },
    "focus": {
      "box": {
        "x0": 50,
        "x1": 275,
        "y0": 634,
        "y1": 870
      }
    },
    "subjects": [
      {
        "app_data_type": null,
        "subject_uid": "bill",
        "media_id": "eb51e7275210d74f5a0116e32c8b32d4",
        "probability": 0.9424338417689073,
        "app_data": {}
      },
      {
        "app_data_type": null,
        "subject_uid": "prashant",
        "media_id": "eb51e7275210d74f5a0116e32c8b32d4",
        "probability": 0.01827074101387713,
        "app_data": {}
      },
      {
        "app_data_type": null,
        "subject_uid": "amy",
        "media_id": "eb51e7275210d74f5a0116e32c8b32d4",
        "probability": 0.023146493553089783,
        "app_data": {}
      },
      {
        "app_data_type": null,
        "subject_uid": "visitor",
        "media_id": "eb51e7275210d74f5a0116e32c8b32d4",
        "probability": 0.02874867741689087,
        "app_data": {}
      }
    ],
    "media_id": "eb51e7275210d74f5a0116e32c8b32d4"
  }
]

Provide Feedback

  • Endpoint

POST /1/applications/{application_id}/feedback
Host: https://api.cogniac.io
  • POST Body

[
  {
    "media": {
      "media_id": "eb51e7275210d74f5a0116e32c8b32d4",
      "resize_urls": {},
      "media_url": "https://cogniac-media.s3.amazonaws.com/eb51e7275210d74f5a0116e32c8b32d4"
    },
    "focus": {
      "box": {
        "x0": 50,
        "x1": 275,
        "y0": 634,
        "y1": 870
      }
    },
    "subjects": [
      {
        "app_data_type": null,
        "subject_uid": "bill",
        "media_id": "eb51e7275210d74f5a0116e32c8b32d4",
        "probability": 0.9424338417689073,
        "app_data": {}
      },
      {
        "app_data_type": null,
        "subject_uid": "prashant",
        "media_id": "eb51e7275210d74f5a0116e32c8b32d4",
        "probability": 0.01827074101387713,
        "app_data": {}
      },
      {
        "app_data_type": null,
        "subject_uid": "amy",
        "media_id": "eb51e7275210d74f5a0116e32c8b32d4",
        "probability": 0.023146493553089783,
        "app_data": {}
      },
      {
        "app_data_type": null,
        "subject_uid": "visitor",
        "media_id": "eb51e7275210d74f5a0116e32c8b32d4",
        "probability": 0.02874867741689087,
        "app_data": {}
      }
    ],
    "media_id": "eb51e7275210d74f5a0116e32c8b32d4"
  }
]

Application-Specific Data

Subject-media associations have optional additional application-specific data relative to the subject, box region areas in detection applications, and range of frames in detection full-frame applications, etc.

The Cogniac system supports the following application data types:
box_set - A list of box regions corresponding to the subject. A box region is defined as:

{
    “box”:            (dictionary of integers) “x0”, “x1”, “y0”, “y1”  
                          Values correspond to pixel offsets in the media item 
                          (x0, y0)  upper left corner of bounding box
                          (x1, y1) lower right corner of bounding box
                          Note that x1 must be greater than x0 
                          and y1 must be greater than y0
<pre><code>“probability”:  (optional) (float) probability for box
</code></pre>
Text}

segment_list - A list of video frame segments corresponding to the subject. A segment is defined as:

{
    “segment”:  (dictionary of integers) “f0”, “f1”
                       f0 & f1 correspond to the frame offsets in a video media 
                       (frame count starts at 0)
                       f0 is the first frame in the media item segment with the subject
                       f1 is the last frame in the media item segment with the subject 
                       Note that f1 must be greater than, or equal to f0

    “probabilities”:  [ordered list of per-frame model output probabilities]
                             The first list entry corresponds to prob for the frame at f0
                             The last list entry corresponds to prob for the frame at f1
                             Note the length of the list if present must equal (f1 - f0 + 1)
}

ocr - A string representing the characters detected.

7ZYA906

Application Feedback Semantics

Classification

Feedback Request
System proposes single most likely subject_uid associated with a full-frame media_id

Feedback
User supplies single most likely subject_uid associated with a media_id with result=True
result=False feedback is not allowed for classification applications.
result=Uncertain feedback is not currently supported for classification applications.

Detection Fullframe

Feedback Request
System proposes probability of association for each output subject_uid configured for an application

Feedback
User supplies “True”, “False”, or “Uncertain” for each output subject_uid configured for an application in a single feedback POST transaction.

Detection ROI

Feedback Request
System proposes single most likely region associated with the application’s subject_uid within a media_id.

Feedback
User supplies “True”, “False”, or “Uncertain” feedback result for the region proposed by the system. System immediately relays this “True”, “False”, or “Uncertain” via the POST feedback result API.

If user selects “False” or “Uncertain” feedback the user is always given the opportunity to correct the bounding box. This bounding box correction should only be enabled after the user selects “False” or “Uncertain” feedback result on the original proposal.

After a user provides False feedback on an original proposal and is given the option to correct the bounding box, the user can have the option of not providing a new bounding box (e.g. if the ROI does not exist in the image). In this case no additional feedback is required beyond the original False feedback.

If the bounding box is corrected that will be relayed to the system as a second feedback response with result True and appropriate bounding box coordinates.

Application Replay

The application replay endpoint allows users to resubmit, or "replay", media in the Cogniac System, that is readable by them, through an application for new detections.

The replay endpoint provides the user the ability to choose which subjects' associated media to replay through the application, not limited to the subjects bound to the application, as well as filters based on time and subject-media association probability.

Argument

Example

Description

replay

TRUE

(required) True - start replay of media through this application. False - stop replay of media.

replay_subjects

cat_123'

(required) Subject UID of media to replay. Multiple subjects can be replayed at once by passing multiple flags. Either replay_subjects or replay_media is required.

replay_media

AJW63NCGIH4NTYVRME

(required) Media ID of a single media item to replay. Either replay_subjects or replay_media is required.

foci

[{'box': {'x0': 0, 'y0': 50, 'x1': 100, 'y1': 150}}]

(optional) For replaying individual media, will replay media foci through the application.

replay_order

first

(optional) One of 'first', 'last', or 'random' - determines the order of media replay.
Defaults to 'first'.

probability_lower

0.75

(optional) Lower bound for subject-media association probabilities to replay.
Defaults to 0.66.

probability_upper

0.9

(optional) Upper bound for subject-media association probabilities to replay.
Defaults to 1.0.

limit

200

(optional) Maximum limit of media items to replay.

force_feedback

TRUE

(optional) True - force all replayed media detections to be surfaced for feedback. False - surfaced for feedback based on current feedback-per-hour rate.
Defaults to False.

replay_arguments

{"cat_1a": {"force_feedback": false, "limit": 1000, "probability_lower": 0, "probability_upper": 1, "replay_order": "first", "replayed": 10}}

(read-only) Map of current replay arguments by subject_uid.

replayed

20

(read-only) Total media items that have been replayed.

Send Replay Request

To replay media through an application, POST a replay request message to the application replay endpoint with appropriate replay flags set.

The POST response contains a list of replaying subjects as well as a map of replay specifications for each subject.

  • Endpoint

POST /1/applications/{app_id}/replay
Host: https://api.cogniac.io
  • POST Body

{
  "replay": true,
  "replay_subjects": ["cat_1a", "dog_2b"],
  "replay_order": "random"
}
  • Successful Response

{
  "replay": true,
  "replay_subjects": ["cat_1a", "dog_2b"],
  "replay_arguments": {
    "cat_1a": {
      "force_feedback": false,
      "limit": null,
      "probability_lower": 0.0,
      "probability_upper": 1.0,
      "replay_order": "random",
      "replayed": 12
    },
    "dog_2b": {
      "force_feedback": false,
      "limit": null,
      "probability_lower": 0.0,
      "probability_upper": 1.0,
      "replay_order": "random",
      "replayed": 15
    }
  }
}

Get Replay Status

The current replay status of an application can be received via a GET call to the application replay endpoint.

  • Endpoint

GET /1/applications/{app_id}/replay
Host: https://api.cogniac.io

A successful response will return the boolean replay flag as well as a list of the subjects that are replaying media through the application.

  • Successful Response

{
  "replay": true,
  "replay_subjects": ["cat_1a"],
  "replay_arguments": {
    "cat_1a": {
      "force_feedback": false,
      "limit": null,
      "probability_lower": 0.0,
      "probability_upper": 1.0,
      "replay_order": "random",
      "replayed": 26
    }
  }
}

Stop Replaying Subjects

Any subject that is readable by the authorized tenant can have associated media replayed through an application, regardless of whether the subject is bound to the application.

In addition to starting, when stopping application replay the subject_uids of the replaying subjects must be passed. Prior to stopping application replay it is recommended to send a GET /1/applications/{app_id}/replay request to retrieve a list of subjects whose associated media is actively replaying.

Application Consensus History

The Application Consensus History returns subject-media consensus counts over time for the output subjects of the application.

Argument

Example

Description

start

1234567890

(optional) Earliest timestamp of subject-media consensus records to return.

end

1234567890

(optional) Latest timestamp of subject-media consensus records to return.

limit

10

(optional) Max number of records (per subject) to return.

user_id

user@cogniac.co

(optional) Returns consensus counts for subject-media correctly asserted by the given user.

  • Endpoint

GET /1/applications/{app_id}/consensusHistory
Host: https://api.cogniac.io
  • Example Repsonse

{
  "data": [
    {
      "subjects": {
        "cat": {
          "True": 91
        },
        "dog": {
          "False": 40
        },
        "bird": {
          "True": 11
        }
      },
      "timestamp": 1490986560
    },
    {
      "subjects": {
        "cat": {
          "True": 82
        },
        "dog": {
          "False": 20
        }
      },
      "timestamp": 1490986620
    }
  ]
}


Was this article helpful?

What's Next