Skip to content

Other Items for Tables

Following classes are sub items composed of each schema tables.

SampleData


FileFormat

Bases: str, Enum

An enum to represent file formats.

Attributes:

Name Type Description
JPG

JPG format for image data.

PNG

PNG format for image data.

PCD

PCD format for pointcloud data.

BIN

BIN format.

PCDBIN

PCD.BIN format for pointcloud data.

Source code in t4_devkit/schema/tables/sample_data.py
@unique
class FileFormat(str, Enum):
    """An enum to represent file formats.

    Attributes:
        JPG: JPG format for image data.
        PNG: PNG format for image data.
        PCD: PCD format for pointcloud data.
        BIN: BIN format.
        PCDBIN: PCD.BIN format for pointcloud data.
    """

    JPG = "jpg"
    PNG = "png"
    PCD = "pcd"
    BIN = "bin"
    PCDBIN = "pcd.bin"

    @staticmethod
    def is_member(item: str) -> bool:
        """Indicate whether the input item is the one of members of FileFormat.

        Args:
            item (str): Any file format name.

        Returns:
            Return True if the item is included.
        """
        return item in FileFormat.values()

    @staticmethod
    def values() -> list[str]:
        """Return a list of values of members.

        Returns:
            List of values.
        """
        return [v.value for v in FileFormat]

    def as_ext(self) -> str:
        """Return the value as file extension.

        Returns:
            File extension.
        """
        return f".{self.value}"

as_ext()

Return the value as file extension.

Returns:

Type Description
str

File extension.

Source code in t4_devkit/schema/tables/sample_data.py
def as_ext(self) -> str:
    """Return the value as file extension.

    Returns:
        File extension.
    """
    return f".{self.value}"

is_member(item) staticmethod

Indicate whether the input item is the one of members of FileFormat.

Parameters:

Name Type Description Default
item str

Any file format name.

required

Returns:

Type Description
bool

Return True if the item is included.

Source code in t4_devkit/schema/tables/sample_data.py
@staticmethod
def is_member(item: str) -> bool:
    """Indicate whether the input item is the one of members of FileFormat.

    Args:
        item (str): Any file format name.

    Returns:
        Return True if the item is included.
    """
    return item in FileFormat.values()

values() staticmethod

Return a list of values of members.

Returns:

Type Description
list[str]

List of values.

Source code in t4_devkit/schema/tables/sample_data.py
@staticmethod
def values() -> list[str]:
    """Return a list of values of members.

    Returns:
        List of values.
    """
    return [v.value for v in FileFormat]

SensorModality

Bases: str, Enum

An enum to represent sensor modalities.

Attributes:

Name Type Description
LIDAR

Lidar sensor.

CAMERA

Camera sensor.

RADAR

Radar sensor.

Source code in t4_devkit/schema/tables/sensor.py
@unique
class SensorModality(str, Enum):
    """An enum to represent sensor modalities.

    Attributes:
        LIDAR: Lidar sensor.
        CAMERA: Camera sensor.
        RADAR: Radar sensor.
    """

    LIDAR = "lidar"
    CAMERA = "camera"
    RADAR = "radar"

VisibilityLevel

Bases: str, Enum

An enum to represent visibility levels.

Attributes:

Name Type Description
FULL

No occlusion for the object.

MOST

Object is occluded, but by less than 50%.

PARTIAL

Object is occluded, but by more than 50%.

NONE

Object is 90-100% occluded and no points/pixels are visible in the label.

UNAVAILABLE

Visibility level is not specified.

