def __call__(self, hm, wh, reg, im_shape, scale_factor):
    heat = self._simple_nms(hm)
    (scores, inds, topk_clses, ys, xs) = self._topk(heat)
    scores = paddle.tensor.unsqueeze(scores, [1])
    clses = paddle.tensor.unsqueeze(topk_clses, [1])
    reg_t = paddle.transpose(reg, [0, 2, 3, 1])
    reg = paddle.reshape(reg_t, [(- 1), paddle.shape(reg_t)[(- 1)]])
    reg = paddle.gather(reg, inds)
    xs = paddle.cast(xs, 'float32')
    ys = paddle.cast(ys, 'float32')
    xs = (xs + reg[:, 0:1])
    ys = (ys + reg[:, 1:2])
    wh_t = paddle.transpose(wh, [0, 2, 3, 1])
    wh = paddle.reshape(wh_t, [(- 1), paddle.shape(wh_t)[(- 1)]])
    wh = paddle.gather(wh, inds)
    if self.regress_ltrb:
        x1 = (xs - wh[:, 0:1])
        y1 = (ys - wh[:, 1:2])
        x2 = (xs + wh[:, 2:3])
        y2 = (ys + wh[:, 3:4])
    else:
        x1 = (xs - (wh[:, 0:1] / 2))
        y1 = (ys - (wh[:, 1:2] / 2))
        x2 = (xs + (wh[:, 0:1] / 2))
        y2 = (ys + (wh[:, 1:2] / 2))
    (n, c, feat_h, feat_w) = hm.shape[:]
    padw = (((feat_w * self.down_ratio) - im_shape[(0, 1)]) / 2)
    padh = (((feat_h * self.down_ratio) - im_shape[(0, 0)]) / 2)
    x1 = (x1 * self.down_ratio)
    y1 = (y1 * self.down_ratio)
    x2 = (x2 * self.down_ratio)
    y2 = (y2 * self.down_ratio)
    x1 = (x1 - padw)
    y1 = (y1 - padh)
    x2 = (x2 - padw)
    y2 = (y2 - padh)
    bboxes = paddle.concat([x1, y1, x2, y2], axis=1)
    scale_y = scale_factor[:, 0:1]
    scale_x = scale_factor[:, 1:2]
    scale_expand = paddle.concat([scale_x, scale_y, scale_x, scale_y], axis=1)
    boxes_shape = paddle.shape(bboxes)
    boxes_shape.stop_gradient = True
    scale_expand = paddle.expand(scale_expand, shape=boxes_shape)
    bboxes = paddle.divide(bboxes, scale_expand)
    if self.for_mot:
        results = paddle.concat([bboxes, scores, clses], axis=1)
        return (results, inds, topk_clses)
    else:
        results = paddle.concat([clses, scores, bboxes], axis=1)
        return (results, paddle.shape(results)[0:1], topk_clses)
def __call__(self, hm, wh, reg, im_shape, scale_factor):
    heat = self._simple_nms(hm)
    (scores, inds, topk_clses, ys, xs) = self._topk(heat)
    scores = paddle.tensor.unsqueeze(scores, [1])
    clses = paddle.tensor.unsqueeze(topk_clses, [1])
    reg_t = paddle.transpose(reg, [0, 2, 3, 1])
    reg = paddle.reshape(reg_t, [(- 1), paddle.shape(reg_t)[(- 1)]])
    reg = paddle.gather(reg, inds)
    xs = paddle.cast(xs, 'float32')
    ys = paddle.cast(ys, 'float32')
    xs = (xs + reg[:, 0:1])
    ys = (ys + reg[:, 1:2])
    wh_t = paddle.transpose(wh, [0, 2, 3, 1])
    wh = paddle.reshape(wh_t, [(- 1), paddle.shape(wh_t)[(- 1)]])
    wh = paddle.gather(wh, inds)
    if self.regress_ltrb:
        x1 = (xs - wh[:, 0:1])
        y1 = (ys - wh[:, 1:2])
        x2 = (xs + wh[:, 2:3])
        y2 = (ys + wh[:, 3:4])
    else:
        x1 = (xs - (wh[:, 0:1] / 2))
        y1 = (ys - (wh[:, 1:2] / 2))
        x2 = (xs + (wh[:, 0:1] / 2))
        y2 = (ys + (wh[:, 1:2] / 2))
    (n, c, feat_h, feat_w) = hm.shape[:]
    padw = (((feat_w * self.down_ratio) - im_shape[(0, 1)]) / 2)
    padh = (((feat_h * self.down_ratio) - im_shape[(0, 0)]) / 2)
    x1 = (x1 * self.down_ratio)
    y1 = (y1 * self.down_ratio)
    x2 = (x2 * self.down_ratio)
    y2 = (y2 * self.down_ratio)
    x1 = (x1 - padw)
    y1 = (y1 - padh)
    x2 = (x2 - padw)
    y2 = (y2 - padh)
    bboxes = paddle.concat([x1, y1, x2, y2], axis=1)
    scale_y = scale_factor[:, 0:1]
    scale_x = scale_factor[:, 1:2]
    scale_expand = paddle.concat([scale_x, scale_y, scale_x, scale_y], axis=1)
    boxes_shape = paddle.shape(bboxes)
    boxes_shape.stop_gradient = True
    scale_expand = paddle.expand(scale_expand, shape=boxes_shape)
    bboxes = paddle.divide(bboxes, scale_expand)
    if self.for_mot:
        results = paddle.concat([bboxes, scores, clses], axis=1)
        return (results, inds, topk_clses)
    else:
        results = paddle.concat([clses, scores, bboxes], axis=1)
        return (results, paddle.shape(results)[0:1], topk_clses)