# Path: detectron/utils/colormap.py
# def colormap(rgb=False):
#     color_list = np.array(
#         [
#             0.000, 0.447, 0.741,
#             0.850, 0.325, 0.098,
#             0.929, 0.694, 0.125,
#             0.494, 0.184, 0.556,
#             0.466, 0.674, 0.188,
#             0.301, 0.745, 0.933,
#             0.635, 0.078, 0.184,
#             0.300, 0.300, 0.300,
#             0.600, 0.600, 0.600,
#             1.000, 0.000, 0.000,
#             1.000, 0.500, 0.000,
#             0.749, 0.749, 0.000,
#             0.000, 1.000, 0.000,
#             0.000, 0.000, 1.000,
#             0.667, 0.000, 1.000,
#             0.333, 0.333, 0.000,
#             0.333, 0.667, 0.000,
#             0.333, 1.000, 0.000,
#             0.667, 0.333, 0.000,
#             0.667, 0.667, 0.000,
#             0.667, 1.000, 0.000,
#             1.000, 0.333, 0.000,
#             1.000, 0.667, 0.000,
#             1.000, 1.000, 0.000,
#             0.000, 0.333, 0.500,
#             0.000, 0.667, 0.500,
#             0.000, 1.000, 0.500,
#             0.333, 0.000, 0.500,
#             0.333, 0.333, 0.500,
#             0.333, 0.667, 0.500,
#             0.333, 1.000, 0.500,
#             0.667, 0.000, 0.500,
#             0.667, 0.333, 0.500,
#             0.667, 0.667, 0.500,
#             0.667, 1.000, 0.500,
#             1.000, 0.000, 0.500,
#             1.000, 0.333, 0.500,
#             1.000, 0.667, 0.500,
#             1.000, 1.000, 0.500,
#             0.000, 0.333, 1.000,
#             0.000, 0.667, 1.000,
#             0.000, 1.000, 1.000,
#             0.333, 0.000, 1.000,
#             0.333, 0.333, 1.000,
#             0.333, 0.667, 1.000,
#             0.333, 1.000, 1.000,
#             0.667, 0.000, 1.000,
#             0.667, 0.333, 1.000,
#             0.667, 0.667, 1.000,
#             0.667, 1.000, 1.000,
#             1.000, 0.000, 1.000,
#             1.000, 0.333, 1.000,
#             1.000, 0.667, 1.000,
#             0.167, 0.000, 0.000,
#             0.333, 0.000, 0.000,
#             0.500, 0.000, 0.000,
#             0.667, 0.000, 0.000,
#             0.833, 0.000, 0.000,
#             1.000, 0.000, 0.000,
#             0.000, 0.167, 0.000,
#             0.000, 0.333, 0.000,
#             0.000, 0.500, 0.000,
#             0.000, 0.667, 0.000,
#             0.000, 0.833, 0.000,
#             0.000, 1.000, 0.000,
#             0.000, 0.000, 0.167,
#             0.000, 0.000, 0.333,
#             0.000, 0.000, 0.500,
#             0.000, 0.000, 0.667,
#             0.000, 0.000, 0.833,
#             0.000, 0.000, 1.000,
#             0.000, 0.000, 0.000,
#             0.143, 0.143, 0.143,
#             0.286, 0.286, 0.286,
#             0.429, 0.429, 0.429,
#             0.571, 0.571, 0.571,
#             0.714, 0.714, 0.714,
#             0.857, 0.857, 0.857,
#             1.000, 1.000, 1.000
#         ]
#     ).astype(np.float32)
#     color_list = color_list.reshape((-1, 3)) * 255
#     if not rgb:
#         color_list = color_list[:, ::-1]
#     return color_list


import cv2
import numpy as np
import os
import pycocotools.mask as mask_util
import detectron.utils.env as envu
import detectron.utils.keypoints as keypoint_utils
import matplotlib.pyplot as plt
from detectron.utils.colormap import colormap
from matplotlib.patches import Polygon
            cv2.line(
                kp_mask, p1, p2,
                color=colors[l], thickness=2, lineType=cv2.LINE_AA)
        if kps[2, i1] > kp_thresh:
            cv2.circle(
                kp_mask, p1,
                radius=3, color=colors[l], thickness=-1, lineType=cv2.LINE_AA)
        if kps[2, i2] > kp_thresh:
            cv2.circle(
                kp_mask, p2,
                radius=3, color=colors[l], thickness=-1, lineType=cv2.LINE_AA)

    # Blend the keypoints.
    return cv2.addWeighted(img, 1.0 - alpha, kp_mask, alpha, 0)


def vis_one_image_opencv(
        im, boxes, segms=None, keypoints=None, thresh=0.9, kp_thresh=2,
        show_box=False, dataset=None, show_class=False):
    """Constructs a numpy array with the detections visualized."""

    if isinstance(boxes, list):
        boxes, segms, keypoints, classes = convert_from_cls_format(
            boxes, segms, keypoints)

    if boxes is None or boxes.shape[0] == 0 or max(boxes[:, 4]) < thresh:
        return im

    if segms is not None and len(segms) > 0:
        masks = mask_util.decode(segms)

