當前位置: 首頁>>代碼示例>>Python>>正文


Python blob.prep_im_for_blob方法代碼示例

本文整理匯總了Python中utils.blob.prep_im_for_blob方法的典型用法代碼示例。如果您正苦於以下問題:Python blob.prep_im_for_blob方法的具體用法?Python blob.prep_im_for_blob怎麽用?Python blob.prep_im_for_blob使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在utils.blob的用法示例。


在下文中一共展示了blob.prep_im_for_blob方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _get_image_blob

# 需要導入模塊: from utils import blob [as 別名]
# 或者: from utils.blob import prep_im_for_blob [as 別名]
def _get_image_blob(roidb, scale_inds):
  """Builds an input blob from the images in the roidb at the specified
  scales.
  """
  num_images = len(roidb)
  processed_ims = []
  im_scales = []
  for i in range(num_images):
    im = cv2.imread(roidb[i]['image'])
    if roidb[i]['flipped']:
      im = im[:, ::-1, :]
    target_size = cfg.TRAIN.SCALES[scale_inds[i]]
    im, im_scale = prep_im_for_blob(im, cfg.PIXEL_MEANS, target_size,
                    cfg.TRAIN.MAX_SIZE)
    im_scales.append(im_scale)
    processed_ims.append(im)

  # Create a blob to hold the input images
  blob = im_list_to_blob(processed_ims)

  return blob, im_scales 
開發者ID:Sunarker,項目名稱:Collaborative-Learning-for-Weakly-Supervised-Object-Detection,代碼行數:23,代碼來源:minibatch.py

示例2: _get_image_blob

# 需要導入模塊: from utils import blob [as 別名]
# 或者: from utils.blob import prep_im_for_blob [as 別名]
def _get_image_blob(roidb, scale_inds):
    """Builds an input blob from the images in the roidb at the specified
    scales.
    """
    num_images = len(roidb)
    processed_ims = []
    im_scales = []
    for i in range(num_images):
        im = helper.read_rgb_img(roidb[i]['image'])
        if roidb[i]['flipped']:
            im = im[:, ::-1, :]
        target_size = cfg.TRAIN.SCALES[scale_inds[i]]
        im, im_scale = prep_im_for_blob(im, cfg.PIXEL_MEANS, target_size,
                                        cfg.TRAIN.MAX_SIZE)
        im_scales.append(im_scale)
        processed_ims.append(im)

    # Create a blob to hold the input images
    blob = im_list_to_blob(processed_ims)

    return blob, im_scales 
開發者ID:Sanster,項目名稱:tf_ctpn,代碼行數:23,代碼來源:minibatch.py

示例3: _get_image_blob

# 需要導入模塊: from utils import blob [as 別名]
# 或者: from utils.blob import prep_im_for_blob [as 別名]
def _get_image_blob(roidb, scale_inds):
    """Builds an input blob from the images in the roidb at the specified
    scales.
    """
    num_images = len(roidb)
    processed_ims = []
    im_scales = []
    im_shapes = np.zeros((0, 2), dtype=np.float32)
    for i in xrange(num_images):
        im = cv2.imread(roidb[i]['image'])
        if roidb[i]['flipped']:
            im = im[:, ::-1, :]
        target_size = cfg.TRAIN.SCALES[scale_inds[i]]
        im, im_scale, im_shape = prep_im_for_blob(im, cfg.PIXEL_MEANS, target_size)
        im_scales.append(im_scale)
        processed_ims.append(im)
        im_shapes = np.vstack((im_shapes, im_shape))

    # Create a blob to hold the input images
    blob = im_list_to_blob(processed_ims)

    return blob, im_scales, im_shapes 
開發者ID:ppengtang,項目名稱:dpl,代碼行數:24,代碼來源:minibatch.py

示例4: _get_image_blob

# 需要導入模塊: from utils import blob [as 別名]
# 或者: from utils.blob import prep_im_for_blob [as 別名]
def _get_image_blob(roidb, scale_inds):
    """Builds an input blob from the images in the roidb at the specified
    scales.
    """
    num_images = len(roidb)
    processed_ims = []
    im_scales = []
    for i in xrange(num_images):
        im = cv2.imread(roidb[i]['image'])
        if roidb[i]['flipped']:
            im = im[:, ::-1, :]
        target_size = cfg.TRAIN.SCALES[scale_inds[i]]
        im, im_scale = prep_im_for_blob(im, cfg.PIXEL_MEANS, target_size,
                                        cfg.TRAIN.MAX_SIZE)
        im_scales.append(im_scale)
        processed_ims.append(im)

    # Create a blob to hold the input images
    blob = im_list_to_blob(processed_ims)

    return blob, im_scales 
