Skip to content
Edit this page

Detections

Detections dataclass

Detections(
    boxes: Tensor,
    scores: Tensor,
    labels: Tensor,
    image_size: tuple[int, int],
    names: Mapping[int, str] | None = None,
)

Fused detections for one image. Tensors stay on the device they were computed on.

boxes instance-attribute

boxes: Tensor

[N, 4] float32 xyxy in image pixels.

scores instance-attribute

scores: Tensor

[N] float32.

labels instance-attribute

labels: Tensor

[N] int64 class ids as returned by the detector.

image_size instance-attribute

image_size: tuple[int, int]

(width, height) of the source image.

names class-attribute instance-attribute

names: Mapping[int, str] | None = None

Optional class id → name map (filled by :func:easi.predict).

to_coco

to_coco(
    image_id: int = 0, category_ids: Mapping[int, int] | None = None
) -> list[dict[str, Any]]

COCO-style results: {"image_id", "category_id", "bbox": [x, y, w, h], "score"}.

Parameters:

Name Type Description Default
image_id int

Value for every entry's image_id.

0
category_ids Mapping[int, int] | None

Optional map from detector label to COCO category id.

None

to_supervision

to_supervision(class_names: Mapping[int, str] | None = None) -> Any

Convert to supervision.Detections (requires pip install supervision); class_names defaults to :attr:names.