(self, image, predictions)
return composite
Adds the instances contours for each predicted object.
        Each label has a different color.

        Arguments:
            image (np.ndarray): an image as returned by OpenCV
            predictions (BoxList): the result of the computation by the model.
                It should contain the field `mask` and `labels`.
Adds the instances contours for each predicted object.
        Each label has a different color.
Adds the instances contours for each predicted object . Each label has a different color .
def overlay_mask(self, image, predictions):
        """
        Adds the instances contours for each predicted object.
        Each label has a different color.

        Arguments:
            image (np.ndarray): an image as returned by OpenCV
            predictions (BoxList): the result of the computation by the model.
                It should contain the field `mask` and `labels`.
        """
        masks = predictions.get_field("mask").numpy()
        labels = predictions.get_field("labels")

        colors = self.compute_colors_for_labels(labels).tolist()

        for mask, color in zip(masks, colors):
            thresh = mask[0, :, :, None]
            contours, hierarchy = cv2_util.findContours(
                thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE
            )
            image = cv2.drawContours(image, contours, -1, color, 3)

        composite = image

        return composite
def overlay_mask ( self , image , predictions ) : masks = predictions . get_field ( "mask" ) . numpy ( ) labels = predictions . get_field ( "labels" ) colors = self . compute_colors_for_labels ( labels ) . tolist ( ) for mask , color in zip ( masks , colors ) : thresh = mask [ 0 , : , : , None ] contours , hierarchy = cv2_util . findContours ( thresh , cv2 . RETR_TREE , cv2 . CHAIN_APPROX_SIMPLE ) image = cv2 . drawContours ( image , contours , - 1 , color , 3 ) composite = image return composite