detrium.core.results
Unified Results object and task-specific prediction containers for all 6 Detrium tasks.
Tasks supported by contract:
- detect -> Results.boxes (Boxes)
- segment -> Results.boxes (Boxes) + Results.masks (Masks)
- semseg -> Results.semseg (SemSeg)
- pose -> Results.boxes (Boxes) + Results.keypoints (Keypoints)
- classify -> Results.probs (Probs)
- obb -> Results.obb (OBB)
class Boxes(_BaseDataContainer)
Axis-aligned 2D bounding boxes container.
Internal `data` layout: shape `(N, 6)` with columns `[x1, y1, x2, y2, conf, cls]`.
| 名称 | 类型 | 默认值 |
|---|
data | TensorOrArray | — |
orig_shape | Tuple[int, int] | — |
from_xyxy_conf_cls(cls, boxes_xyxy: TensorOrArray, scores: TensorOrArray, labels: TensorOrArray, orig_shape: Tuple[int, int]) -> 'Boxes'
| 名称 | 类型 | 默认值 |
|---|
boxes_xyxy | TensorOrArray | — |
scores | TensorOrArray | — |
labels | TensorOrArray | — |
orig_shape | Tuple[int, int] | — |
xyxy(self) -> torch.Tensor
conf(self) -> torch.Tensor
cls(self) -> torch.Tensor
xywh(self) -> torch.Tensor
xyxyn(self) -> torch.Tensor
xywhn(self) -> torch.Tensor
class Masks(_BaseDataContainer)
Instance segmentation binary/soft masks container (`segment` task).
Internal `data` layout: shape `(N, H, W)`.
| 名称 | 类型 | 默认值 |
|---|
data | TensorOrArray | — |
orig_shape | Tuple[int, int] | — |
class SemSeg(_BaseDataContainer)
Semantic segmentation dense pixel map container (`semseg` task).
Internal `data` layout: integer class map `(H, W)` (optional logits/probs `(C, H, W)`).
| 名称 | 类型 | 默认值 |
|---|
class_map | TensorOrArray | — |
orig_shape | Tuple[int, int] | — |
probs | Optional[TensorOrArray] | None |
class_map(self) -> torch.Tensor
cpu(self) -> 'SemSeg'
class Keypoints(_BaseDataContainer)
Pose estimation keypoints container (`pose` task).
Internal `data` layout: shape `(N, K, 2)` or `(N, K, 3)` where dim -1 is `(x, y[, conf])`.
| 名称 | 类型 | 默认值 |
|---|
data | TensorOrArray | — |
orig_shape | Tuple[int, int] | — |
xy(self) -> torch.Tensor
conf(self) -> Optional[torch.Tensor]
xyn(self) -> torch.Tensor
class Probs(_BaseDataContainer)
Image classification probability vector container (`classify` task).
Internal `data` layout: 1D probability tensor `(C,)`.
| 名称 | 类型 | 默认值 |
|---|
data | TensorOrArray | — |
orig_shape | Tuple[int, int] | (0, 0) |
top1(self) -> int
top1conf(self) -> float
top5(self) -> List[int]
top5conf(self) -> List[float]
class OBB(_BaseDataContainer)
Oriented bounding boxes container (`obb` task).
Internal `data` layout: shape `(N, 7)` with columns `[cx, cy, w, h, angle_rad, conf, cls]`.
| 名称 | 类型 | 默认值 |
|---|
data | TensorOrArray | — |
orig_shape | Tuple[int, int] | — |
xywhr(self) -> torch.Tensor
conf(self) -> torch.Tensor
cls(self) -> torch.Tensor
xyxyxyxy(self) -> torch.Tensor
Convert `(cx, cy, w, h, angle_rad)` to 4-corner polygon coordinates `(N, 4, 2)`.
class Results
Unified per-image inference result across all 6 Detrium vision tasks.
字段
| 名称 | 类型 | 默认值 |
|---|
orig_img | Optional[np.ndarray] | — |
orig_shape | Tuple[int, int] | — |
names | Dict[int, str] | — |
task | str | 'detect' |
path | Optional[str] | None |
speed | Dict[str, float] | field(default_factory=lambda : {'preprocess': 0.0, 'inference': 0.0, 'postprocess': 0.0}) |
boxes | Optional[Boxes] | None |
masks | Optional[Masks] | None |
semseg | Optional[SemSeg] | None |
keypoints | Optional[Keypoints] | None |
probs | Optional[Probs] | None |
obb | Optional[OBB] | None |
cpu(self) -> 'Results'
summary(self) -> List[Dict[str, Any]]
Return a JSON-serializable summary list of predictions.
to_json(self, indent: int=2) -> str
to_df(self)
Return predictions as a pandas DataFrame (requires pandas).
plot(self, *, conf: bool=True, labels: bool=True, line_width: Optional[int]=None) -> np.ndarray
Render predictions onto `orig_img` and return an RGB uint8 numpy array.
| 名称 | 类型 | 默认值 |
|---|
conf | bool | True |
labels | bool | True |
line_width | Optional[int] | None |
save(self, filename: Union[str, Path], **plot_kwargs: Any) -> Path
Save the annotated image to `filename`.
| 名称 | 类型 | 默认值 |
|---|
filename | Union[str, Path] | — |
plot_kwargs | Any | — |
show(self, **plot_kwargs: Any) -> None