開發者ID:playerkk,項目名稱:face-py-faster-rcnn,代碼行數:23,代碼來源:minibatch.py

示例5: _get_image_blob

# 需要導入模塊: from utils import blob [as 別名]
# 或者: from utils.blob import prep_im_for_blob [as 別名]
def _get_image_blob(roidb, scale_inds):
    """Builds an input blob from the images in the roidb at the specified
    scales.
    """
    num_images = len(roidb)
    processed_ims = []
    im_scales = []
    for i in xrange(num_images):
        im = roidb[i]['image']() # use image getter

        if roidb[i]['flipped']:
            im = im[:, ::-1, :]
        target_size = cfg.TRAIN.SCALES[scale_inds[i]]
        im, im_scale = prep_im_for_blob(im, cfg.PIXEL_MEANS, target_size,
                                        cfg.TRAIN.MAX_SIZE)
        im_scales.append(im_scale)
        processed_ims.append(im)

    # Create a blob to hold the input images
    blob = im_list_to_blob(processed_ims)

    return blob, im_scales 
開發者ID:danfeiX,項目名稱:scene-graph-TF-release,代碼行數:24,代碼來源:minibatch.py

示例6: get_image_blob

# 需要導入模塊: from utils import blob [as 別名]
# 或者: from utils.blob import prep_im_for_blob [as 別名]
def get_image_blob(roidb, scale_inds, scales, max_scale):
  """Builds an input blob from the images in the roidb at the specified
  scales.
  """
  num_images = len(roidb)
  processed_ims = []
  im_scales = []
  for i in range(num_images):
    im = cv2.imread(roidb[i]['image'])
    if roidb[i]['flipped']:
      im = im[:, ::-1, :]
    target_size = scales[scale_inds[i]]
    im, im_scale = prep_im_for_blob(im, cfg.PIXEL_MEANS, target_size,
                    max_scale)
    im_scales.append(im_scale)
    processed_ims.append(im)

  # Create a blob to hold the input images
  blob = im_list_to_blob(processed_ims)

  return blob, im_scales 
開發者ID:endernewton,項目名稱:iter-reason,代碼行數:23,代碼來源:minibatch.py

示例7: _get_image_blob

# 需要導入模塊: from utils import blob [as 別名]
# 或者: from utils.blob import prep_im_for_blob [as 別名]
def _get_image_blob(im):
    """Converts an image into a network input.

    Arguments:
        im (ndarray): a color image in BGR order

    Returns:
        blob (ndarray): a data blob holding an image pyramid
        im_scale_factors (ndarray): array of image scales (relative to im) used
            in the image pyramid
    """
    processed_ims, im_scale_factors = blob_utils.prep_im_for_blob(
        im, cfg.PIXEL_MEANS, cfg.TEST.SCALES, cfg.TEST.MAX_SIZE
    )
    blob = blob_utils.im_list_to_blob(processed_ims)
    return blob, np.array(im_scale_factors) 
開發者ID:lvpengyuan,項目名稱:masktextspotter.caffe2,代碼行數:18,代碼來源:test.py

示例8: _get_image_blob

# 需要導入模塊: from utils import blob [as 別名]
# 或者: from utils.blob import prep_im_for_blob [as 別名]
def _get_image_blob(roidb, scale_inds):
    """Builds an input blob from the images in the roidb at the specified
    scales.
    """
    num_images = len(roidb)
    processed_ims = []
    im_scales = []
    im_shapes = np.zeros((0, 2), dtype=np.float32)
    for i in xrange(num_images):
        im = cv2.imread(roidb[i]['image'])
        if roidb[i]['flipped']:
            im = im[:, ::-1, :]
        target_size = cfg.TRAIN.SCALES[scale_inds[i]]
        im, im_scale, im_shape = prep_im_for_blob(im, cfg.PIXEL_MEANS, 
                                                  target_size, 
                                                  cfg.TRAIN.MAX_SIZE)
        im_scales.append(im_scale)
        processed_ims.append(im)
        im_shapes = np.vstack((im_shapes, im_shape))

    # Create a blob to hold the input images
    blob = im_list_to_blob(processed_ims)

    return blob, im_scales, im_shapes 
開發者ID:ppengtang,項目名稱:oicr,代碼行數:26,代碼來源:minibatch.py