Source code in t4_devkit/schema/tables/visibility.py
@unique
class VisibilityLevel(str, Enum):
    """An enum to represent visibility levels.

    Attributes:
        FULL: No occlusion for the object.
        MOST: Object is occluded, but by less than 50%.
        PARTIAL: Object is occluded, but by more than 50%.
        NONE: Object is 90-100% occluded and no points/pixels are visible in the label.
        UNAVAILABLE: Visibility level is not specified.
    """

    FULL = "full"
    MOST = "most"
    PARTIAL = "partial"
    NONE = "none"
    UNAVAILABLE = "unavailable"

    @classmethod
    def from_value(cls, level: str) -> Self:
        """Load member from its value."""
        if level not in cls.__members__.values():
            return cls._from_alias(level)
        return cls(level)

    @staticmethod
    def _from_alias(level: str) -> Self:
        """Load member from alias format of level.

        Args:
            level (str): Level of visibility.
        """
        if level == "v0-40":
            return VisibilityLevel.NONE
        elif level == "v40-60":
            return VisibilityLevel.PARTIAL
        elif level == "v60-80":
            return VisibilityLevel.MOST
        elif level == "v80-100":
            return VisibilityLevel.FULL
        else:
            warnings.warn(
                f"level: {level} is not supported, Visibility.UNAVAILABLE will be assigned."
            )
            return VisibilityLevel.UNAVAILABLE

    def rank(self) -> int:
        """Return an integer rank for comparison (higher is more visible)."""
        ranking = {
            "full": 4,
            "most": 3,
            "partial": 2,
            "none": 1,
            "unavailable": None,
        }
        return ranking[self.value]

    def is_comparable(self) -> bool:
        """Return True if the visibility level has a defined rank."""
        return self.rank() is not None

    def _check_comparability(self, other: VisibilityLevel) -> None:
        if not (self.is_comparable() and other.is_comparable()):
            raise ValueError(f"Cannot compare unknown visibility levels: {self}, {other}")

    def __lt__(self, other: VisibilityLevel) -> bool:
        self._check_comparability(other)
        return self.rank() < other.rank()

    def __le__(self, other: VisibilityLevel) -> bool:
        self._check_comparability(other)
        return self.rank() <= other.rank()

    def __gt__(self, other: VisibilityLevel) -> bool:
        self._check_comparability(other)
        return self.rank() > other.rank()

    def __ge__(self, other: VisibilityLevel) -> bool:
        self._check_comparability(other)
        return self.rank() >= other.rank()

from_value(level) classmethod

Load member from its value.

Source code in t4_devkit/schema/tables/visibility.py
@classmethod
def from_value(cls, level: str) -> Self:
    """Load member from its value."""
    if level not in cls.__members__.values():
        return cls._from_alias(level)
    return cls(level)

is_comparable()

Return True if the visibility level has a defined rank.

Source code in t4_devkit/schema/tables/visibility.py
def is_comparable(self) -> bool:
    """Return True if the visibility level has a defined rank."""
    return self.rank() is not None

rank()

Return an integer rank for comparison (higher is more visible).

Source code in t4_devkit/schema/tables/visibility.py
def rank(self) -> int:
    """Return an integer rank for comparison (higher is more visible)."""
    ranking = {
        "full": 4,
        "most": 3,
        "partial": 2,
        "none": 1,
        "unavailable": None,
    }
    return ranking[self.value]

RLEMask

A dataclass to represent segmentation mask compressed by RLE.

Attributes:

Name Type Description
size list[int, int]

Size of image ordering (width, height).

counts str

RLE compressed mask data.

Source code in t4_devkit/schema/tables/object_ann.py
@define
class RLEMask:
    """A dataclass to represent segmentation mask compressed by RLE.

    Attributes:
        size (list[int, int]): Size of image ordering (width, height).
        counts (str): RLE compressed mask data.
    """

    size: list[int, int] = field(validator=validators.deep_iterable(validators.instance_of(int)))
    counts: str = field(validator=validators.instance_of(str))

    @property
    def width(self) -> int:
        return self.size[0]

    @property
    def height(self) -> int:
        return self.size[1]

    def decode(self) -> NDArrayU8:
        """Decode segmentation mask.

        Returns:
            Decoded mask in shape of (H, W).
        """
        counts = base64.b64decode(self.counts)
        data = {"counts": counts, "size": self.size}
        return cocomask.decode(data)

decode()

Decode segmentation mask.

Returns:

Type Description
NDArrayU8

Decoded mask in shape of (H, W).

Source code in t4_devkit/schema/tables/object_ann.py
def decode(self) -> NDArrayU8:
    """Decode segmentation mask.

    Returns:
        Decoded mask in shape of (H, W).
    """
    counts = base64.b64decode(self.counts)
    data = {"counts": counts, "size": self.size}
    return cocomask.decode(data)

ShiftState

Bases: str, Enum

An enum to represent gear shift state.

Source code in t4_devkit/schema/tables/vehicle_state.py
@unique
class ShiftState(str, Enum):
    """An enum to represent gear shift state."""

    PARK = "PARK"
    REVERSE = "REVERSE"
    NEUTRAL = "NEUTRAL"
    HIGH = "HIGH"
    FORWARD = "FORWARD"
    LOW = "LOW"
    NONE = "NONE"

IndicatorState

Bases: str, Enum

An enum to represent indicator state.

Source code in t4_devkit/schema/tables/vehicle_state.py
@unique
class IndicatorState(str, Enum):
    """An enum to represent indicator state."""

    ON = "on"
    OFF = "off"

Indicators

A dataclass to represent state of each indicator.

Attributes:

Name Type Description
left IndicatorState

