formats.md
Unicode text, UTF-8 text
Data formats
This document describes the various data formats that are used in the system.
Raw annotation data (client → server)
The client sends raw data for image annotations in a JSON format which is a list of shapes. Each shape is a dictionary with the following keys:
type
: The type of the shape which can be:bbox
(bounding box, rectangle)polygon
polyline
point
shape
: The shape data. Its format depends on the shapetype
:For
bbox
it is a dictionary with keys x, y, w, h: ~json {"x": x, "y": y, "w": w, "h": h}~For
polygon
andpolyline
it is a list of points; each point is a dictionary with keys x and y: ~json [{"x": x1, "y": y1}, {"x": x2, "y": y2}, ...]~ The only difference betweenpolygon
andpolyline
is that the former is supposed to be closed so the last point is connected to the first one.For
point
it is a dictionary with keys x and y: ~json {"x": x, "y": y}~All coordinates are floating-point numbers in the range [0, 1] and relative to the image size, with the origin in the top-left corner.
object
: The ID of the type of object (label) depicted in the shape. This ID is a human-readable string that must be registered in the system before being used on shapes.
Example
[ { "type": "bbox", "shape": {"x": 0.1, "y": 0.1, "w": 0.5, "h": 0.5}, "object": "Cat (Felis catus)" }, { "type": "polygon", "shape": [{"x": 0, "y": 0}, {"x": 1, "y": 0}, {"x": 0, "y": 1}], "object": "Slice of pizza margherita" }, { "type": "point", "shape": {"x": 0.5, "y": 0.5}, "object": "Cat (Felis catus) - left eye" } ]
Query format
The query format is based on YAML and used to query for pictures in the system.
Example
# Restrictions for queried images - want: # This means that the image must contain both rules, so both a cat and a dog - has_object: ["Cat (Felis catus)"] - has_object: ["Dog (Canis lupus familiaris)"] # Or we can put them in a list to mean that the image can contain any of the # objects in the list - has_object: ["Grass", "Flower"] # So the image must contain a cat and a dog, as well as either grass or # a flower # The following rule restricts the images to those with a certain source, # like a camera or a drawing; omitting this rule means that the images can # be of any type - nature: ["photo", "drawing"] # The following rule restricts the images to those with a certain licence - licence: ["CC-BY-1.0", "CC-BY-2.0", "CC-BY-3.0", "CC-BY-4.0", "CC0-1.0", "Unlicense", "WTFPL", "MIT", "BSD-2-Clause", "BSD-3-Clause", "Apache-2.0", "Informal-attribution", "Informal-do-anything", "Public-domain-old", "Public-domain"] # Prohibitions for queried images - exclude: # This means that the image must not contain any of the objects in the list - has_object: ["Human"] # This excludes images taken before the given date - before_date: 2019-01-01 # This requires images to have a minimum resolution - below_width: 800 - below_height: 600 # Pagination - limit: 32 - offset: 0 # Sorting - sort_by: "date-uploaded-recent" # Format - format: "jpg" - max_resolution: [800, 800] # resizes # In summary, we want the 32 most recent images that contain both a cat and # a dog, either a grass or a flower, but not a human, taken after 2019-01-01, # must be a photo or a drawing, must carry one of certain permissive licences # and have a resolution of at least 800x600 pixels.
1Data formats 2============ 3 4This document describes the various data formats that are used in the system. 5 6Raw annotation data (client → server) 7------------------------------------- 8 9The client sends raw data for image annotations in a JSON format which is a list 10of shapes. Each shape is a dictionary with the following keys: 11 12* `type`: The type of the shape which can be: 13* `bbox` (bounding box, rectangle) 14* `polygon` 15* `polyline` 16* `point` 17* `shape`: The shape data. Its format depends on the shape `type`: 18* For `bbox` it is a dictionary with keys x, y, w, h: 19~~~json 20{"x": x, "y": y, "w": w, "h": h} 21~~~ 22* For `polygon` and `polyline` it is a list of points; each point is a 23dictionary with keys x and y: 24~~~json 25[{"x": x1, "y": y1}, {"x": x2, "y": y2}, ...] 26~~~ 27The only difference between `polygon` and `polyline` is that the former is 28supposed to be closed so the last point is connected to the first one. 29* For `point` it is a dictionary with keys x and y: 30~~~json 31{"x": x, "y": y} 32~~~ 33* All coordinates are floating-point numbers in the range [0, 1] and relative 34to the image size, with the origin in the top-left corner. 35* `object`: The ID of the type of object (label) depicted in the shape. This ID 36is a human-readable string that must be registered in the system before 37being used on shapes. 38 39### Example 40 41~~~json 42[ 43{ 44"type": "bbox", 45"shape": {"x": 0.1, "y": 0.1, "w": 0.5, "h": 0.5}, 46"object": "Cat (Felis catus)" 47}, 48{ 49"type": "polygon", 50"shape": [{"x": 0, "y": 0}, {"x": 1, "y": 0}, {"x": 0, "y": 1}], 51"object": "Slice of pizza margherita" 52}, 53{ 54"type": "point", 55"shape": {"x": 0.5, "y": 0.5}, 56"object": "Cat (Felis catus) - left eye" 57} 58] 59~~~ 60 61Query format 62------------ 63 64The query format is based on YAML and used to query for pictures in the system. 65 66 67 68### Example 69~~~yaml 70# Restrictions for queried images 71- want: 72# This means that the image must contain both rules, so both a cat and a dog 73- has_object: ["Cat (Felis catus)"] 74- has_object: ["Dog (Canis lupus familiaris)"] 75# Or we can put them in a list to mean that the image can contain any of the 76# objects in the list 77- has_object: ["Grass", "Flower"] 78# So the image must contain a cat and a dog, as well as either grass or 79# a flower 80# The following rule restricts the images to those with a certain source, 81# like a camera or a drawing; omitting this rule means that the images can 82# be of any type 83- nature: ["photo", "drawing"] 84# The following rule restricts the images to those with a certain licence 85- licence: ["CC-BY-1.0", "CC-BY-2.0", "CC-BY-3.0", "CC-BY-4.0", "CC0-1.0", 86"Unlicense", "WTFPL", "MIT", "BSD-2-Clause", "BSD-3-Clause", 87"Apache-2.0", "Informal-attribution", "Informal-do-anything", 88"Public-domain-old", "Public-domain"] 89# Prohibitions for queried images 90- exclude: 91# This means that the image must not contain any of the objects in the list 92- has_object: ["Human"] 93# This excludes images taken before the given date 94- before_date: 2019-01-01 95# This requires images to have a minimum resolution 96- below_width: 800 97- below_height: 600 98# Pagination 99- limit: 32 100- offset: 0 101# Sorting 102- sort_by: "date-uploaded-recent" 103# Format 104- format: "jpg" 105- max_resolution: [800, 800] # resizes 106# In summary, we want the 32 most recent images that contain both a cat and 107# a dog, either a grass or a flower, but not a human, taken after 2019-01-01, 108# must be a photo or a drawing, must carry one of certain permissive licences 109# and have a resolution of at least 800x600 pixels. 110~~~ 111