python类prep_im_for_blob()的实例源码

minibatch_orig.py 文件源码 项目:FRCNN_git 作者: runa91 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
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
minibatch.py 文件源码 项目:FastRCNN-TF-Django 作者: DamonLiuNJU 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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
minibatch.py 文件源码 项目:PVANet-FACE 作者: twmht 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def _get_image_blob(imdb, 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):
        proto = imdb.get_proto_at(roidb[i]['image'])
        mem = BytesIO(proto.data)
        im = io.imread(mem)
        im = im[:,:,::-1]

        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, cfg.TRAIN.SCALE_MULTIPLE_OF)
        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
minibatch.py 文件源码 项目:craftGBD 作者: craftGBD 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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
minibatch.py 文件源码 项目:scene-graph-TF-release 作者: danfeiX 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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
minibatch.py 文件源码 项目:py-R-FCN 作者: YuwenXiong 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
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
minibatch.py 文件源码 项目:pytorch-faster-rcnn 作者: ruotianluo 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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
minibatch.py 文件源码 项目:person_search 作者: ShuangLI59 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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
minibatch.py 文件源码 项目:objectattention 作者: cdevin 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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
mnc_data_layer.py 文件源码 项目:MNC 作者: daijifeng001 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def _get_image_blob(self, roidb, scale_inds):
        """Builds an input blob from the images in the roidb at the specified
        scales.
        """
        num_images = 1  # len(roidb)
        processed_ims = []
        im_scales = []
        for i in xrange(num_images):
            im = cv2.imread(roidb['image'])
            if roidb['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
cfm_data_layer.py 文件源码 项目:MNC 作者: daijifeng001 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def _get_image_blob(self, roidb, scale_inds, im_names):
        """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(im_names[i])
            # here [0][0] is due to the nature of scipy.io.savemat
            # since it will change True/False to [[1]] or [[0]] with shape (1,1)
            # so we judge whether flip image in this un-normal way
            if roidb[i]['Flip'][0][0]:
                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
minibatch.py 文件源码 项目:fast-rcnn-distillation 作者: xiaolonw 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def _get_image_blob(roidb, scale_inds, data_i):
    """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):
        imname1 = roidb[i]['image'][data_i]
        imname2= imname1 + '_norm.png'
        im1= cv2.imread(imname1)
        im2= cv2.imread(imname2) 
        if roidb[i]['flipped']:
            im1 = im1[:, ::-1, :]
            im2 = im2[:, ::-1, :]
            im2[:,:,2] = 255 - im2[:,:,2]

        im = np.zeros((im1.shape[0], im1.shape[1], 6))
        im = im.astype('uint8')
        im1 = im1[:, :, ::-1]
        im2 = im2[:, :, ::-1]
        im[:,:,0:3] = im1
        im[:,:,3:6] = im2



        target_size = cfg.TRAIN.SCALES[scale_inds[i]]
        im, im_scale = prep_im_for_blob(im, 127.5, 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
layer.py 文件源码 项目:TPN 作者: myfavouritekk 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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
minibatch.py 文件源码 项目:lsi-faster-rcnn 作者: cguindel 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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):
        if DEBUG:
            print 'Loading:', roidb[i]['image']
        if cfg.TRAIN.FOURCHANNELS:
            im = cv2.imread(roidb[i]['image'], cv2.IMREAD_UNCHANGED)
        else:
            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, four_channels=cfg.TRAIN.FOURCHANNELS)

    return blob, im_scales


问题


面经


文章

微信
公众号

扫码关注公众号