當前位置: 首頁>>代碼示例>>Python>>正文


Python bbox_transform.bbox_pred方法代碼示例

本文整理匯總了Python中bbox.bbox_transform.bbox_pred方法的典型用法代碼示例。如果您正苦於以下問題:Python bbox_transform.bbox_pred方法的具體用法?Python bbox_transform.bbox_pred怎麽用?Python bbox_transform.bbox_pred使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在bbox.bbox_transform的用法示例。


在下文中一共展示了bbox_transform.bbox_pred方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: im_detect

# 需要導入模塊: from bbox import bbox_transform [as 別名]
# 或者: from bbox.bbox_transform import bbox_pred [as 別名]
def im_detect(predictor, data_batch, data_names, scales, cfg):
    output_all = predictor.predict(data_batch)
    data_dict_all = [dict(zip(data_names, data_batch.data[i])) for i in xrange(len(data_batch.data))]
    scores_all = []
    pred_boxes_all = []
    for output, data_dict, scale in zip(output_all, data_dict_all, scales):
        if cfg.TEST.HAS_RPN:
            rois = output['rois_output'].asnumpy()[:, 1:]
        else:
            rois = data_dict['rois'].asnumpy().reshape((-1, 5))[:, 1:]
        im_shape = data_dict['data'].shape

        # save output
        scores = output['cls_prob_reshape_output'].asnumpy()[0]
        bbox_deltas = output['bbox_pred_reshape_output'].asnumpy()[0]
        # post processing
        pred_boxes = bbox_pred(rois, bbox_deltas)
        pred_boxes = clip_boxes(pred_boxes, im_shape[-2:])

        # we used scaled image & roi to train, so it is necessary to transform them back
        pred_boxes = pred_boxes / scale

        scores_all.append(scores)
        pred_boxes_all.append(pred_boxes)
    return zip(scores_all, pred_boxes_all, data_dict_all) 
開發者ID:wangshy31,項目名稱:MANet_for_Video_Object_Detection,代碼行數:27,代碼來源:tester.py

示例2: check_movements

# 需要導入模塊: from bbox import bbox_transform [as 別名]
# 或者: from bbox.bbox_transform import bbox_pred [as 別名]
def check_movements(ims, bef_ims, aft_ims, processed_roidb, delta_bef_roi, delta_aft_roi):
    save_name = '/home/wangshiyao/Documents/testdata/'+processed_roidb[0]['image'].split('/')[-1]
    print 'saving images to '+save_name
    boxes = processed_roidb[0]['boxes']
    ims.squeeze().transpose(1, 2, 0).astype(np.int8)
    bef_ims.squeeze().transpose(1, 2, 0).astype(np.int8)
    aft_ims.squeeze().transpose(1, 2, 0).astype(np.int8)
    delta_bef_roi = np.array(delta_bef_roi).transpose(1, 0, 2)
    delta_aft_roi = np.array(delta_aft_roi).transpose(1, 0, 2)
    for i in range(boxes.shape[0]):
        cv2.rectangle(ims, (int(boxes[i][0]), int(boxes[i][1])),(int(boxes[i][2]), int(boxes[i][3])),(55, 255, 155),5)
        bef_box = bbox_pred(boxes[i].reshape(1, -1), delta_bef_roi[i])
        cv2.rectangle(bef_ims, (int(bef_box[0][0]), int(bef_box[0][1])),(int(bef_box[0][2]), int(bef_box[0][3])),(55, 255, 155),5)
        aft_box = bbox_pred(boxes[i].reshape(1, -1), delta_aft_roi[i])
        cv2.rectangle(aft_ims, (int(aft_box[0][0]), int(aft_box[0][1])),(int(aft_box[0][2]), int(aft_box[0][3])),(55, 255, 155),5)

    imageio.imsave(save_name, ims)
    imageio.imsave(save_name.split('.')[-2]+'_bef'+'.JPEG', bef_ims)
    imageio.imsave(save_name.split('.')[-2]+'_aft'+'.JPEG', aft_ims) 
開發者ID:wangshy31,項目名稱:MANet_for_Video_Object_Detection,代碼行數:21,代碼來源:image.py

示例3: im_detect

# 需要導入模塊: from bbox import bbox_transform [as 別名]
# 或者: from bbox.bbox_transform import bbox_pred [as 別名]
def im_detect(predictor, data_batch, data_names, scales, cfg):
    output_all = predictor.predict(data_batch)

    data_dict_all = [dict(zip(data_names, idata)) for idata in data_batch.data]
    scores_all = []
    pred_boxes_all = []
    for output, data_dict, scale in zip(output_all, data_dict_all, scales):
        if cfg.TEST.HAS_RPN:
            rois = output['rois_output'].asnumpy()[:, 1:]
        else:
            rois = data_dict['rois'].asnumpy().reshape((-1, 5))[:, 1:]
        im_shape = data_dict['data'].shape

        # save output
        scores = output['cls_prob_reshape_output'].asnumpy()[0]
        bbox_deltas = output['bbox_pred_reshape_output'].asnumpy()[0]

        # post processing
        pred_boxes = bbox_pred(rois, bbox_deltas)
        pred_boxes = clip_boxes(pred_boxes, im_shape[-2:])

        # we used scaled image & roi to train, so it is necessary to transform them back
        pred_boxes = pred_boxes / scale

        scores_all.append(scores)
        pred_boxes_all.append(pred_boxes)
    return scores_all, pred_boxes_all, data_dict_all 
開發者ID:i-pan,項目名稱:kaggle-rsna18,代碼行數:29,代碼來源:tester.py

示例4: list_arguments

# 需要導入模塊: from bbox import bbox_transform [as 別名]
# 或者: from bbox.bbox_transform import bbox_pred [as 別名]
def list_arguments(self):
        return ['cls_prob', 'bbox_pred', 'im_info'] 
