LeapImageWithBBox

code_loader.contract.visualizer_classes.LeapImageWithBBox

Used to visualize an image overlayed with bounding boxes

import numpy.typing as npt
from code_loader.contract.enums import LeapDataType

@dataclass
class BoundingBox:
    x: float
    y: float
    width: float
    height: float
    confidence: float
    label: str
    rotation: float = 0.0
    metadata: Optional[Dict[str, Union[str, int, float]]] = None

@dataclass
class LeapImageWithBBox:
    data: Union[npt.NDArray[np.float32], npt.NDArray[np.uint8]]
    bounding_boxes: List[BoundingBox]
    type: LeapDataType = LeapDataType.ImageWithBBox
Args

data

an np.ndarray uint8/float32 representation of the image. The expected image format is [H,W,1] OR [H,W,3] and is expected to be in [0,255].

bounding_boxes

A list of bounding box. Each bounding_box has the following attributes:

  • x - x center of the bounding box. Expected to be between [0,1]

  • y - y center of the bounding box. Expected to be between [0,1]

  • width - width of the bounding box. Expected to be between [0,1]

  • height - height of the bounding box. Expected to be between [0,1]

  • confidence - the confidence of the prediction. Expected to be between [0,1]. Ground Truth should be set to 1.

  • label - a str label of the prediction

  • rotation - a float between [0,360] that represents the degree of roation. Defaults to 0.

  • metadata (optional) - a metadata on the bounding box. A dictionary of property names (str) to their values (str/int/float)

Examples

Basic Usage

Last updated

Was this helpful?