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.
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.
Parameters
project_id: string
The unique identifier for the project. You can find the project ID in the user interface or retrieve it using the
list_projects
function.
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.
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)
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)
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)
Last updated