開發者ID:i-pan,項目名稱:kaggle-rsna18,代碼行數:4,代碼來源:proposal.py

示例5: im_batch_detect

# 需要導入模塊: from bbox import bbox_transform [as 別名]
# 或者: from bbox.bbox_transform import bbox_pred [as 別名]
def im_batch_detect(predictor, data_batch, data_names, scales, cfg):
    output_all = predictor.predict(data_batch)

    data_dict_all = [dict(zip(data_names, data_batch.data[i])) for i in xrange(len(data_batch.data))]
    scores_all = []
    pred_boxes_all = []
    for output, data_dict, scale in zip(output_all, data_dict_all, scales):
        im_infos = data_dict['im_info'].asnumpy()
        # save output
        scores = output['cls_prob_reshape_output'].asnumpy()[0]
        bbox_deltas = output['bbox_pred_reshape_output'].asnumpy()[0]
        rois = output['rois_output'].asnumpy()
        for im_idx in xrange(im_infos.shape[0]):
            bb_idxs = np.where(rois[:,0] == im_idx)[0]
            im_shape = im_infos[im_idx, :2].astype(np.int)

            # post processing
            pred_boxes = bbox_pred(rois[bb_idxs, 1:], bbox_deltas[bb_idxs, :])
            pred_boxes = clip_boxes(pred_boxes, im_shape)

            # we used scaled image & roi to train, so it is necessary to transform them back
            pred_boxes = pred_boxes / scale[im_idx]

            scores_all.append(scores[bb_idxs, :])
            pred_boxes_all.append(pred_boxes)

    return scores_all, pred_boxes_all, data_dict_all 
開發者ID:wangshy31,項目名稱:MANet_for_Video_Object_Detection,代碼行數:29,代碼來源:tester.py

示例6: im_detect

# 需要導入模塊: from bbox import bbox_transform [as 別名]
# 或者: from bbox.bbox_transform import bbox_pred [as 別名]
def im_detect(predictor, data_batch, data_names, scales, cfg):
    output_all = predictor.predict(data_batch)

    data_dict_all = [dict(zip(data_names, data_batch.data[i])) for i in xrange(len(data_batch.data))]
    scores_all = []
    pred_boxes_all = []
    for output, data_dict, scale in zip(output_all, data_dict_all, scales):
        if cfg.TEST.HAS_RPN:
            rois = output['rois_output'].asnumpy()[:, 1:]
        else:
            rois = data_dict['rois'].asnumpy().reshape((-1, 5))[:, 1:]
        im_shape = data_dict['data'].shape

        # save output
        scores = output['cls_prob_reshape_output'].asnumpy()[0]
        bbox_deltas = output['bbox_pred_reshape_output'].asnumpy()[0]

        # post processing
        pred_boxes = bbox_pred(rois, bbox_deltas)
        pred_boxes = clip_boxes(pred_boxes, im_shape[-2:])

        # we used scaled image & roi to train, so it is necessary to transform them back
        pred_boxes = pred_boxes / scale

        scores_all.append(scores)
        pred_boxes_all.append(pred_boxes)

    if output_all[0].has_key('feat_conv_3x3_relu_output'):
        feat = output_all[0]['feat_conv_3x3_relu_output']
    else:
        feat = None
    return scores_all, pred_boxes_all, data_dict_all, feat 
開發者ID:msracver,項目名稱:Deep-Feature-Flow,代碼行數:34,代碼來源:tester.py

示例7: list_arguments

# 需要導入模塊: from bbox import bbox_transform [as 別名]
# 或者: from bbox.bbox_transform import bbox_pred [as 別名]
def list_arguments(self):

        return ['rois', 'bbox_pred', 'cls_prob', 'im_info'] 
開發者ID:dingjiansw101,項目名稱:RoITransformer_DOTA,代碼行數:5,代碼來源:RRoIDecoder.py

示例8: im_detect

# 需要導入模塊: from bbox import bbox_transform [as 別名]
# 或者: from bbox.bbox_transform import bbox_pred [as 別名]
def im_detect(predictor, data_batch, data_names, scales, cfg):
    output_all = predictor.predict(data_batch)

    data_dict_all = [dict(zip(data_names, idata)) for idata in data_batch.data]
    scores_all = []
    pred_boxes_all = []
    for output, data_dict, scale in zip(output_all, data_dict_all, scales):
        if cfg.TEST.HAS_RPN or cfg.network.ROIDispatch:
            rois = output['rois_output'].asnumpy()[:, 1:]
        else:
            rois = data_dict['rois'].asnumpy().reshape((-1, 5))[:, 1:]
        im_shape = data_dict['data'].shape

        # save output
        if cfg.TEST.LEARN_NMS:
            pred_boxes = output['learn_nms_sorted_bbox'].asnumpy()
            # raw_scores = output['sorted_score_output'].asnumpy()
            scores = output['nms_final_score_output'].asnumpy()
        else:
            scores = output['cls_prob_reshape_output'].asnumpy()[0]
            bbox_deltas = output['bbox_pred_reshape_output'].asnumpy()[0]

            # post processing
            pred_boxes = bbox_pred(rois, bbox_deltas)
            pred_boxes = clip_boxes(pred_boxes, im_shape[-2:])

        # we used scaled image & roi to train, so it is necessary to transform them back
        pred_boxes = pred_boxes / scale

        scores_all.append(scores)
        pred_boxes_all.append(pred_boxes)
    return scores_all, pred_boxes_all, data_dict_all 
開發者ID:msracver,項目名稱:Relation-Networks-for-Object-Detection,代碼行數:34,代碼來源:tester.py


注:本文中的bbox.bbox_transform.bbox_pred方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。