Skip to content

Commit

Permalink
feat: add JSONAttributes
Browse files Browse the repository at this point in the history
  • Loading branch information
unexcellent committed Oct 31, 2024
1 parent 2df4b77 commit ee79bca
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 0 deletions.
24 changes: 24 additions & 0 deletions raillabel/json_format/attributes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright DB InfraGO AG and contributors
# SPDX-License-Identifier: Apache-2.0

from __future__ import annotations

from pydantic import BaseModel

from .boolean_attribute import JSONBooleanAttribute
from .num_attribute import JSONNumAttribute
from .text_attribute import JSONTextAttribute
from .vec_attribute import JSONVecAttribute


class JSONAttributes(BaseModel):
"""Attributes is the alias of element data that can be nested inside geometric object data.
For example, a certain bounding box can have attributes related to its score, visibility, etc.
These values can be nested inside the bounding box as attributes.
"""

boolean: list[JSONBooleanAttribute] | None
num: list[JSONNumAttribute] | None
text: list[JSONTextAttribute] | None
vec: list[JSONVecAttribute] | None
17 changes: 17 additions & 0 deletions raillabel/json_format/boolean_attribute.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright DB InfraGO AG and contributors
# SPDX-License-Identifier: Apache-2.0

from __future__ import annotations

from pydantic import BaseModel


class JSONBooleanAttribute(BaseModel):
"""A boolean attribute."""

name: str | None
"""Friendly identifier describing the attribute. Used to track the attribute throughout
annotations and frames."""

val: bool
"The boolean value."
17 changes: 17 additions & 0 deletions raillabel/json_format/num_attribute.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright DB InfraGO AG and contributors
# SPDX-License-Identifier: Apache-2.0

from __future__ import annotations

from pydantic import BaseModel


class JSONNumAttribute(BaseModel):
"""A number attribute."""

name: str | None
"""Friendly identifier describing the attribute. Used to track the attribute throughout
annotations and frames."""

val: int | float
"The number value."
17 changes: 17 additions & 0 deletions raillabel/json_format/text_attribute.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright DB InfraGO AG and contributors
# SPDX-License-Identifier: Apache-2.0

from __future__ import annotations

from pydantic import BaseModel


class JSONTextAttribute(BaseModel):
"""A text attribute."""

name: str | None
"""Friendly identifier describing the attribute. Used to track the attribute throughout
annotations and frames."""

val: str
"The text value."
17 changes: 17 additions & 0 deletions raillabel/json_format/vec_attribute.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright DB InfraGO AG and contributors
# SPDX-License-Identifier: Apache-2.0

from __future__ import annotations

from pydantic import BaseModel


class JSONVecAttribute(BaseModel):
"""A vec attribute."""

name: str | None
"""Friendly identifier describing the attribute. Used to track the attribute throughout
annotations and frames."""

val: list[int | float | str]
"The value vector of the attribute."

0 comments on commit ee79bca

Please sign in to comment.