Skip to content

yolov7_instance_segmentation

YOLOv7InstanceSegmentation

Bases: InstanceSegmentationBaseOnnxRoboflowInferenceModel

YOLOv7 Instance Segmentation ONNX Inference Model.

This class is responsible for performing instance segmentation using the YOLOv7 model with ONNX runtime.

Methods:

Name Description
predict

Performs inference on the given image using the ONNX session.

Source code in inference/models/yolov7/yolov7_instance_segmentation.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class YOLOv7InstanceSegmentation(InstanceSegmentationBaseOnnxRoboflowInferenceModel):
    """YOLOv7 Instance Segmentation ONNX Inference Model.

    This class is responsible for performing instance segmentation using the YOLOv7 model
    with ONNX runtime.

    Methods:
        predict: Performs inference on the given image using the ONNX session.
    """

    def predict(self, img_in: np.ndarray, **kwargs) -> Tuple[np.ndarray, np.ndarray]:
        """Performs inference on the given image using the ONNX session.

        Args:
            img_in (np.ndarray): Input image as a NumPy array.

        Returns:
            Tuple[np.ndarray, np.ndarray]: Tuple containing two NumPy arrays representing the predictions and protos.
        """
        predictions = self.onnx_session.run(None, {self.input_name: img_in})
        protos = predictions[4]
        predictions = predictions[0]
        return predictions, protos

predict(img_in, **kwargs)

Performs inference on the given image using the ONNX session.

Parameters:

Name Type Description Default
img_in ndarray

Input image as a NumPy array.

required

Returns:

Type Description
Tuple[ndarray, ndarray]

Tuple[np.ndarray, np.ndarray]: Tuple containing two NumPy arrays representing the predictions and protos.

Source code in inference/models/yolov7/yolov7_instance_segmentation.py
20
21
22
23
24
25
26
27
28
29
30
31
32
def predict(self, img_in: np.ndarray, **kwargs) -> Tuple[np.ndarray, np.ndarray]:
    """Performs inference on the given image using the ONNX session.

    Args:
        img_in (np.ndarray): Input image as a NumPy array.

    Returns:
        Tuple[np.ndarray, np.ndarray]: Tuple containing two NumPy arrays representing the predictions and protos.
    """
    predictions = self.onnx_session.run(None, {self.input_name: img_in})
    protos = predictions[4]
    predictions = predictions[0]
    return predictions, protos