# import\_labels

`imerit_ango.sdk.SDK.`

## import\_labels(project\_id, labels)

Import pre-labels into your project.

{% hint style="danger" %}
You can only import annotations for tasks in the *Start* stage.

Please ensure the assets you are trying to annotate as in the *Start* stage of your project before continuing.
{% endhint %}

### Parameters

* **project\_id:** string
  * The unique identifier for the project. You can find the project ID in [the user interface](https://docs.imerit.net/sdk/sdk-documentation/..#project-ids) or retrieve it using the [`list_projects`](https://docs.imerit.net/sdk/sdk-documentation/project-level-sdk-functions/list_projects) function.
* **labels:** List\[dict]
  * List of labels to import. See more on our label format here: [Ango Annotation Format](https://docs.imerit.net/data/importing-and-exporting-annotations/importing-annotations/ango-import-format) and learn more about importing labels into Ango Hub [here](https://docs.imerit.net/data/importing-and-exporting-annotations/importing-annotations).

<details>

<summary>Example</summary>

```json
[
  {
    "externalId": "Test Pattern 844x844.png",
    "objects": [
      {
        "schemaId": "8f60cb0209a4d80f9add122",
        "title": "bbb",
        "bounding-box": {
          "width": 86,
          "height": 86,
          "x": 83,
          "y": 83
        }
      },
      {
        "schemaId": "8f60cb0209a4d80f9add122",
        "title": "bbb",
        "bounding-box": {
          "width": 167,
          "height": 167,
          "x": 338,
          "y": 338
        }
      },
      {
        "schemaId": "8f60cb0209a4d80f9add122",
        "title": "bbb",
        "bounding-box": {
          "width": 84,
          "height": 84,
          "x": 675,
          "y": 675
        }
      }
    ]
  }
]
```

</details>

Returns:

* **output:** dict
  * A dictionary containing the result of the operation.
  * Including a `status` field indicating whether the request was successful and a `data` field containing the response payload with updated resources produced by the operation.

### Example

Import Bounding Box

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

```python
import os
from dotenv import load_dotenv
from imerit_ango.sdk import SDK

load_dotenv('variables.env')
api_key = os.getenv('API_KEY')
project_id = os.getenv('PROJECT_ID')

ango_sdk = SDK(api_key)

schema_id = "8b9eacf582ebcf2f04fb832"

annotations = [
    {
        "externalId": "example.png",
        "objects": [
            {
                "schemaId": schema_id,
                "title": "Sample",
                "bounding-box": {
                    "x": 20,
                    "y": 30,
                    "width": 50,
                    "height": 60,
                },
            }
        ],
    }
]

ango_sdk.import_labels(project_id=project_id, labels=annotations)
```

{% endtab %}

{% tab title="curl" %}

```bash
curl -X POST "https://imeritapi.ango.ai/v2/import/labels" \
  -H "Content-Type: application/json" \
  -H "apikey: $ANGO_API_KEY" \
  -d '{
    "jsonContent": [
      {
        "externalId": "example.png",
        "objects": [
          {
            "bounding-box": {
              "height": 60,
              "width": 50,
              "x": 20,
              "y": 30
            },
            "schemaId": "8b9eacf582ebcf2f04fb832",
            "title": "Sample"
          }
        ]
      }
    ],
    "project": "$PROJECT_ID"
  }'
```

{% endtab %}
{% endtabs %}

<details>

<summary>Sample Category Schema </summary>

```json
{
  "tools": [
    {
      "schemaId": "8b9eacf582ebcf2f04fb832",
      "tool": "bounding-box",
      "title": "Sample",
      "required": false,
      "classifications": [],
      "multiple": false,
      "color": "#f44336",
      "shortcutKey": "1",
      "ocrEnabled": false
    }
  ],
  "classifications": [],
  "relations": []
}
```

</details>

Import Brush

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

```python
import os
import numpy as np
from dotenv import load_dotenv
from imerit_ango.sdk import SDK

api_key = os.getenv('API_KEY')
project_id = os.getenv('PROJECT_ID')

ango_sdk = SDK(api_key)

external_id = "example.png"
schema_id = "41be4ae7b3ddad31b1c4650"

height, width = 512, 512
brush_mask = np.full((height, width, 4), [255, 255, 255, 0], dtype=np.uint8) # background pixels
brush_mask[100:500, 100:500, :] = [50, 15, 46, 255] # foreground pixels

brush_url = ango_sdk.upload_brush_array(project_id=project_id, arr=brush_mask, medical=False)

annotations = [{"externalId": external_id, "brushDataUrl": brush_url, "objects": [{"brush": [50, 15, 46], "schemaId": schema_id}]}]

ango_sdk.import_labels(project_id, annotations)
```

{% endtab %}
{% endtabs %}

<details>

<summary>Sample Category Schema</summary>

```json
{
  "tools": [
    {
      "schemaId": "41be4ae7b3ddad31b1c4650",
      "tool": "brush",
      "title": "Sample",
      "required": false,
      "classifications": [],
      "multiple": false,
      "color": "#f44336",
      "shortcutKey": "1"
    }
  ],
  "classifications": [],
  "relations": []
}
```

</details>

Import Medical Brush

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

```python
import os
import numpy as np
from dotenv import load_dotenv
from imerit_ango.sdk import SDK

api_key = os.getenv('API_KEY')
project_id = os.getenv('PROJECT_ID')

ango_sdk = SDK(api_key)

external_id = "example.nrrd"
schema_id = 1

Z, Y, X = 512, 512, 512
volume = np.zeros((Z, Y, X), dtype=np.uint8)
volume[10:50, 10:100, 10:100] = schema_id

medical_brush_url = ango_sdk.upload_brush_array(project_id=project_id, arr=volume, medical=True)

annotations = [{"externalId": external_id, "medicalBrushDataUrl": medical_brush_url}]

ango_sdk.import_labels(project_id, annotations)
```

{% endtab %}
{% endtabs %}

<details>

<summary>Sample Category Schema</summary>

```json
{
  "tools": [
    {
      "schemaId": "1",
      "tool": "medical-brush",
      "title": "Sample",
      "required": false,
      "classifications": [],
      "multiple": false,
      "color": "#f44336",
      "shortcutKey": "1"
    }
  ],
  "classifications": [],
  "relations": []
}
```

</details>

{% hint style="info" %}
**See also**

[Ango Import Format](https://docs.imerit.net/data/importing-and-exporting-annotations/importing-annotations/ango-import-format)
{% endhint %}
