YOLOv5DetectionPipeline(runtime: ONNXRuntime, image_size: tuple[int, int] = (640, 640), stride: int = 32, conf_threshold: float = 0.25, iou_threshold: float = 0.45, class_names: dict[int, str] | None = None, batch_strategy: BatchStrategy[ndarray, tuple[ndarray, ...] | ndarray] | None = None)
Bases: YOLODetectionMixin, Pipeline[ndarray, tuple[ndarray, ...] | ndarray, list[DetectionOutput]]
YOLOv5 object detection pipeline (async ONNX version).
Source code in inferflow/asyncio/pipeline/detection/onnx.py
| def __init__(
self,
runtime: ONNXRuntime,
image_size: tuple[int, int] = (640, 640),
stride: int = 32,
conf_threshold: float = 0.25,
iou_threshold: float = 0.45,
class_names: dict[int, str] | None = None,
batch_strategy: BatchStrategy[np.ndarray, tuple[np.ndarray, ...] | np.ndarray] | None = None,
):
super().__init__(runtime=runtime, batch_strategy=batch_strategy)
self.image_size = image_size
self.stride = stride
self.conf_threshold = conf_threshold
self.iou_threshold = iou_threshold
self.class_names = class_names or {}
self._runtime = runtime
self._original_size = None
self._padding = None
|
Attributes
image_size instance-attribute
stride instance-attribute
conf_threshold instance-attribute
conf_threshold = conf_threshold
iou_threshold instance-attribute
iou_threshold = iou_threshold
class_names instance-attribute
class_names = class_names or {}
Functions
preprocess async
Preprocess image input (async).
Source code in inferflow/asyncio/pipeline/detection/onnx.py
| async def preprocess(self, input: ImageInput) -> np.ndarray:
"""Preprocess image input (async)."""
image = self._convert_to_numpy(input)
return self._preprocess_numpy(image)
|
postprocess async
Postprocess YOLOv5 output (async).
Source code in inferflow/asyncio/pipeline/detection/onnx.py
| async def postprocess(self, raw: tuple[np.ndarray, ...] | np.ndarray) -> list[DetectionOutput]:
"""Postprocess YOLOv5 output (async)."""
predictions = raw if isinstance(raw, np.ndarray) else raw[0]
return self._postprocess_detections(predictions)
|