# Recognition Version

## Version object

### Definition

A recognition version implements a specification: this is the link between a specification and a neural network.

<table><thead><tr><th width="181">Attribute</th><th width="99">Type</th><th width="115">Attributes</th><th>Description</th></tr></thead><tbody><tr><td>id</td><td>int</td><td>read-only</td><td>The ID of the recognition version.</td></tr><tr><td>spec_id</td><td>int</td><td>immutable</td><td>The ID of the parent <a href="/pages/-LZKqIqdZmQCP9l__ao2#specification-object">recognition specification</a>.</td></tr><tr><td>network_id</td><td>int</td><td>immutable</td><td>The ID of the <a href="/pages/-LZKqIf1mY6IjiPAv9Mg#network-object">neural network</a> which will cary on the computation.</td></tr><tr><td>post_processings</td><td><a href="#post-processing">object</a></td><td>immutable</td><td>The <a href="/pages/-LZKqIx_k7DW83QlWSTU#post-processing-object">post-processing</a> object that defines some network specific adjustments like the output tensor, some thresholds, etc. The length of this array must exactly match the length of the <code>outputs</code> field of the parent specification and the i-th post-processing will be matched to the i-th output.</td></tr><tr><td>spec_name</td><td>string</td><td>read-only</td><td>The name of the <a href="/pages/-LZKqIqdZmQCP9l__ao2#specification-object">recognition specification</a> corresponding to <code>spec_id</code>. This is convenient for display purposes.</td></tr><tr><td>network_name</td><td>string</td><td>read-only</td><td>The name of the <a href="/pages/-LZKqIf1mY6IjiPAv9Mg#network-object">neural network</a> corresponding to <code>network_id</code>. This is convenient for display purposes.</td></tr><tr><td>update_date</td><td>string</td><td>read-only</td><td>Date time (ISO 8601 format) of the creation specification version.</td></tr></tbody></table>

### Post-processing

{% hint style="info" %}
The fields of this object are mutually exclusive: you must specify exactly one of them.
{% endhint %}

<table><thead><tr><th width="183.33333333333331">Attribute</th><th width="98">Type</th><th>Description</th></tr></thead><tbody><tr><td>classification</td><td><a href="#classification-post-processing">object</a></td><td>A post-processing of type classification for an output of type <a href="/pages/-LZKqIqdZmQCP9l__ao2#label">labels</a>.</td></tr><tr><td>detection</td><td><a href="#detection-post-processing">object</a></td><td>A post-processing of type detection for an output of type <a href="/pages/-LZKqIqdZmQCP9l__ao2#label">labels</a>.</td></tr></tbody></table>

### Classification post-processing

<table><thead><tr><th width="129.33333333333331">Attribute</th><th width="119">Type</th><th>Description</th></tr></thead><tbody><tr><td>thresholds</td><td>array(float)</td><td>A list of threshold for each label of the recognition specification. The label will be considered present if its score is greater than the threshold. The length of this array must exactly match the length of the <code>labels</code> field of the parent <strong>labels</strong> specification and the i-th threshold will be matched to the i-th label.</td></tr></tbody></table>

### Detection post-processing

{% hint style="info" %}
You must specify exactly one of the `anchored_output`, `direct_output` or `yolo_output` fields. When we specify an expected tensor size in the description of those fields, we omit the first dimension of the tensor (i.e. the batch size).
{% endhint %}

<table><thead><tr><th width="163.33333333333331">Attribute</th><th width="120">Type</th><th>Description</th></tr></thead><tbody><tr><td>thresholds</td><td>array(float)</td><td>A list of threshold for each label of the recognition specification. The label will be considered present if its score is greater than the threshold. The length of this array must exactly match the length of the <code>labels</code> field of the parent <strong>labels</strong> specification and the i-th threshold will be matched to the i-th label.</td></tr><tr><td>nms_threshold</td><td>float</td><td>The Jaccard index threshold that will be applied to NMS to decide if two boxes <strong>of the same label</strong> represent the same object.</td></tr></tbody></table>

### Definition

Creates a new recognition version.

{% code title="cURL" %}

```bash
POST https://api.deepomatic.com/v0.7/recognition/versions
```

{% endcode %}

### Arguments

