A recognition specification describes the output format of your recognition algorithm. You may attach multiple algorithms that perform the same task to the same specification in order to leverage automatic updates of your embedded recognition models.
Parameter
Type
Attributes
Description
id
int (string)
read-only
The ID of the recognition specification. This field is a string for public recognition models.
name
string
A short name for your recognition specification.
description
string
A longer description of your recognition specification.
update_date
string
read-only
Date time (ISO 8601 format) of the last update of the recognition specification.
metadata
object
A JSON field containing any kind of information that you may find interesting to store.
current_version_id
int
nullable, hidden for public models
The ID of the current recognition version object that this specification will execute if you ask it to perform an inference. This is convenient if you want to allow your app to point to a constant API endpoint while keeping the possibility to smoothly update the recognition model behind. This field is hidden for public recognition models
The specification of the outputs you would like to recognize. It's an array of output objects. As this field tends to be large, it is hidden when you access the list of recognition models.
The id field is an integer for private models and a string for public recognition models.
A list of your recognition specification objects. Please note that the outputfield is not present and that current_version_id is unavailable for public recognition models.
Updates the specified specification by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
This request accepts only the name, metadata and current_version_id arguments. Other values are immutable.
Arguments
Parameter
Type
Attributes
Description
name
string
optional
A short name for your network.
description
string
optional
A longer description of your network.
metadata
object
optional
A JSON field containing any kind of information that you may find interesting to store.
current_version_id
int
optional
The ID of the current recognition version object that this specification will execute if you ask it to perform an inference. This is convenient if you want to allow your app to point to a constant API endpoint while keeping the possibility to smoothly update the recognition model behind.
An image input. It is the only supported type for now.
Image input
Parameter
Type
Default
Description
source
string
Either the URL of the image (in which case it must start with http: or https: ), or directly the binary content of the image (in which case it must start with data:image/jpeg;encoding, with encoding being either binaryor base64. jpeg might be replaced by another image type).
import os
from deepomatic.api.client import Client
client = Client(api_key=os.getenv('DEEPOMATIC_API_KEY'))
client.RecognitionSpec.create(
name="hot-dog VS not hot-dog classifier",
description="My great hot-dog VS not hot-dog classifier !",
metadata={
"author": "me",
"project": "my secret project"
},
outputs = [{
"labels": {
"roi": "NONE",
"exclusive": True,
"labels": [{
"id": 0,
"name": "hot-dog"
}, {
"id": 1,
"name": "not hot-dog"
}]
}
}]
)
JSON
{
"id": 42,
"name": "hot-dog VS not hot-dog classifier",
"description": "My great hot-dog VS not hot-dog classifier !",
"task_id": 123,
"update_date": "2018-02-16T16:37:25.148189Z",
"metadata": {
"author": "me",
"project": "my secret project"
},
"outputs": [{
"labels": {
"roi": "NONE",
"exclusive": true,
"labels": [{
"id": 0,
"name": "hot-dog"
}, {
"id": 1,
"name": "not hot-dog"
}]
}
}],
"current_version_id": null
}
# To list public specifications, use:
GET https://api.deepomatic.com/v0.7/recognition/public
# To list your own specifications, use:
GET https://api.deepomatic.com/v0.7/recognition/specs
import os
from deepomatic.api.client import Client
client = Client(api_key=os.getenv('DEEPOMATIC_API_KEY'))
# To list public specifications, use:
client.RecognitionSpec.list(public=True)
# To list your own specifications, use:
client.RecognitionSpec.list()
# For public specifications:
curl https://api.deepomatic.com/v0.7/recognition/public \
-H "X-API-KEY: ${DEEPOMATIC_API_KEY}"
# For private networks:
curl https://api.deepomatic.com/v0.7/recognition/specs \
-H "X-API-KEY: ${DEEPOMATIC_API_KEY}"
import os, deepomatic
client = deepomatic.Client(api_key=os.getenv('DEEPOMATIC_API_KEY'))
# For public specifications:
for spec in client.RecognitionSpec.list(public=True):
print(spec)
# For private specifications:
for spec in client.RecognitionSpec.list():
print(spec)
JSON
{
"count": 2,
"next": null,
"previous": null,
"results": [
{
"id": 42,
"name": "My great hot-dog VS not hot-dog classifier !",
"description": "Very complicated classifier",
"update_date": "2018-03-09T18:30:43.404610Z",
"current_version_id": 1,
"metadata": {}
},
...
]
}
# To retrieve a public specification, use:
GET https://api.deepomatic.com/v0.7/recognition/public/{SPEC_ID}
# To retrieve your own specification, use:
GET https://api.deepomatic.com/v0.7/recognition/specs/{SPEC_ID}
import os
from deepomatic.api.client import Client
client = Client(api_key=os.getenv('DEEPOMATIC_API_KEY'))
# {SPEC_ID} may be a string for a public specification
# or an integer for your own specification.
client.RecognitionSpec.retrieve({SPEC_ID})
# For a public specification:
curl https://api.deepomatic.com/v0.7/recognition/public/fashion-v4 \
-H "X-API-KEY: ${DEEPOMATIC_API_KEY}"
# For a private specification:
curl https://api.deepomatic.com/v0.7/recognition/specs/42 \
-H "X-API-KEY: ${DEEPOMATIC_API_KEY}"
import os, deepomatic
client = deepomatic.Client(api_key=os.getenv('DEEPOMATIC_API_KEY'))
# For a public specification:
client.RecognitionSpec.retrieve("fashion-v4")
# For a private specification:
client.RecognitionSpec.retrieve(42)
import os
from deepomatic.api.client import Client
client = Client(api_key=os.getenv('DEEPOMATIC_API_KEY'))
spec = client.RecognitionSpec.retrieve(42)
spec.delete()
# To run inference on a public specification, use:
POST https://api.deepomatic.com/v0.7/recognition/public/{SPEC_ID}/inference
# To run inference on your own specification, use:
POST https://api.deepomatic.com/v0.7/recognition/specs/{SPEC_ID}/inference
import os
from deepomatic.api.client import Client
client = Client(api_key=os.getenv('DEEPOMATIC_API_KEY'))
# {SPEC_ID} may be a string for a public specification
# or an integer for your own specification.
spec = client.RecognitionSpec.retrieve({SPEC_ID})
spec.inference(...)
URL=https://static.deepomatic.com/resources/demos/api-clients/dog2.jpg
# Inference from an URL:
curl https://api.deepomatic.com/v0.7/recognition/public/fashion-v4/inference \
-H "X-API-KEY: ${DEEPOMATIC_API_KEY}" \
-d "{\"inputs\":[{\"image\": {\"source\": \"${URL}\"}}]}" \
-d show_discarded="True" \
-H "Content-Type: application/json" \
-d max_predictions=100
# You can also directly send an image file or binary content using multipart/form-data:
curl ${URL} > /tmp/img.jpg
curl https://api.deepomatic.com/v0.7/recognition/public/fashion-v4/inference \
-H "X-API-KEY: ${DEEPOMATIC_API_KEY}" \
-F inputs[0]image.source=@/tmp/img.jpg
# You can also send base64 data by prefixing it with 'data:image/*;base64,' and sending it as application/json:
BASE64_DATA=$(cat /tmp/img.jpg | base64)
curl https://api.deepomatic.com/v0.7/recognition/public/fashion-v4/inference \
-H "X-API-KEY: ${DEEPOMATIC_API_KEY}" \
-H "Content-Type: application/json" \
-d "{\"inputs\":[{\"image\": {\"source\": \"data:image/*;base64,${BASE64_DATA}\"}}]}"
import base64
import sys, tarfile
if sys.version_info >= (3, 0):
from urllib.request import urlretrieve
else:
from urllib import urlretrieve
import os
from deepomatic.api.client import Client
from deepomatic.api.inputs import ImageInput
client = Client(api_key=os.getenv('DEEPOMATIC_API_KEY'))
spec = client.RecognitionSpec.retrieve("fashion-v4")
# Inference from an URL:
url = "https://static.deepomatic.com/resources/demos/api-clients/dog2.jpg"
spec.inference(inputs=[ImageInput(url)], show_discarded=True, max_predictions=100)
# You can also directly send an image file:
urlretrieve(url, '/tmp/img.jpg')
with open('/tmp/img.jpg', 'rb') as fp:
spec.inference(inputs=[ImageInput(fp)])
# You can also send binary data:
with open('/tmp/img.jpg', 'rb') as fp:
binary_data = fp.read()
spec.inference(inputs=[ImageInput(binary_data, encoding="binary")])
# If you finally want to send base64 data, you can use:
base64_data = base64.b64encode(binary_data)
spec.inference(inputs=[ImageInput(base64_data, encoding="base64")])