zoukankan      html  css  js  c++  java
  • _bbox_pred函数

    fast中的_bbox_pred函数和faster中的bbox_transform_inv是一样的,是将框进行4个坐标变换得到新的框坐标。fast中是将selective search生成的框坐标进行回归变换,faster中用了两个地方,一个是把根据rpn滑动机制生成的anchor框进行回归变换,另一个是在fast rcnn网络中把rpn生成的region proposal进行回归变换。

    def _bbox_pred(boxes, box_deltas):
        """Transform the set of class-agnostic boxes into class-specific boxes
        by applying the predicted offsets (box_deltas)
        """
        if boxes.shape[0] == 0:
            return np.zeros((0, box_deltas.shape[1]))
    
        boxes = boxes.astype(np.float, copy=False)
        widths = boxes[:, 2] - boxes[:, 0] + cfg.EPS
        heights = boxes[:, 3] - boxes[:, 1] + cfg.EPS
        ctr_x = boxes[:, 0] + 0.5 * widths
        ctr_y = boxes[:, 1] + 0.5 * heights
    
        dx = box_deltas[:, 0::4]
        dy = box_deltas[:, 1::4]
        dw = box_deltas[:, 2::4]
        dh = box_deltas[:, 3::4]
    
        pred_ctr_x = dx * widths[:, np.newaxis] + ctr_x[:, np.newaxis]
        pred_ctr_y = dy * heights[:, np.newaxis] + ctr_y[:, np.newaxis]
        pred_w = np.exp(dw) * widths[:, np.newaxis]
        pred_h = np.exp(dh) * heights[:, np.newaxis]
    
        pred_boxes = np.zeros(box_deltas.shape)
        # 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
        pred_boxes[:, 2::4] = pred_ctr_x + 0.5 * pred_w
        # y2
        pred_boxes[:, 3::4] = pred_ctr_y + 0.5 * pred_h
    
        return pred_boxes
  • 相关阅读:
    高中数学运算能力训练题
    vue @click.native
    vue_qqmapdemo1
    vuxdemo1
    使用命令行打开vscode
    nextjs-demo
    material-ui里面的withStyles是什么?
    material(一)
    有趣的npx
    在macbookpro上开启ssh服务
  • 原文地址:https://www.cnblogs.com/ymjyqsx/p/7670632.html
Copyright © 2011-2022 走看看