本文整理匯總了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