本文整理汇总了Python中mmdet.core.bbox2result方法的典型用法代码示例。如果您正苦于以下问题:Python core.bbox2result方法的具体用法?Python core.bbox2result怎么用?Python core.bbox2result使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mmdet.core
的用法示例。
在下文中一共展示了core.bbox2result方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: async_simple_test
# 需要导入模块: from mmdet import core [as 别名]
# 或者: from mmdet.core import bbox2result [as 别名]
def async_simple_test(self,
x,
proposal_list,
img_metas,
proposals=None,
rescale=False):
"""Async test without augmentation."""
assert self.with_bbox, 'Bbox head must be implemented.'
det_bboxes, det_labels = await self.async_test_bboxes(
x, img_metas, proposal_list, self.test_cfg, rescale=rescale)
bbox_results = bbox2result(det_bboxes, det_labels,
self.bbox_head.num_classes)
if not self.with_mask:
return bbox_results
else:
segm_results = await self.async_test_mask(
x,
img_metas,
det_bboxes,
det_labels,
rescale=rescale,
mask_test_cfg=self.test_cfg.get('mask'))
return bbox_results, segm_results
示例2: simple_test
# 需要导入模块: from mmdet import core [as 别名]
# 或者: from mmdet.core import bbox2result [as 别名]
def simple_test(self,
x,
proposal_list,
img_metas,
proposals=None,
rescale=False):
"""Test without augmentation."""
assert self.with_bbox, 'Bbox head must be implemented.'
det_bboxes, det_labels = self.simple_test_bboxes(
x, img_metas, proposal_list, self.test_cfg, rescale=rescale)
bbox_results = bbox2result(det_bboxes, det_labels,
self.bbox_head.num_classes)
if not self.with_mask:
return bbox_results
else:
segm_results = self.simple_test_mask(
x, img_metas, det_bboxes, det_labels, rescale=rescale)
return bbox_results, segm_results
示例3: simple_test
# 需要导入模块: from mmdet import core [as 别名]
# 或者: from mmdet.core import bbox2result [as 别名]
def simple_test(self, img, img_meta, proposals=None, rescale=False):
"""Test without augmentation."""
assert self.with_bbox, "Bbox head must be implemented."
x = self.extract_feat(img)
proposal_list = self.simple_test_rpn(
x, img_meta, self.test_cfg.rpn) if proposals is None else proposals
det_bboxes, det_labels = self.simple_test_bboxes(
x, img_meta, proposal_list, self.test_cfg.rcnn, rescale=rescale)
bbox_results = bbox2result(det_bboxes, det_labels,
self.bbox_head.num_classes)
if not self.with_mask:
return bbox_results
else:
segm_results = self.simple_test_mask(
x, img_meta, det_bboxes, det_labels, rescale=rescale)
return bbox_results, segm_results
示例4: simple_test
# 需要导入模块: from mmdet import core [as 别名]
# 或者: from mmdet.core import bbox2result [as 别名]
def simple_test(self, img, img_meta, proposals=None, rescale=False):
"""Test without augmentation."""
assert self.with_bbox, "Bbox head must be implemented."
x = self.extract_feat(img)
proposal_list = self.simple_test_rpn(
x, img_meta, self.test_cfg.rpn) if proposals is None else proposals
det_bboxes, det_labels = self.simple_test_bboxes_hkrm(
x, img_meta, proposal_list, self.test_cfg.rcnn, rescale=rescale, use_hkrm=True)
bbox_results = bbox2result(det_bboxes, det_labels,
self.bbox_head_hkrm.num_classes)
if not self.with_mask:
return bbox_results
else:
segm_results = self.simple_test_mask(
x, img_meta, det_bboxes, det_labels, rescale=rescale)
return bbox_results, segm_results
示例5: simple_test
# 需要导入模块: from mmdet import core [as 别名]
# 或者: from mmdet.core import bbox2result [as 别名]
def simple_test(self, img, img_meta, proposals=None, rescale=False):
"""Test without augmentation."""
assert self.with_bbox, "Bbox head must be implemented."
if self.use_consistent_supervision:
x, y = self.extract_feat(img)
else:
x = self.extract_feat(img)
proposal_list = self.simple_test_rpn(
x, img_meta, self.test_cfg.rpn) if proposals is None else proposals
det_bboxes, det_labels = self.simple_test_bboxes(
x, img_meta, proposal_list, self.test_cfg.rcnn, rescale=rescale)
bbox_results = bbox2result(det_bboxes, det_labels,
self.bbox_head.num_classes)
if not self.with_mask:
return bbox_results
else:
segm_results = self.simple_test_mask(
x, img_meta, det_bboxes, det_labels, rescale=rescale)
return bbox_results, segm_results
示例6: simple_test
# 需要导入模块: from mmdet import core [as 别名]
# 或者: from mmdet.core import bbox2result [as 别名]
def simple_test(self,
x,
proposal_list,
img_metas,
proposals=None,
rescale=False):
"""Test without augmentation."""
assert self.with_bbox, 'Bbox head must be implemented.'
det_bboxes, det_labels = self.simple_test_bboxes(
x, img_metas, proposal_list, self.test_cfg, rescale=False)
# pack rois into bboxes
grid_rois = bbox2roi([det_bboxes[:, :4]])
grid_feats = self.grid_roi_extractor(
x[:len(self.grid_roi_extractor.featmap_strides)], grid_rois)
if grid_rois.shape[0] != 0:
self.grid_head.test_mode = True
grid_pred = self.grid_head(grid_feats)
det_bboxes = self.grid_head.get_bboxes(det_bboxes,
grid_pred['fused'],
img_metas)
if rescale:
scale_factor = img_metas[0]['scale_factor']
if not isinstance(scale_factor, (float, torch.Tensor)):
scale_factor = det_bboxes.new_tensor(scale_factor)
det_bboxes[:, :4] /= scale_factor
else:
det_bboxes = torch.Tensor([])
bbox_results = bbox2result(det_bboxes, det_labels,
self.bbox_head.num_classes)
if not self.with_mask:
return bbox_results
else:
segm_results = self.simple_test_mask(
x, img_metas, det_bboxes, det_labels, rescale=rescale)
return bbox_results, segm_results
示例7: aug_test
# 需要导入模块: from mmdet import core [as 别名]
# 或者: from mmdet.core import bbox2result [as 别名]
def aug_test(self, x, proposal_list, img_metas, rescale=False):
"""Test with augmentations.
If rescale is False, then returned bboxes and masks will fit the scale
of imgs[0].
"""
# recompute feats to save memory
det_bboxes, det_labels = self.aug_test_bboxes(x, img_metas,
proposal_list,
self.test_cfg)
if rescale:
_det_bboxes = det_bboxes
else:
_det_bboxes = det_bboxes.clone()
_det_bboxes[:, :4] *= det_bboxes.new_tensor(
img_metas[0][0]['scale_factor'])
bbox_results = bbox2result(_det_bboxes, det_labels,
self.bbox_head.num_classes)
# det_bboxes always keep the original scale
if self.with_mask:
segm_results = self.aug_test_mask(x, img_metas, det_bboxes,
det_labels)
return bbox_results, segm_results
else:
return bbox_results
示例8: aug_test
# 需要导入模块: from mmdet import core [as 别名]
# 或者: from mmdet.core import bbox2result [as 别名]
def aug_test(self, imgs, img_metas, rescale=False):
"""Test with augmentations.
If rescale is False, then returned bboxes and masks will fit the scale
of imgs[0].
"""
# recompute feats to save memory
proposal_list = self.aug_test_rpn(
self.extract_feats(imgs), img_metas, self.test_cfg.rpn)
det_bboxes, det_labels = self.aug_test_bboxes(
self.extract_feats(imgs), img_metas, proposal_list,
self.test_cfg.rcnn)
if rescale:
_det_bboxes = det_bboxes
else:
_det_bboxes = det_bboxes.clone()
_det_bboxes[:, :4] *= img_metas[0][0]['scale_factor']
bbox_results = bbox2result(_det_bboxes, det_labels,
self.bbox_head.num_classes)
# det_bboxes always keep the original scale
if self.with_mask:
segm_results = self.aug_test_mask(
self.extract_feats(imgs), img_metas, det_bboxes, det_labels)
return bbox_results, segm_results
else:
return bbox_results
示例9: simple_test
# 需要导入模块: from mmdet import core [as 别名]
# 或者: from mmdet.core import bbox2result [as 别名]
def simple_test(self, img, img_meta, proposals=None, rescale=False):
"""Test without augmentation."""
assert self.with_bbox, "Bbox head must be implemented."
assert self.with_rbbox, "RBox head must be implemented."
x = self.extract_feat(img)
proposal_list = self.simple_test_rpn(
x, img_meta, self.test_cfg.rpn) if proposals is None else proposals
det_bboxes, det_labels = self.simple_test_bboxes(
x, img_meta, proposal_list, self.test_cfg.rcnn, rescale=rescale)
# TODO: implement the dbbox2result
# bbox_results = dbbox2result(det_bboxes, det_labels,
# self.bbox_head.num_classes)
bbox_results = bbox2result(det_bboxes, det_labels,
self.bbox_head.num_classes)
if not self.with_rbbox:
return bbox_results
else:
det_rbboxes, det_rlabels = self.simple_test_rbboxes_v2(
x, img_meta, det_bboxes, self.test_cfg.rrcnn, rescale=rescale)
# import pdb
# pdb.set_trace()
rbbox_results = dbbox2result(det_rbboxes, det_rlabels,
self.rbbox_head.num_classes)
return bbox_results, rbbox_results
示例10: aug_test
# 需要导入模块: from mmdet import core [as 别名]
# 或者: from mmdet.core import bbox2result [as 别名]
def aug_test(self, imgs, img_metas, rescale=False):
"""Test with augmentations.
If rescale is False, then returned bboxes and masks will fit the scale
of imgs[0].
"""
# recompute feats to save memory
assert NotImplementedError
# proposal_list = self.aug_test_rpn(
# self.extract_feats(imgs), img_metas, self.test_cfg.rpn)
# det_bboxes, det_labels = self.aug_test_bboxes(
# self.extract_feats(imgs), img_metas, proposal_list,
# self.test_cfg.rcnn)
#
# if rescale:
# _det_bboxes = det_bboxes
# else:
# _det_bboxes = det_bboxes.clone()
# _det_bboxes[:, :4] *= img_metas[0][0]['scale_factor']
# bbox_results = bbox2result(_det_bboxes, det_labels,
# self.bbox_head.num_classes)
# det_bboxes always keep the original scale
# if self.with_mask:
# segm_results = self.aug_test_mask(
# self.extract_feats(imgs), img_metas, det_bboxes, det_labels)
# return bbox_results, segm_results
# else:
# return bbox_results
示例11: simple_test
# 需要导入模块: from mmdet import core [as 别名]
# 或者: from mmdet.core import bbox2result [as 别名]
def simple_test(self, img, img_meta, proposals=None, rescale=False):
"""Test without augmentation."""
assert self.with_bbox, "Bbox head must be implemented."
x = self.extract_feat(img)
proposal_list = self.simple_test_rpn(
x, img_meta, self.test_cfg.rpn) if proposals is None else proposals
det_bboxes, det_labels = self.simple_test_bboxes(
x, img_meta, proposal_list, self.test_cfg.rcnn, rescale=False)
# pack rois into bboxes
grid_rois = bbox2roi([det_bboxes[:, :4]])
grid_feats = self.grid_roi_extractor(
x[:len(self.grid_roi_extractor.featmap_strides)], grid_rois)
if grid_rois.shape[0] != 0:
self.grid_head.test_mode = True
grid_pred = self.grid_head(grid_feats)
det_bboxes = self.grid_head.get_bboxes(det_bboxes,
grid_pred['fused'],
img_meta)
if rescale:
det_bboxes[:, :4] /= img_meta[0]['scale_factor']
else:
det_bboxes = torch.Tensor([])
bbox_results = bbox2result(det_bboxes, det_labels,
self.bbox_head.num_classes)
return bbox_results
示例12: simple_test
# 需要导入模块: from mmdet import core [as 别名]
# 或者: from mmdet.core import bbox2result [as 别名]
def simple_test(self, img, img_meta, proposals=None, rescale=False):
"""Test without augmentation."""
assert self.with_bbox, "Bbox head must be implemented."
# 经过backbone和FPN特征提取层,得到若干个输出特征图组成tuple
x = self.extract_feat(img)
# 定义在RPNTestMixin中,用于生成RPN输出后处理得到的proposals(真实坐标)(NMS过)
# 注意list的长度对应的是图片的数目
#输入特征图,生成anchors,分类回归,NMS,坐标还原,生成proposals
proposal_list = self.simple_test_rpn(
x, img_meta, self.test_cfg.rpn) if proposals is None else proposals
# 定义在BBoxTestMixin中
# 输入proposals,进行RoI池化,分类回归,NMS,得到真正的检测目标和坐标的坐标偏移
det_bboxes, det_labels = self.simple_test_bboxes(
x, img_meta, proposal_list, self.test_cfg.rcnn, rescale=rescale)
# 偏移还原为真实坐坐标
bbox_results = bbox2result(det_bboxes, det_labels,
self.bbox_head.num_classes)
if not self.with_mask:
return bbox_results
else:
# 分割任务加mask
segm_results = self.simple_test_mask(
x, img_meta, det_bboxes, det_labels, rescale=rescale)
return bbox_results, segm_results