(self, rel_codes, boxes)
return pred_boxes
From a set of original boxes and encoded relative box offsets,
        get the decoded boxes.

        Arguments:
            rel_codes (Tensor): encoded boxes
            boxes (Tensor): reference boxes.
From a set of original boxes and encoded relative box offsets,
        get the decoded boxes.
From a set of original boxes and encoded relative box offsets get the decoded boxes .
def decode(self, rel_codes, boxes):
        """
        From a set of original boxes and encoded relative box offsets,
        get the decoded boxes.

        Arguments:
            rel_codes (Tensor): encoded boxes
            boxes (Tensor): reference boxes.
        """

        boxes = boxes.to(rel_codes.dtype)

        TO_REMOVE = 1  # TODO remove
        widths = boxes[:, 2] - boxes[:, 0] + TO_REMOVE
        heights = boxes[:, 3] - boxes[:, 1] + TO_REMOVE
        ctr_x = boxes[:, 0] + 0.5 * widths
        ctr_y = boxes[:, 1] + 0.5 * heights

        wx, wy, ww, wh = self.weights
        dx = rel_codes[:, 0::4] / wx
        dy = rel_codes[:, 1::4] / wy
        dw = rel_codes[:, 2::4] / ww
        dh = rel_codes[:, 3::4] / wh

        # Prevent sending too large values into torch.exp()
        dw = torch.clamp(dw, max=self.bbox_xform_clip)
        dh = torch.clamp(dh, max=self.bbox_xform_clip)

        pred_ctr_x = dx * widths[:, None] + ctr_x[:, None]
        pred_ctr_y = dy * heights[:, None] + ctr_y[:, None]
        pred_w = torch.exp(dw) * widths[:, None]
        pred_h = torch.exp(dh) * heights[:, None]

        pred_boxes = torch.zeros_like(rel_codes)
        # x1
        pred_boxes[:, 0::4] = pred_ctr_x - 0.5 * pred_w
        # y1
        pred_boxes[:, 1::4] = pred_ctr_y - 0.5 * pred_h
        # x2 (note: "- 1" is correct; don't be fooled by the asymmetry)
        pred_boxes[:, 2::4] = pred_ctr_x + 0.5 * pred_w - 1
        # y2 (note: "- 1" is correct; don't be fooled by the asymmetry)
        pred_boxes[:, 3::4] = pred_ctr_y + 0.5 * pred_h - 1

        return pred_boxes
def decode ( self , rel_codes , boxes ) : boxes = boxes . to ( rel_codes . dtype ) TO_REMOVE = 1 # TODO remove widths = boxes [ : , 2 ] - boxes [ : , 0 ] + TO_REMOVE heights = boxes [ : , 3 ] - boxes [ : , 1 ] + TO_REMOVE ctr_x = boxes [ : , 0 ] + 0.5 * widths ctr_y = boxes [ : , 1 ] + 0.5 * heights wx , wy , ww , wh = self . weights dx = rel_codes [ : , 0 : : 4 ] / wx dy = rel_codes [ : , 1 : : 4 ] / wy dw = rel_codes [ : , 2 : : 4 ] / ww dh = rel_codes [ : , 3 : : 4 ] / wh # Prevent sending too large values into torch.exp() dw = torch . clamp ( dw , max = self . bbox_xform_clip ) dh = torch . clamp ( dh , max = self . bbox_xform_clip ) pred_ctr_x = dx * widths [ : , None ] + ctr_x [ : , None ] pred_ctr_y = dy * heights [ : , None ] + ctr_y [ : , None ] pred_w = torch . exp ( dw ) * widths [ : , None ] pred_h = torch . exp ( dh ) * heights [ : , None ] pred_boxes = torch . zeros_like ( rel_codes ) # x1 pred_boxes [ : , 0 : : 4 ] = pred_ctr_x - 0.5 * pred_w # y1 pred_boxes [ : , 1 : : 4 ] = pred_ctr_y - 0.5 * pred_h # x2 (note: "- 1" is correct; don't be fooled by the asymmetry) pred_boxes [ : , 2 : : 4 ] = pred_ctr_x + 0.5 * pred_w - 1 # y2 (note: "- 1" is correct; don't be fooled by the asymmetry) pred_boxes [ : , 3 : : 4 ] = pred_ctr_y + 0.5 * pred_h - 1 return pred_boxes