示例9: _get_image_blob

# 需要導入模塊: from utils import blob [as 別名]
# 或者: from utils.blob import prep_im_for_blob [as 別名]
def _get_image_blob(roidb, scale_inds):
  """Builds an input blob from the images in the roidb at the specified
  scales.
  """
  num_images = len(roidb)
  processed_ims = []
  im_scales = []
  for i in range(num_images):
    im = cv2.imread(roidb[i]['image'])
    if roidb[i]['flipped']:
      im = im[:, ::-1, :]
    target_size = cfg.TRAIN.SCALES[scale_inds[i]]
    im, im_scale = prep_im_for_blob(im, cfg.PIXEL_MEANS, target_size,
                    cfg.TRAIN.MAX_SIZE)
    im_scales.append(im_scale)
    processed_ims.append(im)


  # Create a blob to hold the input images
  blob = im_list_to_blob(processed_ims)

  return blob, im_scales 
開發者ID:Sundrops,項目名稱:pytorch-faster-rcnn,代碼行數:24,代碼來源:minibatch.py

示例10: _get_image_blob

# 需要導入模塊: from utils import blob [as 別名]
# 或者: from utils.blob import prep_im_for_blob [as 別名]
def _get_image_blob(self, sample):
        im_blob = []
        labels_blob = []
        for i in range(self.batch_size):
            im = cv2.imread(cfg.IMAGEPATH + sample[i]['picname'])
            if sample[i]['flipped']:
                im = im[:, ::-1, :]
            personname = sample[i]['picname'].split('/')[0]
            labels_blob.append(self._data._sample_label[personname])
            im = prep_im_for_blob(im)

            im_blob.append(im)

        # Create a blob to hold the input images
        blob = im_list_to_blob(im_blob)
        return blob, labels_blob 
開發者ID:hizhangp,項目名稱:triplet,代碼行數:18,代碼來源:data_layer.py

示例11: _get_image_blob

# 需要導入模塊: from utils import blob [as 別名]
# 或者: from utils.blob import prep_im_for_blob [as 別名]
def _get_image_blob(roidb):
    """Builds an input blob from the images in the roidb at the specified
    scales.
    """
    num_images = len(roidb)
    # Sample random scales to use for each image in this batch
    scale_inds = np.random.randint(
        0, high=len(cfg.TRAIN.SCALES), size=num_images)
    processed_ims = []
    im_scales = []
    for i in range(num_images):
        im = cv2.imread(roidb[i]['image'])
        assert im is not None, \
            'Failed to read image \'{}\''.format(roidb[i]['image'])
        # If NOT using opencv to read in images, uncomment following lines
        # if len(im.shape) == 2:
        #     im = im[:, :, np.newaxis]
        #     im = np.concatenate((im, im, im), axis=2)
        # # flip the channel, since the original one using cv2
        # # rgb -> bgr
        # im = im[:, :, ::-1]
        if roidb[i]['flipped']:
            im = im[:, ::-1, :]
        target_size = cfg.TRAIN.SCALES[scale_inds[i]]
        im, im_scale = blob_utils.prep_im_for_blob(
            im, cfg.PIXEL_MEANS, [target_size], cfg.TRAIN.MAX_SIZE)
        im_scales.append(im_scale[0])
        processed_ims.append(im[0])

    # Create a blob to hold the input images [n, c, h, w]
    blob = blob_utils.im_list_to_blob(processed_ims)

    return blob, im_scales 
開發者ID:roytseng-tw,項目名稱:Detectron.pytorch,代碼行數:35,代碼來源:minibatch.py

示例12: _image_preprocess

# 需要導入模塊: from utils import blob [as 別名]
# 或者: from utils.blob import prep_im_for_blob [as 別名]
def _image_preprocess(img):
    target_scale = npr.choice(cfg.TRAIN.SCALES)
    im, im_scale = prep_im_for_blob(img, cfg.PIXEL_MEANS, target_scale,
                                    cfg.TRAIN.MAX_SIZE)
    return im, im_scale 
開發者ID:myfavouritekk,項目名稱:TPN,代碼行數:7,代碼來源:layer.py

示例13: _get_image_blob

