YOLOv5SegmentationPipeline(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: YOLOSegmentationMixin, Pipeline[ndarray, tuple[ndarray, ndarray], list[SegmentationOutput]]
YOLOv5 instance segmentation pipeline (ONNX version).
Source code in inferflow/pipeline/segmentation/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
Preprocess image for YOLOv5-Seg.
Source code in inferflow/pipeline/segmentation/onnx.py
| def preprocess(self, input: ImageInput) -> np.ndarray:
"""Preprocess image for YOLOv5-Seg."""
image = self._convert_to_numpy(input)
return self._preprocess_numpy(image)
|
postprocess
Postprocess YOLOv5-Seg output.
Source code in inferflow/pipeline/segmentation/onnx.py
| def postprocess(self, raw: tuple[np.ndarray, np.ndarray]) -> list[SegmentationOutput]:
"""Postprocess YOLOv5-Seg output."""
detections, protos = raw
return self._postprocess_segmentation(detections, protos)
|