<table><thead><tr><th width="185">Parameter</th><th width="94">Type</th><th width="88">Default</th><th>Description</th></tr></thead><tbody><tr><td>spec_id</td><td>int</td><td></td><td>The ID of the parent <a href="/pages/-LZKqIqdZmQCP9l__ao2#specification-object">recognition specification</a>.</td></tr><tr><td>network_id</td><td>int</td><td></td><td>The ID of the <a href="/pages/-LZKqIf1mY6IjiPAv9Mg#network-object">neural network</a> which will cary on the computation.</td></tr><tr><td>post_processings</td><td><a href="/pages/-LZKqIx_k7DW83QlWSTU#post-processing">object</a></td><td></td><td>The <a href="/pages/-LZKqIx_k7DW83QlWSTU#post-processing">post-processing object</a> that defines some network specific adjustments like the output tensor, some thresholds, etc. The length of this array must exactly match the length of the <code>outputs</code> field of the parent specification and the i-th post-processing will be matched to the i-th output.</td></tr></tbody></table>

### Code sample

{% tabs %}
{% tab title="cURL" %}

```bash
curl https://api.deepomatic.com/v0.7/recognition/versions \
-H "X-API-KEY: ${DEEPOMATIC_API_KEY}" \
-d '{
"spec_id": 42,
"network_id": 123,
"post_processings": [{"classification": {"output_tensor": "inception_v3/logits/predictions", "thresholds": [0.025, 0.025]}}]
}' \
-H "Content-Type: application/json"
```

{% endtab %}

{% tab title="Python" %}

```python
import os
from deepomatic.api.client import Client
client = Client(api_key=os.getenv('DEEPOMATIC_API_KEY'))

client.RecognitionVersion.create(
    spec_id=42,
    network_id=123,
    post_processings=[{
        "classification": {
            "output_tensor": "inception_v3/logits/predictions",
            "thresholds": [
                0.5,
                0.5
            ]
        }
    }]
)
```

{% endtab %}
{% endtabs %}

### Response