State of the left indicator.

right IndicatorState

State of the right indicator.

hazard IndicatorState

State of the hazard lights.

Source code in t4_devkit/schema/tables/vehicle_state.py
@define
class Indicators:
    """A dataclass to represent state of each indicator.

    Attributes:
        left (IndicatorState): State of the left indicator.
        right (IndicatorState): State of the right indicator.
        hazard (IndicatorState): State of the hazard lights.
    """

    left: IndicatorState = field(converter=IndicatorState)
    right: IndicatorState = field(converter=IndicatorState)
    hazard: IndicatorState = field(converter=IndicatorState)

AdditionalInfo

A dataclass to represent additional state information of the ego vehicle.

Attributes:

Name Type Description
speed float | None

Speed of the ego vehicle.

Source code in t4_devkit/schema/tables/vehicle_state.py
@define
class AdditionalInfo:
    """A dataclass to represent additional state information of the ego vehicle.

    Attributes:
        speed (float | None): Speed of the ego vehicle.
    """

    speed: float | None = field(
        default=None,
        validator=validators.optional(validators.instance_of(float)),
    )

AutolabelModel

A dataclass to represent a model used in autolabeling.

Attributes:

Name Type Description
name str

Name of the model used for annotation. Can include version information.

score float

Label score for the annotation from this model (range: 0.0–1.0).

uncertainty float | None

Model-reported uncertainty for the annotation (range: 0.0–1.0). Lower values imply higher confidence.

Source code in t4_devkit/schema/tables/autolabel_metadata.py
@define
class AutolabelModel:
    """A dataclass to represent a model used in autolabeling.

    Attributes:
        name (str): Name of the model used for annotation. Can include version information.
        score (float): Label score for the annotation from this model (range: 0.0–1.0).
        uncertainty (float | None, optional): Model-reported uncertainty for the annotation (range: 0.0–1.0).
            Lower values imply higher confidence.
    """

    name: str = field(validator=validators.instance_of(str))
    score: float = field(
        validator=[
            validators.instance_of(float),
            validators.and_(validators.ge(0.0), validators.le(1.0)),
        ]
    )
    uncertainty: float | None = field(
        default=None,
        validator=validators.optional(
            (validators.instance_of(float), validators.and_(validators.ge(0.0), validators.le(1.0)))
        ),
    )

    @staticmethod
    def to_autolabel_model(x: list[dict | AutolabelModel] | None) -> list[AutolabelModel] | None:
        """Convert input to a list of AutolabelModel instances.

        Args:
            x (list[dict | AutolabelModel] | None): Input to convert. Can be None, a list of dicts, or a list of AutolabelModel instances.

        Returns:
            list[AutolabelModel] | None: Converted list of AutolabelModel instances or None.
        """
        if x is None:
            return None
        if isinstance(x, list):
            return [AutolabelModel(**model) if isinstance(model, dict) else model for model in x]
        raise TypeError("Input must be None or a list of [dicts or AutolabelModel] instances.")

to_autolabel_model(x) staticmethod

Convert input to a list of AutolabelModel instances.

Parameters:

Name Type Description Default
x list[dict | AutolabelModel] | None

Input to convert. Can be None, a list of dicts, or a list of AutolabelModel instances.

required

Returns:

Type Description
list[AutolabelModel] | None

list[AutolabelModel] | None: Converted list of AutolabelModel instances or None.

Source code in t4_devkit/schema/tables/autolabel_metadata.py
@staticmethod
def to_autolabel_model(x: list[dict | AutolabelModel] | None) -> list[AutolabelModel] | None:
    """Convert input to a list of AutolabelModel instances.

    Args:
        x (list[dict | AutolabelModel] | None): Input to convert. Can be None, a list of dicts, or a list of AutolabelModel instances.

    Returns:
        list[AutolabelModel] | None: Converted list of AutolabelModel instances or None.
    """
    if x is None:
        return None
    if isinstance(x, list):
        return [AutolabelModel(**model) if isinstance(model, dict) else model for model in x]
    raise TypeError("Input must be None or a list of [dicts or AutolabelModel] instances.")

AutolabelMixin

Mixin class for schema tables that use autolabel metadata with automatic annotation.

