本文整理汇总了Python中model.utils.cython_bbox.bbox_overlaps方法的典型用法代码示例。如果您正苦于以下问题:Python cython_bbox.bbox_overlaps方法的具体用法?Python cython_bbox.bbox_overlaps怎么用?Python cython_bbox.bbox_overlaps使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.utils.cython_bbox
的用法示例。
在下文中一共展示了cython_bbox.bbox_overlaps方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_roidb_from_box_list
# 需要导入模块: from model.utils import cython_bbox [as 别名]
# 或者: from model.utils.cython_bbox import bbox_overlaps [as 别名]
def create_roidb_from_box_list(self, box_list, gt_roidb):
assert len(box_list) == self.num_images, \
'Number of boxes must match number of ground-truth images'
roidb = []
for i in range(self.num_images):
boxes = box_list[i]
num_boxes = boxes.shape[0]
overlaps = np.zeros((num_boxes, self.num_classes), dtype=np.float32)
if gt_roidb is not None and gt_roidb[i]['boxes'].size > 0:
gt_boxes = gt_roidb[i]['boxes']
gt_classes = gt_roidb[i]['gt_classes']
gt_overlaps = bbox_overlaps(boxes.astype(np.float),
gt_boxes.astype(np.float))
argmaxes = gt_overlaps.argmax(axis=1)
maxes = gt_overlaps.max(axis=1)
I = np.where(maxes > 0)[0]
overlaps[I, gt_classes[argmaxes[I]]] = maxes[I]
overlaps = scipy.sparse.csr_matrix(overlaps)
roidb.append({
'boxes': boxes,
'gt_classes': np.zeros((num_boxes,), dtype=np.int32),
'gt_overlaps': overlaps,
'flipped': False,
'seg_areas': np.zeros((num_boxes,), dtype=np.float32),
})
return roidb
示例2: create_roidb_from_box_list
# 需要导入模块: from model.utils import cython_bbox [as 别名]
# 或者: from model.utils.cython_bbox import bbox_overlaps [as 别名]
def create_roidb_from_box_list(self, box_list, gt_roidb):
assert len(box_list) == self.num_images, \
'Number of boxes must match number of ground-truth images'
roidb = []
for i in range(self.num_images):
boxes = box_list[i]
num_boxes = boxes.shape[0]
overlaps = np.zeros((num_boxes, self.num_classes), dtype=np.float32)
if gt_roidb is not None and gt_roidb[i]['boxes'].size > 0:
gt_boxes = gt_roidb[i]['boxes']
gt_classes = gt_roidb[i]['gt_classes']
gt_overlaps = bbox_overlaps(boxes.astype(np.float),
gt_boxes.astype(np.float))
argmaxes = gt_overlaps.argmax(axis=1)
maxes = gt_overlaps.max(axis=1)
I = np.where(maxes > 0)[0]
overlaps[I, gt_classes[argmaxes[I]]] = maxes[I]
overlaps = scipy.sparse.csr_matrix(overlaps)
roidb.append({
'boxes': boxes,
'gt_classes': np.zeros((num_boxes,), dtype=np.int32),
'gt_overlaps': overlaps,
'flipped': False,
'seg_areas': np.zeros((num_boxes,), dtype=np.float32),
})
return roidb
示例3: _sample_rois
# 需要导入模块: from model.utils import cython_bbox [as 别名]
# 或者: from model.utils.cython_bbox import bbox_overlaps [as 别名]
def _sample_rois(all_rois, proposals, num_classes):
"""Generate a random sample of RoIs comprising foreground and background
examples.
"""
# overlaps: (rois x gt_boxes)
gt_boxes = proposals['gt_boxes']
gt_labels = proposals['gt_classes']
gt_scores = proposals['gt_scores']
overlaps = bbox_overlaps(
np.ascontiguousarray(all_rois[0], dtype=np.float),
np.ascontiguousarray(gt_boxes, dtype=np.float))
try :
gt_assignment = overlaps.argmax(axis=1)
max_overlaps = overlaps.max(axis=1)
except :
pdb.set_trace()
labels = gt_labels[gt_assignment, 0]
cls_loss_weights = gt_scores[gt_assignment, 0]
# Select foreground RoIs as those with >= FG_THRESH overlap
fg_inds = np.where(max_overlaps >= 0.5)[0]
# Select background RoIs as those within [BG_THRESH_LO, BG_THRESH_HI)
bg_inds = np.where(max_overlaps < 0.5)[0]
labels[bg_inds] = 0
real_labels = np.zeros((labels.shape[0], 21))
for i in range(labels.shape[0]) :
real_labels[i, labels[i]] = 1
rois = all_rois
return real_labels, rois, cls_loss_weights