当前位置: 首页>>代码示例>>Python>>正文


Python blob.get_image_blob方法代码示例

本文整理汇总了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 
开发者ID:roytseng-tw,项目名称:Detectron.pytorch,代码行数:10,代码来源:test.py

示例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 
开发者ID:ppengtang,项目名称:pcl.pytorch,代码行数:11,代码来源:test.py

示例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 
开发者ID:ruotianluo,项目名称:Context-aware-ZSR,代码行数:43,代码来源:rpn_generator.py

示例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 
开发者ID:ronghanghu,项目名称:seg_every_thing,代码行数:10,代码来源:test.py

示例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 ---------------------------- 
开发者ID:bobwan1995,项目名称:PMFNet,代码行数:13,代码来源:test.py

示例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 
开发者ID:ronghanghu,项目名称:seg_every_thing,代码行数:45,代码来源:rpn_generator.py


注:本文中的utils.blob.get_image_blob方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。