Documentation
Search…
Label formats
When you label a sample and press the save button, you've created a label for that sample. Labels come in different types, with the available options determined by the type of the corresponding sample.
When downloading or uploading labels using the Python SDK, the format of the attributes field depends on the type of label. The different formats are described here.
A label can additionally also contain Object attributes and Image attributes.

Image

Segmentation labels

Format of the attributes field in client.get_label():
1
{
2
"format_version": "0.1",
3
"annotations": [
4
{
5
"id": 1, // this is an object id. Should be > 0.
6
"category_id": 1 // this is a category id
7
},
8
{
9
"id": 2,
10
"category_id": 1
11
},
12
{
13
"id": 3,
14
"category_id": 4
15
}
16
],
17
"segmentation_bitmap": {
18
"url": "https://segmentsai-staging.s3.eu-west-2.amazonaws.com/assets/davy/ddf55e99-1a6f-42d2-83e9-8657de3259a1.png"
19
}
20
}
Copied!
Thesegmentation_bitmap_urlrefers to a 32-bit RGBA png image which contains the segmentation masks. The alpha channel is set to 255, and the remaining 24-bit values in the RGB channels correspond to the object ids in the annotations list. Unlabeled regions should have a value of 0. Because of the large dynamic range, these png images may appear black in an image viewer.
When downloading a label, you can use the utility function utils.load_label_bitmap_from_url(url) in the Python SDK to load the label bitmap as a numpy array containing object ids.
When uploading a label, the easiest way to transform a segmentation bitmap into this format and upload it is by using the util functionbitmap2file:
1
from segments.utils import bitmap2file
2
3
# segmentation_bitmap is a numpy array of type np.uint32, with values corresponding to instance_ids
4
file = bitmap2file(segmentation_bitmap)
5
asset = client.upload_asset(file, "label.png")
6
segmentation_bitmap_url = asset["url"]
Copied!
For a full example of uploading model-generated labels to Segments.ai, please refer to this blogpost.

Vector labels (bounding box, polygon, polyline, keypoint)

Format of the attributes field in client.get_label():
1
{
2
"format_version": "0.1",
3
"annotations": [
4
{
5
"id": 1, // the object id
6
"category_id": 1, // the category id
7
"type": "bbox", // refers to the annotation type (bounding box)
8
"points": [
9
[12.34, 56.78], // x0, y0 (upper left corner of bbox)
10
[90.12, 34.56] // x1, y1 (lower right corner of bbox)
11
]
12
},
13
{
14
"id": 2,
15
"category_id": 2,
16
"type": "polygon", // refers to the annotation type (polygon)
17
"points": [
18
[12.34, 56.78], // x0, y0 (starting point of the polygon)
19
[90.12, 34.56], // x1, y1
20
[78.91, 23.45], // x2, y2
21
[67.89, 98.76], // x3, y3
22
[54.32, 10.01] // x4, y4
23
]
24
},
25
{
26
"id": 3,
27
"category_id": 3,
28
"type": "polyline", // refers to the annotation type (polyline)
29
"points": [
30
[12.34, 56.78], // x0, y0 (starting point of the polyline)
31
[90.12, 34.56], // x1, y1
32
[78.91, 23.45], // x2, y2
33
[67.89, 98.76], // x3, y3
34
[54.32, 10.01] // x4, y4
35
]
36
},
37
{
38
"id": 4,
39
"category_id": 4,
40
"type": "point", // refers to the annotation type (keypoint)
41
"points": [
42
[12.34, 56.78] // x, y (coordinates of keypoint)
43
]
44
},
45
],
46
}
Copied!

Image sequence

Segmentation labels

Coming soon.

Vector labels (bounding box, polygon, polyline, keypoint)

