Applications - Create
  • 22 Dec 2023
  • 5 Minutes to read
  • Dark
    Light

Applications - Create

  • Dark
    Light

Article summary

Applications Create

Applications can be created by posting to the application endpoint with the following arguments: only name and type are required. Input and output subjects are optional, but the application is not helpful until they are specified. And they can only be specified if the subjects already exist.

An application JSON object with complete attributes is returned.

Name

Example

Description

name
string

"Person detector"

(required) Name should be brief and descriptive

type
string

"classification"

(required) Cogniac appliction type, see type string in valid application type below

description
string

"Find people walking
 into the front door"

(optional) A full description of the purpose of the application. Use this field to capture detailed subject and any exceptional feedback instructions.

input_subjects
array

["flicker_cats",
 "animals_pics"]

(optional) Array of
 input subjects id's (note that input subjects' must be already created and have a valid id before adding to an Application)

output_subjects
array

["cat","dog","face"]

(optional) List of subject tags corresponding to objects, patterns, or features that are of interest in this application (note that output subjects' must be already created and have a valid id before adding to an Application)

release_metrics
string

"best_F1"

(optional) The performance measure used when to assess model performance.
 
 Must be one of 'best_recall', 'best_precision', 'best_F1'.
 
 Defaults to 'best_F1'

detection_
 thresholds

dictionary

{"cat": 0.5,
 "dog": 0.7,
 "face": 0.5}

(optional) Map between subject_uid's and associated probability thresholds. Detections below the specified probability threshold will not be forwarded to subsequent applications (if any). Detections below the threshold will not be posted to the detection_post_urls (if any).

detection_
 post_urls

array

["http://127.0.0.1:99/
 my_model_output.net", "https://detections-now.com/detections"]

(optional) A list of URL's where model detections will be surfaced in addition to web and iOS interfaces.
 
 Posts are retried for thirty seconds, but URL's that fail retried posts after thirty seconds are blacklisted for five minutes.

gateway_
 post_urls

array

["http://127.0.0.1:99/
 my_model_output.net", "https://detections-now.com/detections"]

(optional) A list of URL's where model detections will be surfaced from the gateway.
 
 Posts are retried for thirty seconds, but URL's that fail retried posts after thirty seconds are blacklisted for five minutes.
 
 Specifying a gateway post URL implies that the gateway will implement the application along with any linked applications.

active
bool

true

(optional) Flag to control if the the application is active or not. Inactive applications do not process images submitted to their input subjects or requests feed back.

requested_
 feedback_per_hour

integer

50

(optional) Override the target rate of feedback to surface per hour.
 
 A Null or value indicates the system feedback rate should be used.
 
 The default value is Null: system selects feedback rate.
 
 Select a higher value to schedule more feedback feedback requests, or a lower value to schedule fewer feedback requests.

refresh_feedback
bool

false

(optional) Flag to control whether the images waiting for user feedback should be re-evaluated by the new model when a new model is released.

app_managers
array

["user1@email.com", "user2@email.com"]

_(optional)_List of user email address, the users are given the app_manager role that is authorized to manage application settings and maintain feedback control.

Create Application

POST /1/applications
Host: https://api.cogniac.io

Example: Create a New Application

curl -X POST https://api.cogniac.io/1/applications \
-H "Authorization: Bearer abcdefg.hijklmnop.qrstuvwxyz" \
-H "Content-Type: application/json" \
-d '{ 
"name": "Test App",
"type": "classification",
"description": "App For Testing",
"output_subjects": ["cat", "dog"],
"detection_post_urls": ["http://example.com/cogniac-post"]
}'

Application Subjects

The input and output subjects must already exist in the system. Otherwise the above call will result in and error. One can always create applications without input and output subjects and add them later with an application update.

import cogniac

# connect to the tenant
cc = cogniac.CogniacConnection(username="testuser@cogniac.co", 
                               password="password", 
                               tenant_id="abcdefghijk")

# create the application with keyword arguments
applications = cc.create_application(name='Test App',
                      application_type='classification',
                      description='App For Testing',
                      output_subjects=['cat', 'dog'])
#                      detection_post_urls="http://example.com/cogniac-post"

print(applications)
import requests
import json
from pprint import pprint

url_prefix = 'https://api.cogniac.io'
api_version = "1"
token = ''  # add your token here
headers = {'Authorization': f'Bearer {token}',
           'Content-Type': 'application/json'}
application_data = { 
    "name": "Test App-Readme-Curl6",
    "type": "classification",
    "description": "App For Testing-Readme-Curl6",
    "output_subjects": ["cat", "dog"],
    "detection_post_urls": ["http://example.com/cogniac-post"]
}
url = f'{url_prefix}/{api_version}/applications'
res = requests.post(url, json=application_data, headers=headers)

if res.status_code == 200:
    response_data = json.loads(res.content)
    pprint(response_data)
else:
    pprint(f"Error: {res.status_code}, {res.text}")
{
    "application_id": "di71rG94",
    "tenant_id": "abcdefghijk",
    "name": "Test App",
    "description": "App For Testing",
    "type": "classification",
    "release_metrics": "best_F1",
    "output_subjects": [
        "cat",
        "dog"
    ],
    "detection_thresholds": {
        "dog": 0.0,
        "cat": 0.0
    },
    "active": true,
    "refresh_feedback": false,
    "app_managers": [
        "testuser@cogniac.co"
    ],
    "detection_post_urls": [
        "http://example.com/cogniac-post"
    ],
    "gateway_post_urls": [],
    "custom_fields": {},
    "hpo_credit": 0,
    "created_by": "testuser@cogniac.co",
    "created_at": 1508537094.552487,
    "modified_at": 1508537094.552487,
    "system_feedback_per_hour": 0,
    "requested_feedback_per_hour": null,   
    "release_model_count": null,
    "best_model_ccp_filename": null,
    "candidate_model_count": null,
    "current_performance": null,
    "last_candidate_at": null,
    "last_released_at": null,
    "training_data_count": null,
    "validation_data_count": null,
    "replay": false,
}

Valid Application Types

Name

Type string

Description

Classification

classification

Classify the full input image as exactly one subject to the mutual exclusion of the other subjects

Detection Full-frame

detection_fullframe

Detect the presence of one or more objects of interest in a full-frame image

Detection

box_detection

Detection with bounding boxes

Optical Character Recognition

ocr

reads a limited set of characters against a noisy real-world (non-document) image background

Static Count

static_count

count number of objects of interest in an image

Left Offset

offset_x

Measure the pixel distances from the LEFT frame edge to the subjects of interest

Top Offset

offset_y

Measure the pixel distances from the TOP frame edge to the subjects of interest

Point Detection

point

Locate a point coordinate for each object of interest

Motion Detection

motion

Perform motion detection based on background subtraction

Static Crop

static_crop

Perform a static crop at fixed coordinates. Negative numbers indicate the right-most or bottom pixel dimension of the image

Network Camera

network_camera

Pull images from network cameras and capture to a subject.

Twitter

twitter

Capture images from twitter to the indicated subjects

Video Segmentation

video_segmentation

Segment video files into individual frames or smaller segments

Other application types available by special arrangement include:

Name

Type string

Description

Line Crossing

line_crossing

Counts the number of objects crossing lines set by users! A dynamic tracking app must be an immediate upstream app!

Dynamic Tracking

dynamic_tracking

Track boxed objects in videos or real-time video streams! A detection app must be an immediate upstream app

DroneDeploy Retiler

retiler

Recombine DroneDeploy plan tiles into larger sub-plans of their original plan. Sub-plan size is given by configuration items 'max_height' and 'max_width'.

Static Focus

static_focus

Add the fixed focus on the media to indicate the area of interest to downstream apps. If a fixed coordinate is beyond the corresponding limit of the media, the focus at the coordinate will be set at the limit. If constant_focus_box_size is set to 1, the focus box's size will be maintained when a coordinate is beyond a media limit. If all the fixed coordinates are beyond the limits of media, no focus will be added.

NSFW Detection

nsfw

Detect the presence of explicit (NSFW) content.


Was this article helpful?