Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/schema/table.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
| `enum[X,Y,...]` | Enumerated type with possible values X, Y, ... |
| `[T;N]` | Array of N elements of type T |
| `[T;N,M,...]` | Array of type T with N, M, or other specified number of elements |
| `option[T]` | Optional value of type T |
| `option[T]` | Optional value of type T by default `None` |

### Special Types

Expand Down Expand Up @@ -382,7 +382,9 @@ surface_ann {
"token": <str> -- Unique record identifier.
"sample_data_token": <str> -- Foreign key to the `SampleData` table associated with the sample data.
"category_token": <str> -- Foreign key to the `Category` table associated with the category of the surface.
"mask": <RLE> -- Run length encoding of instance mask.
"instance_token": <option[str]> -- Foreign key to the `Instance` table associated with the instance of the surface.
"attribute_tokens": <list[str]> -- Foreign keys to the `Attribute` table associated with the attributes of the surface. Defaults to `[]`.
"mask": <option[RLE]> -- Run length encoding of instance mask.
"automatic_annotation": <bool> -- Whether the annotation was automatically generated. Defaults to `false`.
"autolabel_metadata": <option[[AutolabelModel;N]]> -- List of models used for autolabeling. Required if `automatic_annotation` is `true`.
}
Expand Down
16 changes: 15 additions & 1 deletion t4_devkit/schema/tables/surface_ann.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ class SurfaceAnn(SchemaBase, AutolabelMixin):
token (str): Unique record identifier.
sample_data_token (str): Foreign key pointing to the sample data, which must be a keyframe image.
category_token (str): Foreign key pointing to the surface category.
mask (RLEMask): Segmentation mask using the COCO format compressed by RLE.
instance_token (str | None, optional): Foreign key pointing to the instance category.
attribute_tokens (list[str], optional): Foreign keys pointing to the attribute categories.
mask (RLEMask | None, optional): Segmentation mask using the COCO format compressed by RLE.

Inherited from AutolabelMixin:
automatic_annotation (bool, optional): Indicates if the annotation is fully generated by an ML model.
Expand All @@ -37,6 +39,18 @@ class SurfaceAnn(SchemaBase, AutolabelMixin):

sample_data_token: str = field(validator=(validators.instance_of(str), impossible_empty()))
category_token: str = field(validator=(validators.instance_of(str), impossible_empty()))
instance_token: str | None = field(
default=None,
validator=validators.optional(
validators.and_(validators.instance_of(str), impossible_empty())
),
)
attribute_tokens: list[str] = field(
factory=list,
validator=validators.deep_iterable(
validators.and_(validators.instance_of(str), impossible_empty())
),
)
mask: RLEMask | None = field(
default=None,
converter=lambda x: RLEMask(**x) if isinstance(x, dict) else x,
Expand Down
2 changes: 2 additions & 0 deletions tests/schema/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ def surface_ann_dict() -> dict:
"token": "4230e00708fb3f404d246ea97716f848",
"sample_data_token": "a1d3257e11ec9d4a587ea7053b33f1c1",
"category_token": "7864884179fb37bf9e973016b13a332c",
"instance_token": None,
"attribute_tokens": [],
"mask": {"size": [1920, 1280], "counts": "UFBQWzI='"},
"automatic_annotation": False,
"autolabel_metadata": None,
Expand Down
Loading