A [recognition version object](/deepomatic-api-v0.7/recognition-version.md#version-object).

{% code title="JSON" %}

```javascript
{
    "id": 1,
    "spec_id": 42,
    "spec_name": "hot-dog VS not hot-dog classifier",
    "network_id": 123,
    "network_name": "hot-dog VS not hot-dog classifier",
    "update_date": "2018-03-09T18:30:43.404610Z",
    "post_processings": [{
        "classification": {
            "output_tensor": "inception_v3/logits/predictions",
            "thresholds": [
                0.5,
                0.5
            ]
        }
    }]
}
```

{% endcode %}

## List versions

### Definition

Get the list of existing recognition versions.

{% tabs %}
{% tab title="cURL" %}

```bash
# To access all your versions, use:
GET https://api.deepomatic.com/v0.7/recognition/versions

# To access versions attached to a given recognition spec, use:
GET https://api.deepomatic.com/v0.7/recognition/specs/{SPEC_ID}/versions
```

{% endtab %}

{% tab title="Python" %}

```python
import os
from deepomatic.api.client import Client
client = Client(api_key=os.getenv('DEEPOMATIC_API_KEY'))

# To access all your versions, use:
client.RecognitionVersion.list()

# To access versions attached to a given recognition spec, use:
client.RecognitionSpec.retrieve({SPEC_ID}).versions()
```

{% endtab %}
{% endtabs %}

### Code sample

{% tabs %}
{% tab title="cURL" %}

```bash
# To access all your versions:
curl https://api.deepomatic.com/v0.7/recognition/versions \
-H "X-API-KEY: ${DEEPOMATIC_API_KEY}"

# To access versions attached to a given recognition spec, use:
curl https://api.deepomatic.com/v0.7/recognition/specs/42/versions \
-H "X-API-KEY: ${DEEPOMATIC_API_KEY}"
```

{% endtab %}

{% tab title="Python" %}

```python
import os
from deepomatic.api.client import Client
client = Client(api_key=os.getenv('DEEPOMATIC_API_KEY'))

# To access all your versions, use:
for version in client.RecognitionVersion.list():
    print(version)

# To access versions attached to a given recognition spec, use:
for version in client.RecognitionSpec.retrieve(42).versions():
    print(version)
```

{% endtab %}
{% endtabs %}

### Response

A paginated list of responses.

<table><thead><tr><th width="127.33333333333331">Attribute</th><th width="134">Type</th><th>Description</th></tr></thead><tbody><tr><td>count</td><td>int</td><td>The total number of results.</td></tr><tr><td>next</td><td>string</td><td>The URL to the next page.</td></tr><tr><td>previous</td><td>string</td><td>The URL to the previous page.</td></tr><tr><td>results</td><td>array(<a href="/pages/-LZKqIx_k7DW83QlWSTU#version-object">object</a>)</td><td>A list of your <a href="/pages/-LZKqIx_k7DW83QlWSTU#version-object">recognition version objects</a>. Please note that the <code>post_processings</code> field is not present.</td></tr></tbody></table>

{% code title="JSON" %}

```javascript
{
    "count": 2,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 1,
            "spec_id": 42,
            "spec_name": "hot-dog VS not hot-dog classifier",
            "network_id": 123,
            "network_name": "hot-dog VS not hot-dog classifier",
            "update_date": "2018-03-09T18:30:43.404610Z"
        },
        ...
    ]
}
```

{% endcode %}

## Retrieve a version

### Definition

Retrieve a recognition version by ID.

{% code title="cURL" %}

```bash
GET https://api.deepomatic.com/v0.7/recognition/versions/{VERSION_ID}
```

{% endcode %}

### Arguments

<table><thead><tr><th width="133">Parameter</th><th width="74">Type</th><th width="87">Default</th><th>Description</th></tr></thead><tbody><tr><td>version_id</td><td>int</td><td></td><td>The ID of the version to retrieve.</td></tr></tbody></table>

### Code sample

{% tabs %}
{% tab title="cURL" %}

```bash
curl https://api.deepomatic.com/v0.7/recognition/versions/1 \
-H "X-API-KEY: ${DEEPOMATIC_API_KEY}"
```

{% endtab %}

{% tab title="Python" %}

```python
import os
from deepomatic.api.client import Client
client = Client(api_key=os.getenv('DEEPOMATIC_API_KEY'))

client.RecognitionVersion.retrieve(1)
```

{% endtab %}
{% endtabs %}

### Response

A [recognition version object](/deepomatic-api-v0.7/recognition-version.md#version-object).

## Delete a version

### Definition

Permanently deletes a recognition version.

{% code title="cURL" %}

```bash
DELETE https://api.deepomatic.com/v0.7/recognition/versions/{VERSION_ID}
```

{% endcode %}

{% hint style="danger" %}
**This cannot be undone.**
{% endhint %}

### Arguments

| Parameter   | Type | Default | Description                      |
| ----------- | ---- | ------- | -------------------------------- |
| version\_id | int  |         | The ID of the version to delete. |

### Code sample

{% tabs %}
{% tab title="cURL" %}

```bash
curl https://api.deepomatic.com/v0.7/recognition/versions/42 \
-H "X-API-KEY: ${DEEPOMATIC_API_KEY}" \
-X DELETE
```

{% endtab %}

{% tab title="Python" %}

```python
import os
from deepomatic.api.client import Client
client = Client(api_key=os.getenv('DEEPOMATIC_API_KEY'))

version = client.RecognitionVersion.retrieve(42)
version.delete()
```

{% endtab %}
{% endtabs %}

### Response

Return 204 (no content).

## Version inference

### Definition

Run inference on this specification version. This endpoint returns a task ID. Please refer to [the Specification Inference](/deepomatic-api-v0.7/recognition-specification.md#specification-inference) to have a comprehensive list of the inference request arguments and response.

{% code title="cURL" %}

```bash
POST https://api.deepomatic.com/v0.7/recognition/versions/{VERSION_ID}/inference
```

{% endcode %}

### Code sample

{% tabs %}
{% tab title="cURL" %}

```bash
curl https://api.deepomatic.com/v0.7/recognition/versions/1/inference \
-X POST \
-H "Content-Type: application/json" \
-H "X-API-KEY: ${DEEPOMATIC_API_KEY}" \
-d '{"inputs": [{"image": {"source": "https://static.deepomatic.com/resources/demos/api-clients/dog2.jpg"}}]}'
```

{% endtab %}

{% tab title="Python" %}

```python
import os
from deepomatic.api.client import Client
client = Client(api_key=os.getenv('DEEPOMATIC_API_KEY'))

version = client.RecognitionVersion.retrieve(1)
url = "https://static.deepomatic.com/resources/demos/api-clients/dog2.jpg"
version.inference(inputs=[deepomatic.ImageInput(url)])
```

{% endtab %}
{% endtabs %}

### Response

A task JSON.

{% code title="JSON" %}

```javascript
{
    "task_id": "123"
}
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.deepomatic.com/deepomatic-api-v0.7/recognition-version.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
