turicreate.object_detector.util.unstack_annotations

turicreate.object_detector.util.unstack_annotations(annotations_sframe, num_rows=None)

Converts object detection annotations (ground truth or predictions) to unstacked format (an SArray where each element is a list of object instances).

Parameters:
annotations_sframe: SFrame

An SFrame with stacked predictions, produced by the stack_annotations function.

num_rows: int

Optionally specify the number of rows in your original dataset, so that all get represented in the unstacked format, regardless of whether or not they had instances or not.

Returns:
annotations_sarray: An SArray with unstacked annotations.

Examples

If you have annotations in stacked format:

>>> stacked_predictions
Data:
+--------+------------+-------+-------+-------+-------+--------+
| row_id | confidence | label |   x   |   y   | width | height |
+--------+------------+-------+-------+-------+-------+--------+
|   0    |    0.98    |  dog  | 123.0 | 128.0 |  80.0 | 182.0  |
|   0    |    0.67    |  cat  | 150.0 | 183.0 | 129.0 | 101.0  |
|   1    |    0.8     |  dog  |  50.0 | 432.0 |  65.0 |  98.0  |
+--------+------------+-------+-------+-------+-------+--------+
[3 rows x 7 columns]

They can be converted to unstacked format using this function:

>>> turicreate.object_detector.util.unstack_annotations(stacked_predictions)[0]
[{'confidence': 0.98,
  'coordinates': {'height': 182.0, 'width': 80.0, 'x': 123.0, 'y': 128.0},
  'label': 'dog',
  'type': 'rectangle'},
 {'confidence': 0.67,
  'coordinates': {'height': 101.0, 'width': 129.0, 'x': 150.0, 'y': 183.0},
  'label': 'cat',
  'type': 'rectangle'}]