本文整理汇总了Python中utils.blob.get_image_blob方法的典型用法代码示例。如果您正苦于以下问题:Python blob.get_image_blob方法的具体用法?Python blob.get_image_blob怎么用?Python blob.get_image_blob使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils.blob
的用法示例。
在下文中一共展示了blob.get_image_blob方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_blobs
# 需要导入模块: from utils import blob [as 别名]
# 或者: from utils.blob import get_image_blob [as 别名]
def _get_blobs(im, rois, target_scale, target_max_size):
"""Convert an image and RoIs within that image into network inputs."""
blobs = {}
blobs['data'], im_scale, blobs['im_info'] = \
blob_utils.get_image_blob(im, target_scale, target_max_size)
if rois is not None:
blobs['rois'] = _get_rois_blob(rois, im_scale)
return blobs, im_scale
示例2: _get_blobs
# 需要导入模块: from utils import blob [as 别名]
# 或者: from utils.blob import get_image_blob [as 别名]
def _get_blobs(im, rois, target_scale, target_max_size):
"""Convert an image and RoIs within that image into network inputs."""
blobs = {}
blobs['data'], im_scale = \
blob_utils.get_image_blob(im, target_scale, target_max_size)
if rois is not None:
blobs['rois'] = _get_rois_blob(rois, im_scale)
blobs['labels'] = np.zeros((1, cfg.MODEL.NUM_CLASSES), dtype=np.int32)
return blobs, im_scale
示例3: im_proposals
# 需要导入模块: from utils import blob [as 别名]
# 或者: from utils.blob import get_image_blob [as 别名]
def im_proposals(model, im, roidb=None):
"""Generate RPN proposals on a single image."""
inputs = {}
inputs['data'], im_scale, inputs['im_info'] = \
blob_utils.get_image_blob(im, cfg.TEST.SCALE, cfg.TEST.MAX_SIZE)
inputs['data'] = [torch.from_numpy(inputs['data'])]
inputs['im_info'] = [torch.from_numpy(inputs['im_info'])]
if roidb is not None:
inputs['roidb'] = [[roidb]]
return_dict = model(**inputs)
if cfg.FPN.FPN_ON and cfg.FPN.MULTILEVEL_RPN:
k_max = cfg.FPN.RPN_MAX_LEVEL
k_min = cfg.FPN.RPN_MIN_LEVEL
rois = [
return_dict['rpn_rois_fpn' + str(l)]
for l in range(k_min, k_max + 1)
]
scores = [
return_dict['rpn_rois_prob_fpn' + str(l)]
for l in range(k_min, k_max + 1)
]
# Combine predictions across all levels and retain the top scoring
boxes = np.concatenate(rois)
scores = np.concatenate(scores).squeeze()
# Discussion: one could do NMS again after combining predictions from
# the different FPN levels. Conceptually, it's probably the right thing
# to do. For arbitrary reasons, the original FPN RPN implementation did
# not do another round of NMS.
inds = np.argsort(-scores)[:cfg.TEST.RPN_POST_NMS_TOP_N]
scores = scores[inds]
boxes = boxes[inds, :]
else:
boxes = return_dict['rpn_rois'].data.cpu().numpy()
scores = return_dict['rpn_roi_probs'].data.cpu().numpy().squeeze()
# Column 0 is the batch index in the (batch ind, x1, y1, x2, y2) encoding,
# so we remove it since we just want to return boxes
# Scale proposals back to the original input image scale
boxes = boxes[:, 1:] / im_scale
return boxes, scores
示例4: im_conv_body_only
# 需要导入模块: from utils import blob [as 别名]
# 或者: from utils.blob import get_image_blob [as 别名]
def im_conv_body_only(model, im, target_scale, target_max_size):
"""Runs `model.conv_body_net` on the given image `im`."""
im_blob, im_scale, _im_info = blob_utils.get_image_blob(
im, target_scale, target_max_size
)
workspace.FeedBlob(core.ScopedName('data'), im_blob)
workspace.RunNet(model.conv_body_net.Proto().name)
return im_scale
示例5: _get_blobs
# 需要导入模块: from utils import blob [as 别名]
# 或者: from utils.blob import get_image_blob [as 别名]
def _get_blobs(im, rois, target_scale, target_max_size):
"""Convert an image and RoIs within that image into network inputs."""
blobs = {}
blobs['data'], im_scale, blobs['im_info'] = \
blob_utils.get_image_blob(im, target_scale, target_max_size)
if rois is not None:
blobs['rois'] = _get_rois_blob(rois, im_scale)
return blobs, im_scale
# -------------------------- HOI ----------------------------
示例6: im_proposals
# 需要导入模块: from utils import blob [as 别名]
# 或者: from utils.blob import get_image_blob [as 别名]
def im_proposals(model, im):
"""Generate RPN proposals on a single image."""
inputs = {}
inputs['data'], im_scale, inputs['im_info'] = \
blob_utils.get_image_blob(im, cfg.TEST.SCALE, cfg.TEST.MAX_SIZE)
for k, v in inputs.items():
workspace.FeedBlob(core.ScopedName(k), v.astype(np.float32, copy=False))
workspace.RunNet(model.net.Proto().name)
if cfg.FPN.FPN_ON and cfg.FPN.MULTILEVEL_RPN:
k_max = cfg.FPN.RPN_MAX_LEVEL
k_min = cfg.FPN.RPN_MIN_LEVEL
rois_names = [
core.ScopedName('rpn_rois_fpn' + str(l))
for l in range(k_min, k_max + 1)
]
score_names = [
core.ScopedName('rpn_roi_probs_fpn' + str(l))
for l in range(k_min, k_max + 1)
]
blobs = workspace.FetchBlobs(rois_names + score_names)
# Combine predictions across all levels and retain the top scoring
boxes = np.concatenate(blobs[:len(rois_names)])
scores = np.concatenate(blobs[len(rois_names):]).squeeze()
# Discussion: one could do NMS again after combining predictions from
# the different FPN levels. Conceptually, it's probably the right thing
# to do. For arbitrary reasons, the original FPN RPN implementation did
# not do another round of NMS.
inds = np.argsort(-scores)[:cfg.TEST.RPN_POST_NMS_TOP_N]
scores = scores[inds]
boxes = boxes[inds, :]
else:
boxes, scores = workspace.FetchBlobs(
[core.ScopedName('rpn_rois'),
core.ScopedName('rpn_roi_probs')]
)
scores = scores.squeeze()
# Column 0 is the batch index in the (batch ind, x1, y1, x2, y2) encoding,
# so we remove it since we just want to return boxes
# Scale proposals back to the original input image scale
boxes = boxes[:, 1:] / im_scale
return boxes, scores