Hasty JSON v1.0

JSON Example

{
"project_name": "Project Name,
"create_date": "2019-10-22 19:04:16Z",
"export_format_version": "1.0",
"export_date": "2019-11-19 16:21:18Z",
"label_classes": [
{
"class_name": "cat",
"color": "#1f78b44d",
"class_type": "object"
},
{
"class_name": "dog",
"color": "#e31a1c4d",
"class_type": "object"
}
],
"images": [
{
"image_name": "IMG_000002.jpg",
"dataset_name": "train dataset",
"width": 500,
"height": 430,
"image_status": "TO REVIEW",
"labels": [
{
"class_name": "cat",
"bbox": [102, 45, 420, 404],
"polygon": null,
"mask": null,
"z_index": 1
},
{...},
{...}
]
},
{...},
{...}
]
}

The Project object

Attributes

project_name string The name of the project

create_date string The project creation date in format YYYY-MM-DD HH:MI:SSZ

export_format_version string Internal file format version

export_date string The project export date in format YYYY-MM-DD HH:MI:SSZ

label_classes list of Label Class objects Projects label classes

images list of Image objects The list of images and associated labels

The Label Class object

Attributes

class_name string The name of the class

color string Associated with the label class color, in format #RRGGBBAA

class_type string Class type, "object" or "background"

The Image object

Attributes

image_name string The image filename

dataset_name string Dataset name

width integer Image width in pixels

height integer Image height in pixels

image_status string Image status. Possible values:

  • NEW

  • IN PROGRESS

  • TO REVIEW

  • SKIPPED

  • DONE

labels list of Label object The list of labels associated with the image

The Label object

Attributes

class_name string The name of the class

bbox list of integers or null Bounding box label. 4 numbers defining xmin, xmax, ymin, and ymax

polygon list of the list of integers or null Polygon coordinates, list of polygon vertices (x0, y0), (x1, y1), ...

mask list of integers or null RLE Encoded mask

z_index integer The z-index property specifies the stack order of an element. An element with a greater stack order is always in front of an element with a lower stack order.

RLE Encoding python example

import numpy as np
def rle_decode(mask_rle, shape):
"""
mask_rle: run-length as string formatted (start length)
shape: (width, height) of array to return
Returns numpy array, 1 - mask, 0 - background
"""
s = mask_rle
starts, lengths = [np.asarray(x, dtype=int) for x in (s[0:][::2], s[1:][::2])]
starts -= 1
ends = starts + lengths
shape = shape[1], shape[0]
img = np.zeros(shape[0] * shape[1], dtype=np.uint8)
for lo, hi in zip(starts, ends):
img[lo:hi] = 1
return img.reshape(shape)
bbox = [24, 307, 43, 320]
mask_rle = [11, 2, 26, 2, 30, 2, 45, 3, 49, 3, 60, 2, 65, 7, 79, 4, 84, 7, 99, 12, 115, 1, 119, 8, 128, 3, 134, 10, 149, 2, 154, 9, 164, 3, 169, 2, 173, 9, 189, 2, 193, 8, 206, 3, 214, 13, 234, 10]
mask = rle_decode(mask_rle, (bbox[2]-bbox[0], bbox[3]-bbox[1]))