Per-Object Attributes for Boxes, Tracks, and Cuboids
Add typed fields such as occlusion and truncation to each box, video track, or 3D cuboid, with agreement per attribute and the formats that keep the values.
Per-object attributes are typed fields that an annotator fills in for each box or shape, such as how much of a car is hidden or whether the image edge cuts the car off. Since Potato 2.12.0, an image_annotation scheme takes an attributes block, and the same block works on video tracks and on 3D boxes in a point cloud. With two or more annotators per image, Potato reports Krippendorff's alpha for each attribute over the objects that two or more annotators drew.
A label says what an object is, and an attribute records a property of that one object. KITTI records occlusion and truncation for every object, and a question about the whole image cannot say which box was occluded. An attribute keeps the value on the box itself. Exports and the agreement report then use the value object by object.
Configuration
Add an attributes list to an image_annotation scheme. The config below records occlusion and truncation on every shape, parking on vehicles only, and activity on people only:
annotation_task_name: Vehicle and pedestrian attributes
task_dir: .
data_files:
- data/images.json
item_properties:
id_key: id
text_key: image_url
output_annotation_dir: annotation_output/
num_annotators_per_item: 2
annotation_schemes:
- annotation_type: image_annotation
name: objects
description: "Box each vehicle and person, then set the box's attributes under the image."
source_field: image_url
tools: [bbox, polygon]
labels:
- name: vehicle
color: "#2563eb"
- name: person
color: "#dc2626"
attributes:
- name: occlusion
type: select
options: [none, partial, heavy]
required: true
default: none
description: "How much of the object is hidden behind something else"
- name: truncated
type: bool
default: false
description: "Cut off by the edge of the image"
- name: truncation
type: number
min: 0
max: 1
show_if: {attribute: truncated, equals: true}
description: "Share of the object outside the image, from 0 to 1"
- name: parked
type: bool
labels: [vehicle]
- name: activity
type: multi
options: [walking, standing, cycling, carrying]
labels: [person]The config passes python -m potato.validate_cli --strict on Potato 2.14.0. The agreement report needs two annotators per image, and num_annotators_per_item: 2 sends each image to two. Each attribute takes the keys below:
| Key | Default | Meaning |
|---|---|---|
name | required | The attribute's name. The panel shows the name as the field's caption, and storage and every export use the same name. |
type | select | One of select, multi, text, number, or bool |
options | none | The choices. Required for select and multi, and refused on the other types. |
labels | every label | The scheme labels the attribute applies to. Each entry must be one of the scheme's labels. |
required | false | Blocks Next while any shape the attribute applies to has no value |
default | none | The value set on each shape an annotator draws. For select and multi, the default must be one of the options. |
show_if | none | {attribute: <name>, equals: <value>}. Shows the field only while another attribute of the same scheme has the given value. |
min, max | none | Bounds for a number field |
description | none | Help text under the field |
per_keyframe | false | Video tracks and point clouds only. Lets the value change along a track. |
Potato checks the block when the config loads and stops with a message that names the attribute. An unknown key gets a suggested spelling. For example, Potato answers a misspelled option: with a pointer to options. The same check stops the config on a name used twice, a select or multi with no options, a labels entry that is not one of the scheme's labels, a default outside the options, and per_keyframe on an image scheme. A message about an unknown key or a name used twice gives the attribute's position in the list, such as attributes[0], in place of the name. Changing labels: [vehicle] to labels: [car] on the parked attribute stops the server with this message:
annotation_schemes[0].attributes[parked].labels names car, which is not among the scheme's labels (vehicle, person)
YAML reads an unquoted yes or no as a boolean. Potato turns a boolean option back into the text yes or no. With options: [yes, no], the panel therefore shows and stores the two words as written.
Attribute types
Each type gets its own control in the panel and its own stored value:
| Type | Control | Stored value |
|---|---|---|
select | A drop-down list with a blank first entry | One option, as text |
multi | One checkbox per option | A list of the checked options |
bool | A checkbox | true or false |
number | A number field | A number |
text | A one-line text field | The text as typed |
The number field uses min and max as the limits of its arrows. A typed value outside the limits is saved as typed. Check the range after export when the bounds matter. Choosing the blank entry of a select, unchecking every box of a multi, or emptying a number or text field removes the value from the shape. Unchecking a bool stores false.
Attributes for some labels only
A labels list limits an attribute to shapes with the listed labels. In the example config, a person box shows no parked field, and a vehicle box shows no activity field. Relabeling a selected shape rebuilds the panel for the new label. A value set under the old label stays on the shape and goes out in the exports, although the panel no longer shows the value and the agreement report leaves the value out.
show_if hides a field until another attribute has a given value. The truncation field appears only once truncated is checked. In Potato 2.14.0, a show_if that names a multi attribute never matches. A field gated on a multi attribute therefore never appears and never counts as required. Gate show_if on a select or bool attribute only. Hiding a field does not clear a value already set in the field.
Defaults and required attributes
Potato sets the defaults once, on each shape an annotator draws, while the shape has no attributes yet. A shape from a model or an import gets no defaults and keeps the attributes the shape arrived with. A default therefore never passes for a model's answer or a source file's value. Potato gives defaults only to shapes whose source is human. An import sets source to import unless the file names a source, but Potato's own COCO export keeps source: human. A shape re-imported from a Potato COCO export therefore counts as drawn by a person and can receive defaults. Changing an attribute on a model's shape or an imported shape marks the shape edited, as moving the shape does. The edited flag keeps an accepted suggestion apart from a corrected one in the data.
A required attribute counts only on shapes whose label the attribute applies to, and only while show_if shows the field. While any shape lacks a required value, the panel's status line gives the count ("2 objects still need required attributes"). Pressing Next then shows the same message in the banner instead of moving on. A required attribute with a default is filled as soon as the shape is drawn, and the requirement then catches a value the annotator cleared.
Annotating
Draw a shape or click a shape, and the Object attributes panel under the image shows the fields for that shape's label, under the heading 'Attributes for the selected "vehicle"'. The caption of a required field ends in an asterisk. With nothing selected, the panel reads "Select a shape to set its attributes.", and a shape whose label has no attributes shows "No attributes for" with the label's name. Each edit saves at once and joins the undo history beside the drawing edits.
The fields are ordinary form controls, and Tab moves between the fields. While the focus is in an attribute field, Potato ignores the tool shortcuts, such as r for the box tool. Typing a value therefore never switches the drawing tool. Selecting a shape on an image takes a click, because the image tool has no key that steps from one shape to the next.
Video tracks and point clouds
The same attributes block works on a video_annotation scheme in tracking or combined mode, where each track takes one set of values. A video scheme left in the default segment mode fails validation when the scheme declares attributes. In a video, the panel sits under the track list and shows the attributes of the active track. In a spatial_annotation scheme, each 3D box or point takes a separate set of values. The panel sits under the point-cloud viewer and shows the attributes of the selected box or point, and the , and . keys step the selection through the objects on the scan.
A car can be in full view for a hundred frames and behind a truck for the next forty. With per_keyframe: true, an attribute on a video track or a point-cloud sequence takes a value at each keyframe instead of one value for the whole track. The video scheme below records occlusion frame by frame and parking once per track:
annotation_schemes:
- annotation_type: video_annotation
name: tracks
description: "Track each vehicle and set the track's attributes."
mode: tracking
labels:
- name: vehicle
color: "#2563eb"
attributes:
- name: occluded
type: select
options: [none, partial, heavy]
default: none
per_keyframe: true
- name: parked
type: boolA per_keyframe value holds from the keyframe that sets the value to the next keyframe that changes the value, and Potato never interpolates between values. Before the first keyframe that sets the value, the track's own value applies. Under a per_keyframe field, the panel shows "From frame N until the next keyframe that changes it". Changing the value on a frame between keyframes first pins a keyframe on that frame with the interpolated box, as moving the box would. Outside the track's first and last keyframes, the panel keeps the old value and says the frame is outside the track. In the example, parked stays one value for the whole track.
Label LiDAR Point Clouds With 3D Cuboids From KITTI builds a point-cloud task with an occluded attribute and shows the agreement report for the attribute.
Storage
Annotations persist to <output_annotation_dir>/<user>/user_state.json, and each shape carries the shape's values in an attributes object. A stored box from the example config has these keys, with the coordinates left out:
{
"type": "bbox",
"label": "vehicle",
"source": "human",
"attributes": {"occlusion": "partial", "truncated": false, "parked": true}
}A video track stores per-track values in the same attributes object beside the track's keyframes. A per_keyframe value set on a video frame is stored on that keyframe, as keyframes.<frame>.attributes, and only for the attributes that change there. A null on a keyframe clears the value from that frame on. Each keyframe of a point-cloud sequence stores the full set of the object's attributes.
Export formats
Each export format keeps the attributes, maps some attributes onto the format's own columns, or drops the attributes. Export with python -m potato.export --config config.yaml --format <name> --output ./export/:
--format | What happens to attributes |
|---|---|
coco | Written as an attributes object on each annotation. potato import -f coco reads the object back. |
cvat | Written as an <attribute name="..."> element on each shape, with the value as text. A bool comes out as True or False, and a multi as the text of a Python list. The CVAT importer reads every value back as text. |
darwin | Written as a properties object on each annotation |
kitti, kitti_3d | Mapped onto KITTI's truncation and occlusion columns, from attributes with the names in the next table. The kitti exporter also reads attributes named alpha, dimensions_hwl, location_xyz, and rotation_y. Other attributes are dropped. |
mot | ignore sets the row's confidence to 0, and visibility fills MOT's visibility column. On image and sequence boxes, track_id fills the identity column. A video track's identity is the track's position in the track list, and Potato ignores a track_id attribute on the track. Other attributes are dropped. A video track's row takes the value at the row's frame. |
yolo, labelme | Dropped |
pascal_voc | Dropped. Each object's truncated and difficult fields are written as 0. |
Potato's Darwin importer reads the attributes field of a V7 annotation, not the properties field that the Darwin exporter writes. A Darwin file that Potato exported and imports again therefore comes back without the attributes. Use coco or cvat for a round trip that keeps the values.
The two KITTI exporters read these attribute names and values, with an underscore read as a space:
| KITTI column | Attribute name | Values read |
|---|---|---|
| truncated | truncated or truncation | A share from 0 to 1; none, no, not truncated, or false; partly, partial, partially, yes, or true; fully, full, largely, or heavy |
| occluded | occluded or occlusion | A code from 0 to 3; none or fully visible (0); partly, partial, or partly occluded (1); largely, heavy, or largely occluded (2); unknown (3); true or false |
The example config uses these names and values and exports to KITTI as written. In the kitti export, a share is written as the share, a partial level as 0.5, and a full level as 1.0. A lone integer 0, 1, or 2 counts as a level code rather than a share. A truncation of 1 is therefore written as 0.5. A truncated value of false overrides any share in truncation. The kitti_3d export writes the larger of the attribute's value and the share of the projected box that the image edge cuts off. The kitti_3d export writes an imported object that nobody edited unchanged from the import. A shape with no occlusion attribute is written as 0. The occlusion values true and false count only as YAML booleans. The text True or False, which the CVAT importer produces, is written as 3 with a warning. Any other occlusion value Potato cannot read is written as 3 (unknown) and listed in the export's warnings. An unreadable truncation value is listed in the warnings as well.
Agreement over attributes
With two or more annotators per image, the agreement report at /admin/iaa adds one group per attribute to the scheme's report. The units are the objects that two or more annotators drew in the same place, and the values are what each annotator set. Two shapes of the same type on an image count as one object at a geometric similarity of 0.5 or more, measured as IoU for boxes and OKS for keypoint sets. The attribute report uses the same matching as the scheme's detection and classification agreement. On a point cloud, two 3D boxes count as one object at a 3D IoU of 0.25 or more. Two video tracks count as one object at 0.5 or more on a measure that combines overlap in time with box overlap. Each attribute type is scored as follows:
| Type | Krippendorff's alpha at |
|---|---|
select, bool | The nominal level |
number | The interval level |
multi | MASI distance between the checked sets |
text | Not scored |
Each group shows Krippendorff's alpha, the raw percent agreement beside the alpha, the number of matched objects, and the number of annotators. A shape that only one annotator drew, a shape whose label the attribute does not apply to, and a blank value contribute nothing. When every annotator gave the same value on every matched object, Krippendorff's alpha is undefined, and the table prints the reason in place of the number. A per_keyframe attribute is scored over object-frames. Each matched track adds one unit for each frame where an annotator's value changes, and the report marks the group unit: object-frame. Geometry agreement explains the matching and the detection and classification measures.
Limits
- Brush masks have no attribute panel. Masks imported with attributes keep the values.
- An imported attribute that the config does not declare stays on the shape and in the exports, but the panel shows only declared attributes. Declare an attribute with the imported name to edit the value.
per_keyframeapplies to video tracks and point-cloud sequences only. On an image scheme, each shape has one value per attribute.
Example project
examples/image/object-attributes/ in the Potato repository is a runnable project with the attributes from the config above and two annotators per image. From the repository root, run:
python potato/flask_server.py start examples/image/object-attributes/config.yaml -p 8000The server starts on port 8000 with three sample images, which the browser loads from picsum.photos, and /admin/iaa shows one group per attribute once two annotators have boxed the same objects.
Further reading
- Image annotation
- Bounding box, polygon, keypoint, and cuboid annotation
- Video tracking
- 3D point clouds and cuboids
- Computer vision formats
- Export formats
- Geometry agreement
For implementation details, see the source documentation.