Format of the attributes field in client.get_label():
1
{
2
"format_version": "0.2",
3
"frames": [
4
{ ... },
5
{ ... },
6
{ ... }
7
]
8
}
Copied!
Where each frames object has the following format:
1
{
2
"format_version": "0.1",
3
"timestamp": "00001", // this field is only included if the sample has a timestamp
4
"annotations": [
5
{
6
"id": 1, // the object id
7
"category_id": 1, // the category id
8
"track_id": 6, // this id is used to links objects across frame
9
"is_keyframe": true, // whether this frame is a keyframe
10
"type": "bbox", // refers to the annotation type (bounding box)
11
"points": [
12
[12.34, 56.78], // x0, y0 (upper left corner of bbox)
13
[90.12, 34.56] // x1, y1 (lower right corner of bbox)
14
]
15
},
16
{
17
"id": 2,
18
"category_id": 2,
19
"track_id": 5, // this id is used to links objects across frame
20
"is_keyframe": true, // whether this frame is a keyframe
21
"type": "polygon", // refers to the annotation type (polygon)
22
"points": [
23
[12.34, 56.78], // x0, y0 (starting point of the polygon)
24
[90.12, 34.56], // x1, y1
25
[78.91, 23.45], // x2, y2
26
[67.89, 98.76], // x3, y3
27
[54.32, 10.01] // x4, y4
28
]
29
},
30
{
31
"id": 3,
32
"category_id": 3,
33
"track_id": 4, // this id is used to links objects across frame
34
"is_keyframe": true, // whether this frame is a keyframe
35
"type": "polyline", // refers to the annotation type (polyline)
36
"points": [
37
[12.34, 56.78], // x0, y0 (starting point of the polyline)
38
[90.12, 34.56], // x1, y1
39
[78.91, 23.45], // x2, y2
40
[67.89, 98.76], // x3, y3
41
[54.32, 10.01] // x4, y4
42
]
43
},
44
{
45
"id": 4,
46
"category_id": 4,
47
"track_id": 3, // this id is used to links objects across frame
48
"is_keyframe": true, // whether this frame is a keyframe
49
"type": "point", // refers to the annotation type (keypoint)
50
"points": [
51
[12.34, 56.78] // x, y (coordinates of keypoint)
52
]
53
},
54
],
55
}
Copied!

3D point cloud

Segmentation label

1
{
2
"format_version": "0.1",
3
"annotations": [
4
{
5
"id": 1, // the object id
6
"category_id": 1 // the category id
7
},
8
{
9
"id": 2,
10
"category_id": 1
11
},
12
{
13
"id": 3,
14
"category_id": 4
15
}
16
],
17
"point_annotations": [0, 0, 0, 3, 2, 2, 2, 1, 3...], // refers to object ids
18
}
Copied!

Cuboid label

1
{
2
"format_version": "0.2",
3
"annotations": [
4
{
5
"id": 1,
6
"category_id": 1,
7
"type": "cuboid",
8
"position": {
9
"x": 0.0,
10
"y": 0.2,
11
"z": 0.5
12
},
13
"dimensions": {
14
"x": 1.2,
15
"y": 1,
16
"z": 1
17
},
18
"yaw": 1.63,
19
"track_id": 1, // only in sequences
20
"is_keyframe": true, // only in sequences
21
"index": 0, // only in sequences
22
}
23
]
24
}
Copied!
Name
Type
Description
format_version
string
Format version.
annotations
array of cuboid annotations
List of the cuboid annotations.

Cuboid annotation

