def get_instance_segmentation(semantic,
                              ctr_hmp,
                              offset,
                              thing_list,
                              threshold=0.1,
                              nms_kernel=3,
                              top_k=None):
    """
    Post-processing for instance segmentation, gets class agnostic instance id map.

    Args:
        semantic (Tensor): A Tensor of shape [1, H, W], predicted semantic label.
        ctr_hmp (Tensor): A Tensor of shape [1, H, W] of raw center heatmap output, where N is the batch size,
            for consistent, we only support N=1.
        offsets (Tensor): A Tensor of shape [2, H, W] of raw offset output, where N is the batch size,
            for consistent, we only support N=1. The order of second dim is (offset_y, offset_x).
        thing_list (list): A List of thing class id.
        threshold (float, optional): A Float, threshold applied to center heatmap score. Default: 0.1.
        nms_kernel (int, optional): An Integer, NMS max pooling kernel size. Default: 3.
        top_k (int, optional): An Integer, top k centers to keep. Default: None.

    Returns:
        Tensor: Instance segmentation results which shape is [1, H, W].
        Tensor: A Tensor of shape [1, K, 2] where K is the number of center points. The order of second dim is (y, x).
    """
    thing_seg = paddle.zeros_like(semantic)
    for thing_class in thing_list:
        thing_seg = thing_seg + (semantic == thing_class).astype('int64')
    thing_seg = (thing_seg > 0).astype('int64')
    center = find_instance_center(
        ctr_hmp, threshold=threshold, nms_kernel=nms_kernel, top_k=top_k)
    if center is None:
        return paddle.zeros_like(semantic), center
    ins_seg = group_pixels(center, offset)
    return thing_seg * ins_seg, center.unsqueeze(0)

    Post-processing for instance segmentation, gets class agnostic instance id map.

    Args:
        semantic (Tensor): A Tensor of shape [1, H, W], predicted semantic label.
        ctr_hmp (Tensor): A Tensor of shape [1, H, W] of raw center heatmap output, where N is the batch size,
            for consistent, we only support N=1.
        offsets (Tensor): A Tensor of shape [2, H, W] of raw offset output, where N is the batch size,
            for consistent, we only support N=1. The order of second dim is (offset_y, offset_x).
        thing_list (list): A List of thing class id.
        threshold (float, optional): A Float, threshold applied to center heatmap score. Default: 0.1.
        nms_kernel (int, optional): An Integer, NMS max pooling kernel size. Default: 3.
        top_k (int, optional): An Integer, top k centers to keep. Default: None.

    Returns:
        Tensor: Instance segmentation results which shape is [1, H, W].
        Tensor: A Tensor of shape [1, K, 2] where K is the number of center points. The order of second dim is (y, x).
    
contrib/PanopticDeepLab/core/infer.py