本文整理汇总了Python中detectron.utils.vis.convert_from_cls_format方法的典型用法代码示例。如果您正苦于以下问题:Python vis.convert_from_cls_format方法的具体用法?Python vis.convert_from_cls_format怎么用?Python vis.convert_from_cls_format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类detectron.utils.vis
的用法示例。
在下文中一共展示了vis.convert_from_cls_format方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_model_cfg
# 需要导入模块: from detectron.utils import vis [as 别名]
# 或者: from detectron.utils.vis import convert_from_cls_format [as 别名]
def run_model_cfg(args, im, check_blobs):
workspace.ResetWorkspace()
model, _ = load_model(args)
with c2_utils.NamedCudaScope(0):
cls_boxes, cls_segms, cls_keyps = test_engine.im_detect_all(
model, im, None, None,
)
boxes, segms, keypoints, classes = vis_utils.convert_from_cls_format(
cls_boxes, cls_segms, cls_keyps)
# sort the results based on score for comparision
boxes, segms, keypoints, classes = _sort_results(
boxes, segms, keypoints, classes)
# write final results back to workspace
def _ornone(res):
return np.array(res) if res is not None else np.array([], dtype=np.float32)
with c2_utils.NamedCudaScope(0):
workspace.FeedBlob(core.ScopedName('result_boxes'), _ornone(boxes))
workspace.FeedBlob(core.ScopedName('result_segms'), _ornone(segms))
workspace.FeedBlob(core.ScopedName('result_keypoints'), _ornone(keypoints))
workspace.FeedBlob(core.ScopedName('result_classids'), _ornone(classes))
# get result blobs
with c2_utils.NamedCudaScope(0):
ret = _get_result_blobs(check_blobs)
return ret
示例2: run_model_cfg
# 需要导入模块: from detectron.utils import vis [as 别名]
# 或者: from detectron.utils.vis import convert_from_cls_format [as 别名]
def run_model_cfg(args, im, check_blobs):
workspace.ResetWorkspace()
model, _ = load_model(args)
with c2_utils.NamedCudaScope(0):
cls_boxes, cls_segms, cls_keyps = test_engine.im_detect_all(
model, im, None, None
)
boxes, segms, keypoints, classes = vis_utils.convert_from_cls_format(
cls_boxes, cls_segms, cls_keyps
)
# sort the results based on score for comparision
boxes, segms, keypoints, classes = _sort_results(boxes, segms, keypoints, classes)
# write final results back to workspace
def _ornone(res):
return np.array(res) if res is not None else np.array([], dtype=np.float32)
with c2_utils.NamedCudaScope(0):
workspace.FeedBlob(core.ScopedName("result_boxes"), _ornone(boxes))
workspace.FeedBlob(core.ScopedName("result_segms"), _ornone(segms))
workspace.FeedBlob(core.ScopedName("result_keypoints"), _ornone(keypoints))
workspace.FeedBlob(core.ScopedName("result_classids"), _ornone(classes))
# get result blobs
with c2_utils.NamedCudaScope(0):
ret = _get_result_blobs(check_blobs)
return ret