detrium.nn.autobackend
Unified multi-backend inference engine (`AutoBackend`):
PyTorch (.pt / nn.Module), ONNXRuntime (.onnx), TensorRT (.engine / .plan), and OpenVINO (.xml).
class AutoBackend(nn.Module)
Unified inference wrapper across PyTorch, ONNXRuntime, TensorRT, and OpenVINO.
| 名称 | 类型 | 默认值 |
|---|
weights | Union[str, Path, nn.Module] | — |
device | Optional[Union[str, int, torch.device]] | None |
half | bool | False |
names | Optional[Mapping[int, str]] | None |
imgsz | Optional[Tuple[int, int]] | None |
task | str | 'detect' |
family | str | 'rtdetr' |
forward(self, images: torch.Tensor, orig_target_sizes: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]
| 名称 | 类型 | 默认值 |
|---|
images | torch.Tensor | — |
orig_target_sizes | torch.Tensor | — |
warmup(self, batch: int=1) -> None
select_device(device: Optional[Union[str, int, torch.device]]=None) -> torch.device
| 名称 | 类型 | 默认值 |
|---|
device | Optional[Union[str, int, torch.device]] | None |
sidecar_metadata_path(artifact_path: Union[str, Path]) -> Path
| 名称 | 类型 | 默认值 |
|---|
artifact_path | Union[str, Path] | — |
write_sidecar_metadata(artifact_path: Union[str, Path], meta: Mapping[str, Any]) -> Path
| 名称 | 类型 | 默认值 |
|---|
artifact_path | Union[str, Path] | — |
meta | Mapping[str, Any] | — |
read_sidecar_metadata(artifact_path: Union[str, Path]) -> Dict[str, Any]
| 名称 | 类型 | 默认值 |
|---|
artifact_path | Union[str, Path] | — |