Source code in t4_devkit/schema/tables/autolabel_metadata.py
@define(slots=False)
class AutolabelMixin:
    """Mixin class for schema tables that use autolabel metadata with automatic annotation."""

    automatic_annotation: bool = field(
        default=False, validator=validators.instance_of(bool), kw_only=True
    )
    autolabel_metadata: list[AutolabelModel] | None = field(
        default=None,
        converter=AutolabelModel.to_autolabel_model,
        validator=validators.optional(
            validators.deep_iterable(validators.instance_of(AutolabelModel))
        ),
        kw_only=True,
    )

    def __attrs_post_init__(self) -> None:
        """Post-initialization validation for autolabel consistency."""
        # if automatic_annotation=True, autolabel_metadata must exist
        if self.automatic_annotation and self.autolabel_metadata is None:
            raise TypeError("autolabel_metadata must be provided when automatic_annotation is True")
        # if automatic_annotation=False, autolabel_metadata must not exist
        if not self.automatic_annotation and self.autolabel_metadata is not None:
            raise TypeError("autolabel_metadata must be None when automatic_annotation is False")

__attrs_post_init__()

Post-initialization validation for autolabel consistency.

Source code in t4_devkit/schema/tables/autolabel_metadata.py
def __attrs_post_init__(self) -> None:
    """Post-initialization validation for autolabel consistency."""
    # if automatic_annotation=True, autolabel_metadata must exist
    if self.automatic_annotation and self.autolabel_metadata is None:
        raise TypeError("autolabel_metadata must be provided when automatic_annotation is True")
    # if automatic_annotation=False, autolabel_metadata must not exist
    if not self.automatic_annotation and self.autolabel_metadata is not None:
        raise TypeError("autolabel_metadata must be None when automatic_annotation is False")

Sensor


SensorModality

Bases: str, Enum

An enum to represent sensor modalities.

Attributes:

Name Type Description
LIDAR

Lidar sensor.

CAMERA

Camera sensor.

RADAR

Radar sensor.

Source code in t4_devkit/schema/tables/sensor.py
@unique
class SensorModality(str, Enum):
    """An enum to represent sensor modalities.

    Attributes:
        LIDAR: Lidar sensor.
        CAMERA: Camera sensor.
        RADAR: Radar sensor.
    """

    LIDAR = "lidar"
    CAMERA = "camera"
    RADAR = "radar"

ObjectAnn/SurfaceAnn


RLEMask

A dataclass to represent segmentation mask compressed by RLE.

Attributes:

Name Type Description
size list[int, int]

Size of image ordering (width, height).

counts str

RLE compressed mask data.

Source code in t4_devkit/schema/tables/object_ann.py
@define
class RLEMask:
    """A dataclass to represent segmentation mask compressed by RLE.

    Attributes:
        size (list[int, int]): Size of image ordering (width, height).
        counts (str): RLE compressed mask data.
    """

    size: list[int, int] = field(validator=validators.deep_iterable(validators.instance_of(int)))
    counts: str = field(validator=validators.instance_of(str))

    @property
    def width(self) -> int:
        return self.size[0]

    @property
    def height(self) -> int:
        return self.size[1]

    def decode(self) -> NDArrayU8:
        """Decode segmentation mask.

        Returns:
            Decoded mask in shape of (H, W).
        """
        counts = base64.b64decode(self.counts)
        data = {"counts": counts, "size": self.size}
        return cocomask.decode(data)

decode()

Decode segmentation mask.

Returns:

Type Description
NDArrayU8

Decoded mask in shape of (H, W).

Source code in t4_devkit/schema/tables/object_ann.py
def decode(self) -> NDArrayU8:
    """Decode segmentation mask.

    Returns:
        Decoded mask in shape of (H, W).
    """
    counts = base64.b64decode(self.counts)
    data = {"counts": counts, "size": self.size}
    return cocomask.decode(data)

Visibility


VisibilityLevel

Bases: str, Enum

An enum to represent visibility levels.

Attributes:

Name Type Description
FULL

No occlusion for the object.

MOST

Object is occluded, but by less than 50%.

PARTIAL

Object is occluded, but by more than 50%.

NONE

Object is 90-100% occluded and no points/pixels are visible in the label.

UNAVAILABLE

Visibility level is not specified.