# Path: detectron/utils/colormap.py
# def colormap(rgb=False):
#     color_list = np.array(
#         [
#             0.000, 0.447, 0.741,
#             0.850, 0.325, 0.098,
#             0.929, 0.694, 0.125,
#             0.494, 0.184, 0.556,
#             0.466, 0.674, 0.188,
#             0.301, 0.745, 0.933,
#             0.635, 0.078, 0.184,
#             0.300, 0.300, 0.300,
#             0.600, 0.600, 0.600,
#             1.000, 0.000, 0.000,
#             1.000, 0.500, 0.000,
#             0.749, 0.749, 0.000,
#             0.000, 1.000, 0.000,
#             0.000, 0.000, 1.000,
#             0.667, 0.000, 1.000,
#             0.333, 0.333, 0.000,
#             0.333, 0.667, 0.000,
#             0.333, 1.000, 0.000,
#             0.667, 0.333, 0.000,
#             0.667, 0.667, 0.000,
#             0.667, 1.000, 0.000,
#             1.000, 0.333, 0.000,
#             1.000, 0.667, 0.000,
#             1.000, 1.000, 0.000,
#             0.000, 0.333, 0.500,
#             0.000, 0.667, 0.500,
#             0.000, 1.000, 0.500,
#             0.333, 0.000, 0.500,
#             0.333, 0.333, 0.500,
#             0.333, 0.667, 0.500,
#             0.333, 1.000, 0.500,
#             0.667, 0.000, 0.500,
#             0.667, 0.333, 0.500,
#             0.667, 0.667, 0.500,
#             0.667, 1.000, 0.500,
#             1.000, 0.000, 0.500,
#             1.000, 0.333, 0.500,
#             1.000, 0.667, 0.500,
#             1.000, 1.000, 0.500,
#             0.000, 0.333, 1.000,
#             0.000, 0.667, 1.000,
#             0.000, 1.000, 1.000,
#             0.333, 0.000, 1.000,
#             0.333, 0.333, 1.000,
#             0.333, 0.667, 1.000,
#             0.333, 1.000, 1.000,
#             0.667, 0.000, 1.000,
#             0.667, 0.333, 1.000,
#             0.667, 0.667, 1.000,
#             0.667, 1.000, 1.000,
#             1.000, 0.000, 1.000,
#             1.000, 0.333, 1.000,
#             1.000, 0.667, 1.000,
#             0.167, 0.000, 0.000,
#             0.333, 0.000, 0.000,
#             0.500, 0.000, 0.000,
#             0.667, 0.000, 0.000,
#             0.833, 0.000, 0.000,
#             1.000, 0.000, 0.000,
#             0.000, 0.167, 0.000,
#             0.000, 0.333, 0.000,
#             0.000, 0.500, 0.000,
#             0.000, 0.667, 0.000,
#             0.000, 0.833, 0.000,
#             0.000, 1.000, 0.000,
#             0.000, 0.000, 0.167,
#             0.000, 0.000, 0.333,
#             0.000, 0.000, 0.500,
#             0.000, 0.000, 0.667,
#             0.000, 0.000, 0.833,
#             0.000, 0.000, 1.000,
#             0.000, 0.000, 0.000,
#             0.143, 0.143, 0.143,
#             0.286, 0.286, 0.286,
#             0.429, 0.429, 0.429,
#             0.571, 0.571, 0.571,
#             0.714, 0.714, 0.714,
#             0.857, 0.857, 0.857,
#             1.000, 1.000, 1.000
#         ]
#     ).astype(np.float32)
#     color_list = color_list.reshape((-1, 3)) * 255
#     if not rgb:
#         color_list = color_list[:, ::-1]
#     return color_list


# Path: detectron/utils/vis.py
import cv2
import numpy as np
import os
import pycocotools.mask as mask_util
import detectron.utils.env as envu
import detectron.utils.keypoints as keypoint_utils
import matplotlib.pyplot as plt
from detectron.utils.colormap import colormap
from matplotlib.patches import Polygon

            cv2.line(
                kp_mask, p1, p2,
                color=colors[l], thickness=2, lineType=cv2.LINE_AA)
        if kps[2, i1] > kp_thresh:
            cv2.circle(
                kp_mask, p1,
                radius=3, color=colors[l], thickness=-1, lineType=cv2.LINE_AA)
        if kps[2, i2] > kp_thresh:
            cv2.circle(
                kp_mask, p2,
                radius=3, color=colors[l], thickness=-1, lineType=cv2.LINE_AA)

    # Blend the keypoints.
    return cv2.addWeighted(img, 1.0 - alpha, kp_mask, alpha, 0)


def vis_one_image_opencv(
        im, boxes, segms=None, keypoints=None, thresh=0.9, kp_thresh=2,
        show_box=False, dataset=None, show_class=False):
    """Constructs a numpy array with the detections visualized."""

    if isinstance(boxes, list):
        boxes, segms, keypoints, classes = convert_from_cls_format(
            boxes, segms, keypoints)

    if boxes is None or boxes.shape[0] == 0 or max(boxes[:, 4]) < thresh:
        return im

    if segms is not None and len(segms) > 0:
        masks = mask_util.decode(segms)

        color_list = colormap()