Skip to content

onnx

onnx

Attributes

__all__ module-attribute

__all__ = ['YOLOv5SegmentationPipeline']

Classes

YOLOv5SegmentationPipeline

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 (async ONNX version).

Source code in inferflow/asyncio/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
image_size = image_size
stride instance-attribute
stride = stride
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(input: ImageInput) -> ndarray

Preprocess image for YOLOv5-Seg (async).

Source code in inferflow/asyncio/pipeline/segmentation/onnx.py
async def preprocess(self, input: ImageInput) -> np.ndarray:
    """Preprocess image for YOLOv5-Seg (async)."""
    image = self._convert_to_numpy(input)
    return self._preprocess_numpy(image)
postprocess async
postprocess(raw: tuple[ndarray, ndarray]) -> list[SegmentationOutput]

Postprocess YOLOv5-Seg output (async).

Source code in inferflow/asyncio/pipeline/segmentation/onnx.py
async def postprocess(self, raw: tuple[np.ndarray, np.ndarray]) -> list[SegmentationOutput]:
    """Postprocess YOLOv5-Seg output (async)."""
    detections, protos = raw
    return self._postprocess_segmentation(detections, protos)