当前位置: 首页>>代码示例>>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;未经允许,请勿转载。