A cuboid annotation represents a single cuboid in a point cloud (frame).
1
{
2
"id": 1,
3
"category_id": 1,
4
"type": "cuboid",
5
"position": {
6
"x": 0.0,
7
"y": 0.2,
8
"z": 0.5
9
},
10
"dimensions": {
11
"x": 1.2,
12
"y": 1,
13
"z": 1
14
},
15
"yaw": 0.63,
16
"track_id": 1, // only in sequences
17
"is_keyframe": true, // only in sequences
18
"index": 0, // only in sequences
19
}
Copied!
Name
Type
Description
id
integer
Object id.
category_id
integer
Category id.
type
string
Object type, which is always "cuboid" for cuboid annotations.
position
object: { "x": float, "y": float, "z": float }
XYZ position of the center of the cuboid in world coordinates.
dimensions
object: { "x": float, "y": float, "z": float }
Dimensions of the cuboid. "x" corresponds to the length, "y" to the width, and "z" to the height. See diagram 1.
yaw
float
Cuboid rotation along the z-axis in radians between [-π, π]. 0 yaw corresponds to a cuboid aligned with the x-axis pointing to increasing x-values. The yaw value increases with a counter-clockwise rotation up to π, and decreases with a clockwise rotation up to -π. See diagram 2.
track_id
integer
Track ID of the object. This ID is used to track an object over multiple frames. Only relevant for sequences.
is_keyframe
boolean
Whether this cuboid annotation is a keyframe or an interpolated frame. Only relevant for sequences.
index
integer
The frame index. Only relevant for sequences.
Diagram 1: x and y attributes of the cuboid dimensions. The red arrow shows the cuboid heading.
Diagram 2: yaw rotation of a cuboid. The red arrow shows the cuboid heading. yaw = π/2 corresponds to a heading in the direction of increasing y values, while yaw = -π/2 corresponds to a heading in the direction of decreasing y values.

3D point cloud sequence

Segmentation label

1
{
2
"format_version": "0.2",
3
"frames": [
4
{ ... },
5
{ ... },
6
{ ... }
7
]
8
}
Copied!
Where each frames object has the following format:
1
{
2
"format_version": "0.2",
3
"annotations": [
4
{
5
"id": 1, // the object id
6
"category_id": 1, // the category id
7
"track_id": 3 // this id is used to link objects across frames
8
},
9
{
10
"id": 2,
11
"category_id": 1,
12
"track_id": 4
13
},
14
{
15
"id": 3,
16
"category_id": 4,
17
"track_id": 5
18
},
19
],
20
"point_annotations": [0, 0, 0, 3, 2, 2, 2, 1, 3...], // refers to object ids
21
}
Copied!

Cuboid label

1
{
2
"format_version": "0.2",
3
"frames": [
4
{ ... },
5
{ ... },
6
{ ... }
7
]
8
}
Copied!
Name
Type
Text
format_version
string
Format version.
frames
array of cuboid labels
List of cuboid labels (one per frame in the sequence).

Text

Named entity recognition and span categorization

Format of the attributes field in client.get_label():
1
{
2
"format_version": "0.1",
3
"annotations": [
4
{
5
"start": 0, // the first character index of the label
6
"end": 5, // the last character index of the the label (exclusive)
7
"category_id": 1 // the category id
8
},
9
{
10
"start": 7,
11
"end": 12,
12
"category_id": 0
13
},
14
{
15
"start": 20,
16
"end": 30,
17
"category_id": 2
18
},
19
]
20
}
Copied!

Object attributes

Objects in the annotations list can optionally also contain an attributes field to store object-level attributes. Make sure to properly configure the label editor if you're using object-level attributes.
1
{
2
"format_version": "0.1",
3
"annotations": [
4
{
5
"id": 1,
6
"category_id": 1,
7
"attributes": { // object-level attributes
8
"is_crowd": "1",
9
"color": "red"
10
}
11
},
12
{
13
"id": 2,
14
"category_id": 1,
15
"attributes": {
16
"is_crowd": "0",
17
"color": "blue"
18
}
19
},
20
{
21
"id": 3,
22
"category_id": 4,
23
"attributes": {
24
"is_crowd": "1",
25
"color": "yellow"
26
}
27
}
28
],
29
...
30
}
Copied!

Image attributes

You can also define image-level attributes. These can be useful in image classification tasks. Make sure to properly configure the label editor if you're using image-level attributes.
1
{
2
"format_version": "0.1",
3
"annotations": [...],
4
"image_attributes": { // sample-level attributes
5
"scene_type": "crossroads",
6
"weather": "sunny"
7
}
8
}
Copied!