# 需要導入模塊: from utils import blob [as 別名]
# 或者: from utils.blob import prep_im_for_blob [as 別名]
def _get_image_blob(roidb, scale_inds):
    """Builds an input blob from the images in the roidb at the specified
    scales.
    """
    num_images = len(roidb)
    processed_ims = []
    im_scales = []
    for i in xrange(num_images):
        im = cv2.imread(roidb[i]['image'])

        if roidb[i]['flipped']:
            im = im[:, ::-1, :]

        if roidb[i]['blurred']:
            im = cv2.GaussianBlur(im, (7, 7), 20)

        if 'scale' in roidb[i].keys():
            if roidb[i]['scale'] != 1:
                resized_im = cv2.resize(im, (
                    np.floor(im.shape[1] * roidb[i]['scale']).astype(np.int32),
                    np.floor(im.shape[0] * roidb[i]['scale']).astype(np.int32)))
                im = resized_im

        if 'crop_box' in roidb[i].keys():
            im = im[roidb[i]['crop_box'][1]:roidb[i]['crop_box'][3],
                 roidb[i]['crop_box'][0]:roidb[i]['crop_box'][2]]

        target_size = cfg.TRAIN.SCALES[scale_inds[i]]
        im, im_scale = prep_im_for_blob(im, cfg.PIXEL_MEANS, target_size,
                                        cfg.TRAIN.MAX_SIZE)
        im_scales.append(im_scale)
        processed_ims.append(im)

    # Create a blob to hold the input images
    blob = im_list_to_blob(processed_ims)

    return blob, im_scales 
開發者ID:po0ya,項目名稱:face-magnet,代碼行數:39,代碼來源:minibatch.py

示例14: _get_image_blob

# 需要導入模塊: from utils import blob [as 別名]
# 或者: from utils.blob import prep_im_for_blob [as 別名]
def _get_image_blob(roidb):
    """Builds an input blob from the images in the roidb at the specified
    scales.
    """
    num_images = len(roidb)
    # Sample random scales to use for each image in this batch
    scale_inds = np.random.randint(
        0, high=len(cfg.TRAIN.SCALES), size=num_images
    )
    processed_ims = []
    im_scales = []
    for i in range(num_images):
        im = cv2.imread(roidb[i]['image'])
        assert im is not None, \
            'Failed to read image \'{}\''.format(roidb[i]['image'])
        if roidb[i]['flipped']:
            im = im[:, ::-1, :]
        target_size = cfg.TRAIN.SCALES[scale_inds[i]]
        im, im_scale = blob_utils.prep_im_for_blob(
            im, cfg.PIXEL_MEANS, target_size, cfg.TRAIN.MAX_SIZE
        )
        im_scales.append(im_scale)
        processed_ims.append(im)

    # Create a blob to hold the input images
    blob = blob_utils.im_list_to_blob(processed_ims)

    return blob, im_scales 
開發者ID:ronghanghu,項目名稱:seg_every_thing,代碼行數:30,代碼來源:minibatch.py

示例15: _get_image_blob

# 需要導入模塊: from utils import blob [as 別名]
# 或者: from utils.blob import prep_im_for_blob [as 別名]
def _get_image_blob(roidb):
    """Builds an input blob from the images in the roidb at the specified
    scales.
    """
    num_images = len(roidb)
    # Sample random scales to use for each image in this batch
    scale_inds = np.random.randint(
        0, high=len(cfg.TRAIN.SCALES), size=num_images)
    processed_ims = []
    im_scales = []
    for i in range(num_images):
        im = cv2.imread(roidb[i]['image'])
        assert im is not None, \
            'Failed to read image \'{}\''.format(roidb[i]['image'])
        # If NOT using opencv to read in images, uncomment following lines
        # if len(im.shape) == 2:
        #     im = im[:, :, np.newaxis]
        #     im = np.concatenate((im, im, im), axis=2)
        # # flip the channel, since the original one using cv2
        # # rgb -> bgr
        # im = im[:, :, ::-1]
        if roidb[i]['flipped']:
            im = im[:, ::-1, :]
        target_size = cfg.TRAIN.SCALES[scale_inds[i]]

        # TODO: color argumentation
        im = color_aug(im)

        im, im_scale = blob_utils.prep_im_for_blob(
            im, cfg.PIXEL_MEANS, [target_size], cfg.TRAIN.MAX_SIZE)
        im_scales.append(im_scale[0])
        processed_ims.append(im[0])

    # Create a blob to hold the input images [n, c, h, w]
    blob = blob_utils.im_list_to_blob(processed_ims)

    return blob, im_scales 
開發者ID:bobwan1995,項目名稱:PMFNet,代碼行數:39,代碼來源:minibatch.py


注:本文中的utils.blob.prep_im_for_blob方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。