def paste_mask(self, masks, boxes, im_h, im_w):
    '\n        Paste the mask prediction to the original image.\n        '
    (x0, y0, x1, y1) = paddle.split(boxes, 4, axis=1)
    masks = paddle.unsqueeze(masks, [0, 1])
    img_y = (paddle.arange(0, im_h, dtype='float32') + 0.5)
    img_x = (paddle.arange(0, im_w, dtype='float32') + 0.5)
    img_y = ((((img_y - y0) / (y1 - y0)) * 2) - 1)
    img_x = ((((img_x - x0) / (x1 - x0)) * 2) - 1)
    img_x = paddle.unsqueeze(img_x, [1])
    img_y = paddle.unsqueeze(img_y, [2])
    N = boxes.shape[0]
    gx = paddle.expand(img_x, [N, img_y.shape[1], img_x.shape[2]])
    gy = paddle.expand(img_y, [N, img_y.shape[1], img_x.shape[2]])
    grid = paddle.stack([gx, gy], axis=3)
    img_masks = F.grid_sample(masks, grid, align_corners=False)
    return img_masks[:, 0]
Paste the mask prediction to the original image.
def paste_mask(self, masks, boxes, im_h, im_w):
    '\n        \n        '
    (x0, y0, x1, y1) = paddle.split(boxes, 4, axis=1)
    masks = paddle.unsqueeze(masks, [0, 1])
    img_y = (paddle.arange(0, im_h, dtype='float32') + 0.5)
    img_x = (paddle.arange(0, im_w, dtype='float32') + 0.5)
    img_y = ((((img_y - y0) / (y1 - y0)) * 2) - 1)
    img_x = ((((img_x - x0) / (x1 - x0)) * 2) - 1)
    img_x = paddle.unsqueeze(img_x, [1])
    img_y = paddle.unsqueeze(img_y, [2])
    N = boxes.shape[0]
    gx = paddle.expand(img_x, [N, img_y.shape[1], img_x.shape[2]])
    gy = paddle.expand(img_y, [N, img_y.shape[1], img_x.shape[2]])
    grid = paddle.stack([gx, gy], axis=3)
    img_masks = F.grid_sample(masks, grid, align_corners=False)
    return img_masks[:, 0]