import_labels

imerit_ango.sdk.SDK.

import_labels(project_id, labels)

Import labels to the project. More details on importing existing labels to Hub here.

Parameters

  • project_id: string

  • labels: List[dict]

    • List of labels to import. See more on our label format here: Ango Annotation Format and learn more about importing labels into Ango Hub here.

Example
[
  {
    "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
        }
      }
    ]
  }
]

Returns:

  • output: dict

    • A dictionary containing the result of the operation.

Example

Import Bounding Box

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, annotations)
Sample Category Schema
{
  "tools": [
    {
      "schemaId": "8b9eacf582ebcf2f04fb832",
      "tool": "bounding-box",
      "title": "Sample",
      "required": false,
      "classifications": [],
      "multiple": false,
      "color": "#f44336",
      "shortcutKey": "1",
      "ocrEnabled": false
    }
  ],
  "classifications": [],
  "relations": []
}

Import Brush

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)
Sample Category Schema
{
  "tools": [
    {
      "schemaId": "41be4ae7b3ddad31b1c4650",
      "tool": "brush",
      "title": "Sample",
      "required": false,
      "classifications": [],
      "multiple": false,
      "color": "#f44336",
      "shortcutKey": "1"
    }
  ],
  "classifications": [],
  "relations": []
}

Import Medical Brush

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)
Sample Category Schema
{
  "tools": [
    {
      "schemaId": "1",
      "tool": "medical-brush",
      "title": "Sample",
      "required": false,
      "classifications": [],
      "multiple": false,
      "color": "#f44336",
      "shortcutKey": "1"
    }
  ],
  "classifications": [],
  "relations": []
}

Last updated