Importing annotations

Contents

Hasty support an import of existing annotations of the following types:

  • bbox - Bounding boxes (as a JSON file)

  • polygon - Polygons (as a JSON file)

  • semantic - Semantic segmentation (as a PNG image)

  • label_class - Label classes (as a JSON file)

  • hasty_export - JSON File with a structure of the Hasty JSON V1.1

bbox or polygon

The JSON should be of the following format:

{
"definitions": {},
"type": "array",
"title": "Array of Images",
"items": {
"type": "object",
"title": "Image",
"required": [
"image_name",
"labels"
],
"properties": {
"image_name": {
"type": "string",
"title": "Image file name",
"default": "",
"examples": [
"2010_000001.jpg"
]
},
"labels": {
"type": "array",
"title": "Image labels",
"items": {
"type": "object",
"title": "Image label",
"required": [
"class_name",
"bbox"
],
"properties": {
"class_name": {
"type": "string",
"title": "Name of the label class",
"default": "",
"examples": [
"ground"
]
},
"bbox": {
"type": "array",
"title": "Bounding box coordinates [X_top_left, Y_top_left, X_bottom_right, Y_bottom_right]",
"items": {
"type": "integer",
"examples": [
3,
12,
500,
295
]
}
},
"polygon": {
"type": "array",
"title": "Polygon coordinates [[x0, y0], [x1, y1], ...]",
"items": {
"type": "array",
"items": {
"type": "integer",
"examples": [
202,
13
]
}
}
}
}
}
}
}
}
}

As an example, here are two annotations, one bounding box (cat) and one polygon (dining table):

[
{
"image_name": "2010_000001.jpg",
"labels": [
{
"class_name": "cat",
"bbox": [128, 13, 340, 308]
}
]
},
{
"image_name": "2010_000001.jpg",
"labels": [
{
"class_name": "diningtable",
"polygon": [[122, 222], [73, 236], [72, 250], [2, 256], [2, 332], [498, 332],
[498, 295], [429, 260], [339, 231], [282, 223], [297, 246], [306, 285], [280, 302],
[255, 271], [224, 260], [222, 304], [199, 310], [171, 290], [171, 265],
[131, 244], [128, 222]]
}
]
}
]

semantic

Each file with a semantic segmentation should be an image in *.png format. The filename should be the same (without extension) as the corresponding image's name. The image file can contain one or three channels.

label_class

Label classes can be imported through the use of a JSON-file with in the following schema:

{
"$id": "http://example.com/root.json",
"type": "array",
"title": "List of Label Classes",
"items": {
"type": "object",
"png_index": "number",
"required": [
"name",
"type"
],
"properties": {
"name": {
"type": "string",
"title": "Class name",
"examples": [
"floor"
]
},
{
"png_index": {
"type": "number",
"title": "PNG index",
"examples": [
18
]
},
"color": {
"type": "string",
"title": "Class color (can be assigned automatically)",
"examples": [
"#F453A3"
]
},
"type": {
"type": "string",
"title": "object or background",
"default": "object",
"examples": [
"background"
]
}
}
}
}

As an example:

[
{
"color": "#8000ff4d",
"png_index": 1,
"name": "wall",
"type": "background"
},
{
"color": "#396bf94d",
"png_index": 17,
"name": "plate",
"type": "object"
}
]

As you can see, there are two types of classes: object (1) and background (2). These correspond to the foreground (1) and semantic (2) classes you see in the tool.

If you are looking to import masks or do other, more complex imports with attributes and image tags as well as annotations, you need to format your data into our own supported Hasty JSON v1.1.

Can’t find what you are looking for in our documentation? Get in contact with me, Herbert Janssen, community manager here at Hasty by emailing [email protected] if you have any questions or need help.