當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。