Source code in t4_devkit/schema/tables/visibility.py
@unique
class VisibilityLevel(str, Enum):
    """An enum to represent visibility levels.

    Attributes:
        FULL: No occlusion for the object.
        MOST: Object is occluded, but by less than 50%.
        PARTIAL: Object is occluded, but by more than 50%.
        NONE: Object is 90-100% occluded and no points/pixels are visible in the label.
        UNAVAILABLE: Visibility level is not specified.
    """

    FULL = "full"
    MOST = "most"
    PARTIAL = "partial"
    NONE = "none"
    UNAVAILABLE = "unavailable"

    @classmethod
    def from_value(cls, level: str) -> Self:
        """Load member from its value."""
        if level not in cls.__members__.values():
            return cls._from_alias(level)
        return cls(level)

    @staticmethod
    def _from_alias(level: str) -> Self:
        """Load member from alias format of level.

        Args:
            level (str): Level of visibility.
        """
        if level == "v0-40":
            return VisibilityLevel.NONE
        elif level == "v40-60":
            return VisibilityLevel.PARTIAL
        elif level == "v60-80":
            return VisibilityLevel.MOST
        elif level == "v80-100":
            return VisibilityLevel.FULL
        else:
            warnings.warn(
                f"level: {level} is not supported, Visibility.UNAVAILABLE will be assigned."
            )
            return VisibilityLevel.UNAVAILABLE

    def rank(self) -> int:
        """Return an integer rank for comparison (higher is more visible)."""
        ranking = {
            "full": 4,
            "most": 3,
            "partial": 2,
            "none": 1,
            "unavailable": None,
        }
        return ranking[self.value]

    def is_comparable(self) -> bool:
        """Return True if the visibility level has a defined rank."""
        return self.rank() is not None

    def _check_comparability(self, other: VisibilityLevel) -> None:
        if not (self.is_comparable() and other.is_comparable()):
            raise ValueError(f"Cannot compare unknown visibility levels: {self}, {other}")

    def __lt__(self, other: VisibilityLevel) -> bool:
        self._check_comparability(other)
        return self.rank() < other.rank()

    def __le__(self, other: VisibilityLevel) -> bool:
        self._check_comparability(other)
        return self.rank() <= other.rank()

    def __gt__(self, other: VisibilityLevel) -> bool:
        self._check_comparability(other)
        return self.rank() > other.rank()

    def __ge__(self, other: VisibilityLevel) -> bool:
        self._check_comparability(other)
        return self.rank() >= other.rank()

from_value(level) classmethod

Load member from its value.

Source code in t4_devkit/schema/tables/visibility.py
@classmethod
def from_value(cls, level: str) -> Self:
    """Load member from its value."""
    if level not in cls.__members__.values():
        return cls._from_alias(level)
    return cls(level)

is_comparable()

Return True if the visibility level has a defined rank.

Source code in t4_devkit/schema/tables/visibility.py
def is_comparable(self) -> bool:
    """Return True if the visibility level has a defined rank."""
    return self.rank() is not None

rank()

Return an integer rank for comparison (higher is more visible).

Source code in t4_devkit/schema/tables/visibility.py
def rank(self) -> int:
    """Return an integer rank for comparison (higher is more visible)."""
    ranking = {
        "full": 4,
        "most": 3,
        "partial": 2,
        "none": 1,
        "unavailable": None,
    }
    return ranking[self.value]

VehicleState


ShiftState

Bases: str, Enum

An enum to represent gear shift state.

Source code in t4_devkit/schema/tables/vehicle_state.py
@unique
class ShiftState(str, Enum):
    """An enum to represent gear shift state."""

    PARK = "PARK"
    REVERSE = "REVERSE"
    NEUTRAL = "NEUTRAL"
    HIGH = "HIGH"
    FORWARD = "FORWARD"
    LOW = "LOW"
    NONE = "NONE"

IndicatorState

Bases: str, Enum

An enum to represent indicator state.

Source code in t4_devkit/schema/tables/vehicle_state.py
@unique
class IndicatorState(str, Enum):
    """An enum to represent indicator state."""

    ON = "on"
    OFF = "off"

Indicators

A dataclass to represent state of each indicator.

Attributes:

Name Type Description
left IndicatorState

State of the left indicator.

right IndicatorState

State of the right indicator.

hazard IndicatorState

State of the hazard lights.

Source code in t4_devkit/schema/tables/vehicle_state.py
@define
class Indicators:
    """A dataclass to represent state of each indicator.

    Attributes:
        left (IndicatorState): State of the left indicator.
        right (IndicatorState): State of the right indicator.
        hazard (IndicatorState): State of the hazard lights.
    """

    left: IndicatorState = field(converter=IndicatorState)
    right: IndicatorState = field(converter=IndicatorState)
    hazard: IndicatorState = field(converter=IndicatorState)

AdditionalInfo

A dataclass to represent additional state information of the ego vehicle.

Attributes:

Name Type Description
speed float | None

Speed of the ego vehicle.

Source code in t4_devkit/schema/tables/vehicle_state.py
@define
class AdditionalInfo:
    """A dataclass to represent additional state information of the ego vehicle.

    Attributes:
        speed (float | None): Speed of the ego vehicle.
    """

    speed: float | None = field(
        default=None,
        validator=validators.optional(validators.instance_of(float)),
    )