def visualize_semantic(semantic, colormap=None, image=None, weight=0.5):
    """
    Visualize semantic segmentation results.

    Args:
        semantic (np.ndarray): The semantic segmenation results, whose shape is (h, w).
        colormap (np.ndarray, optional): The color map used for visualization. Default: None.
        image (np.ndarray, optional): The original input image. Merge the segmentation result 
            with `image` if it is provided. Default: None.
        weight (float, optional): The weight of original image when performing image merge. 
            Default: 0.5.
    """
    semantic = semantic.astype('uint8')
    if colormap is None:
        colormap = _COLORS * 255
    colored_semantic = colormap[semantic]
    if image is not None:
        colored_semantic = cv2.addWeighted(image, weight, colored_semantic,
                                           1 - weight, 0)
    return colored_semantic

    Visualize semantic segmentation results.

    Args:
        semantic (np.ndarray): The semantic segmenation results, whose shape is (h, w).
        colormap (np.ndarray, optional): The color map used for visualization. Default: None.
        image (np.ndarray, optional): The original input image. Merge the segmentation result 
            with `image` if it is provided. Default: None.
        weight (float, optional): The weight of original image when performing image merge. 
            Default: 0.5.
    
contrib/PanopticSeg/paddlepanseg/utils/visualize.py