Skip to content

bbox

Bbox related features.

Classes:

Name Description
BboxFeature

Feature representing a bounding box.

BoundingBoxesFeature

Feature representing a list of bounding boxes within a single image.

BboxFeature #

Feature representing a bounding box.

This feature represents a single bbox in YOLO format for object detection tasks described by positional coordinates, class category, and detection score.

Bounding boxes follow the YOLO format, where each box is parameterized by: - center_x and center_y: normalized coordinates of the box center within the image. - width and height: normalized dimensions of the box. - class: category index or label of the detected object. - score: confidence score associated with the detection.

Parameters:

Name Type Description Default

categories #

list[int] or list[str]

List of category identifiers or labels corresponding to the possible object classes.

required
Notes
  • This feature is mostly meant to be used through BoundingBoxesFeature

Methods:

Name Description
to_model

Convert to a ListFeatureTypeInput instance.

from_model

Instantiate from a json response.

Attributes:

Name Type Description
categories list[int] | list[str]
name Literal['BBOX']

categories: list[int] | list[str] #

name: Literal['BBOX'] = 'BBOX' #

to_model() -> BBoxFeatureType #

Convert to a ListFeatureTypeInput instance.

Returns:

Type Description
ListFeatureTypeInput

Model-level representation of the bounding boxes feature, including the serialized box structure and category information.

Source code in src/xpdeep/dataset/feature/feature_types/bbox.py
def to_model(self) -> BBoxFeatureType:
    """Convert to a ``ListFeatureTypeInput`` instance.

    Returns
    -------
    ListFeatureTypeInput
        Model-level representation of the bounding boxes feature, including
        the serialized box structure and category information.
    """
    return BBoxFeatureType(
        name=self.name,
        size=[0, 0],
        categories=self.categories,
        channel_names=["class", "center_x", "center_y", "width", "height", "score"],
    )

from_model(feature_type_input: BBoxFeatureType) -> BboxFeature #

Instantiate from a json response.

Source code in src/xpdeep/dataset/feature/feature_types/bbox.py
@staticmethod
def from_model(feature_type_input: BBoxFeatureType) -> BboxFeature:
    """Instantiate from a json response."""
    return BboxFeature(categories=feature_type_input.categories)

BoundingBoxesFeature #

Feature representing a list of bounding boxes within a single image.

This feature encodes object detections as a collection of bounding boxes, each described by positional coordinates, class category, and detection score. It provides a structured way to represent outputs from object detection models or annotated datasets.

Bounding boxes follow the YOLO format, where each box is parameterized by: - center_x and center_y: normalized coordinates of the box center within the image. - width and height: normalized dimensions of the box. - class: category index or label of the detected object. - score: confidence score associated with the detection.

Parameters:

Name Type Description Default

categories #

list[int] or list[str]

List of category identifiers or labels corresponding to the possible object classes.

required
Notes
  • Bounding boxes are represented as a list of homogeneous sub-features.
  • This feature is typically used to represent detections within a single image or frame.
  • Current limitation: Xpdeep does not yet support variable numbers of detections per instance. Please pad bounding box lists to a uniform length before using this feature.

Attributes:

Name Type Description
items str

Methods:

Name Description
__attrs_post_init__

Update categories.

categories: list[int] | list[str] #

items: BboxFeature = attrs.field(init=False) #

__attrs_post_init__() -> None #

Update categories.

Source code in src/xpdeep/dataset/feature/feature_types/bbox.py
def __attrs_post_init__(self) -> None:
    """Update categories."""
    self.items = BboxFeature(categories=self.categories)