# Inference output

## Inference output examples

Let's first start with some examples of output which may be easier to understand than the exact specifications below.

A typical output for a classification algorithm will look like this:

{% code title="JSON" %}

```javascript
{
    "outputs": [{
        "labels": {
            "predicted": [{
                "label_name": "sunglasses",
                "label_id": 9,
                "score": 0.801353174,
                "threshold": 0.347
            },
            {
                "label_name": "glasses",
                "label_id": 8,
                "score": 0.175235228,
                "threshold": 0.139
            }],
            "discarded": []
        }
    }]
}
```

{% endcode %}

Prediction are displayed as soon as the prediction score is above the indicated threshold. The predictions are sorted by decreasing confidence, so you may only be interested in the first prediction `outputs[0]['labels']['predicted'][0]['label_name']` for a classification problem. For a multi-label classification problem (tagging), all the predicted labels are  independent and may be of interest.

The output of a detection algorithm is almost the same, see just below. Please note the presence of the `roi` field which indicate the location ("roi" stand for Region Of Interest)  of the object in the image. The `(xmin, ymin)` coordinate of the box corresponds to its top-left corner.

{% code title="JSON" %}

```javascript
{
    "outputs": [{
        "labels": {
            "predicted": [{
                "label_name": "sunglasses",
                "label_id": 9,
                "roi": {
                    "region_id": 1,
                    "bbox": {
                        "xmin": 0.312604159,
                        "ymin": 0.366485775,
                        "ymax": 0.5318923,
                        "xmax": 0.666821837
                    }
                },
                "score": 0.990304172,
                "threshold": 0.347
            }],
            "discarded": []
        }
    }]
}
```

{% endcode %}

## Inference output specification

The data returned by an inference request will contain the list of inference outputs:

<table><thead><tr><th width="123.33333333333331">Attribute</th><th width="142">Type</th><th>Description</th></tr></thead><tbody><tr><td>outputs</td><td>array(<a href="../recognition-specification#inference-output">object</a>)</td><td>An array of inference output objects. The i-th element of the array corresponds to the result of the i-th element of the specification <code>outputs</code> field and version <code>post_processings</code> field.</td></tr></tbody></table>

This object is directly related to the [output object](https://docs.deepomatic.com/deepomatic-api-v0.7/recognition-specification#output) of the specification: they both have the same unique field. It stores the recognition inference output.

<table><thead><tr><th width="126.33333333333331">Attribute</th><th width="137">Type</th><th>Description</th></tr></thead><tbody><tr><td>labels</td><td><a href="../recognition-specification#label">object</a></td><td>An output of type <code>labels</code>.</td></tr></tbody></table>

### **Inference labels output**

<table><thead><tr><th width="129.33333333333331">Attribute</th><th width="135">Type</th><th>Description</th></tr></thead><tbody><tr><td>predicted</td><td>array(<a href="../recognition-specification#prediction">object</a>)</td><td>An array of prediction object. This field stores the list of recognition hypotheses whose score is above the recognition threshold.</td></tr><tr><td>discarded</td><td>array(<a href="../recognition-specification#prediction">object</a>)</td><td>An array of prediction object. If you passed <code>show_discared=true</code> in the inference request, this field will store the list of recognition hypotheses whose score did not reached the recognition threshold.</td></tr></tbody></table>

### **Prediction**

Stores information related to an object hypothesis.

<table><thead><tr><th width="141.33333333333331">Attribute</th><th width="85">Type</th><th>Description</th></tr></thead><tbody><tr><td>label_id</td><td>int</td><td>The recognized label ID from the specification's label object.</td></tr><tr><td>label_name</td><td>string</td><td>The recognized label name from the specification's label object.</td></tr><tr><td>score</td><td>float</td><td>The recognition score.</td></tr><tr><td>threshold</td><td>float</td><td>The recognition threshold that was defined by the recognition version post-processing.</td></tr><tr><td>roi</td><td><a href="../recognition-specification#roi-object">object</a></td><td> (optional) If the <code>roi</code> field of the corresponding labels output object is not <code>"NONE"</code>, this field will store a ROI object.</td></tr></tbody></table>

### **ROI Object**

**ROI** stands for **Region Of Interest** and describes the position of an object.

<table><thead><tr><th width="145.33333333333331">Attribute</th><th width="87">Type</th><th>Description</th></tr></thead><tbody><tr><td>region_id</td><td>int</td><td>The region ID. It might not be unique among all the returned prediction objects. It can be used in conjunction with <code>show_discarded=true</code> to group the <code>predicted</code> and <code>discarded</code> fields by <code>region_id</code> to identify alternate labels for a given region in case of ambiguity.</td></tr><tr><td>bbox</td><td><a href="../common-objects#bounding-box-object">object</a></td><td>(optional) Present if and only if the region type is <code>"BBOX".</code></td></tr></tbody></table>
