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


Python blob.prep_im_for_blob方法代码示例

本文整理汇总了Python中model.utils.blob.prep_im_for_blob方法的典型用法代码示例。如果您正苦于以下问题:Python blob.prep_im_for_blob方法的具体用法?Python blob.prep_im_for_blob怎么用?Python blob.prep_im_for_blob使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在model.utils.blob的用法示例。


在下文中一共展示了blob.prep_im_for_blob方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_image_blob

# 需要导入模块: from model.utils import blob [as 别名]
# 或者: from model.utils.blob import prep_im_for_blob [as 别名]
def _get_image_blob(roidb, scale_inds):
    num_images = len(roidb)
    processed_ims = []
    im_scales = []
    for i in range(num_images):
        im = cv2.imread(roidb[i]['file_path'])

        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)

    blob = im_list_to_blob(processed_ims)
    return blob, im_scales 
开发者ID:dechunwang,项目名称:SSH-pytorch,代码行数:20,代码来源:minibatch.py

示例2: _get_image_blob

# 需要导入模块: from model.utils import blob [as 别名]
# 或者: from model.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'])
    im = imread(roidb[i]['image'])

    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 = prep_im_for_blob(im, cfg.PIXEL_MEANS, cfg.PIXEL_STDS, 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:guoruoqian,项目名称:cascade-rcnn_Pytorch,代码行数:33,代码来源:minibatch.py

示例3: _get_image_blob

# 需要导入模块: from model.utils import blob [as 别名]
# 或者: from model.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'])
    #im = imread(roidb[i]['image'])

    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 = 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:Feynman27,项目名称:pytorch-detect-to-track,代码行数:33,代码来源:minibatch.py

示例4: _get_image_blob

# 需要导入模块: from model.utils import blob [as 别名]
# 或者: from model.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'])
        im = imread(roidb[i]['image'])

        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 = 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:ucbdrive,项目名称:3d-vehicle-tracking,代码行数:33,代码来源:minibatch.py

示例5: _get_image_blob

# 需要导入模块: from model.utils import blob [as 别名]
# 或者: from model.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'])
    im = imread(roidb[i]['image'])

    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 = 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:twangnh,项目名称:Distilling-Object-Detectors,代码行数:33,代码来源:minibatch.py

示例6: _get_image_blob

# 需要导入模块: from model.utils import blob [as 别名]
# 或者: from model.utils.blob import prep_im_for_blob [as 别名]
def _get_image_blob(roidb, target_size):
  """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'])
    im = imread(roidb[i]['image'])

    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, :]
    im, im_scale = prep_im_for_blob(im, cfg.PIXEL_MEANS, target_size[i],
                    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:princewang1994,项目名称:RFCN_CoupleNet.pytorch,代码行数:32,代码来源:minibatch.py

示例7: _get_image_blob

# 需要导入模块: from model.utils import blob [as 别名]
# 或者: from model.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'])
    im = imread(roidb[i]['image'])

    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 = 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:timy90022,项目名称:One-Shot-Object-Detection,代码行数:33,代码来源:minibatch.py

示例8: _get_image_blob

# 需要导入模块: from model.utils import blob [as 别名]
# 或者: from model.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 range(num_images):
        img_path = roidb[i]['image']

        im = cv2.imread(roidb[i]['image'])

        target_size = cfg.TRAIN.SCALES[scale_inds[i]]
        if roidb[i]['flipped']:
            im = im[:, ::-1, :]
        
        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:jd730,项目名称:OICR-pytorch,代码行数:31,代码来源:minibatch.py

示例9: load_query

# 需要导入模块: from model.utils import blob [as 别名]
# 或者: from model.utils.blob import prep_im_for_blob [as 别名]
def load_query(self, choice, id=0):
    
    if self.training:
        # Random choice query catgory image
        all_data = self._query[choice]
        data     = random.choice(all_data)
    else:
        # Take out the purpose category for testing
        catgory = self.cat_list[choice]
        # list all the candidate image 
        all_data = self._query[catgory]

        # Use image_id to determine the random seed
        # The list l is candidate sequence, which random by image_id
        random.seed(id)
        l = list(range(len(all_data)))
        random.shuffle(l)

        # choose the candidate sequence and take out the data information
        position=l[self.query_position%len(l)]
        data     = all_data[position]

    # Get image
    path       = data['image_path']
    im = imread(path)
    

    if len(im.shape) == 2:
      im = im[:,:,np.newaxis]
      im = np.concatenate((im,im,im), axis=2)

    im = crop(im, data['boxes'], cfg.TRAIN.query_size)
    # flip the channel, since the original one using cv2
    # rgb -> bgr
    # im = im[:,:,::-1]
    if random.randint(0,99)/100 > 0.5 and self.training:
      im = im[:, ::-1, :]


    im, im_scale = prep_im_for_blob(im, cfg.PIXEL_MEANS, cfg.TRAIN.query_size,
                    cfg.TRAIN.MAX_SIZE)
    
    query = im_list_to_blob([im])

    return query 
开发者ID:timy90022,项目名称:One-Shot-Object-Detection,代码行数:47,代码来源:roibatchLoader.py

示例10: _get_image_blob

# 需要导入模块: from model.utils import blob [as 别名]
# 或者: from model.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_left = []
  processed_ims_right = []
  im_scales = []
  for i in range(num_images):
    #im = cv2.imread(roidb[i]['image'])
    img_left = imread(roidb[i]['img_left'])
    img_right = imread(roidb[i]['img_right'])

    if len(img_left.shape) == 2:
      img_left = img_left[:,:,np.newaxis]
      img_left = np.concatenate((img_left,img_left,img_left), axis=2)
    
    if len(img_right.shape) == 2:
      img_right = img_right[:,:,np.newaxis]
      img_right = np.concatenate((img_right,img_right,img_right), axis=2)

    # flip the channel, since the original one using cv2
    # rgb -> bgr
    img_left = img_left[:,:,::-1]
    img_right = img_right[:,:,::-1]

    if roidb[i]['flipped']:
      img_left_flip = img_right[:, ::-1, :].copy()
      img_right = img_left[:, ::-1, :].copy()
      img_left = img_left_flip

    target_size = cfg.TRAIN.SCALES[scale_inds[i]]
    img_left, img_right, im_scale = prep_im_for_blob(img_left, img_right, cfg.PIXEL_MEANS, target_size,
                    cfg.TRAIN.MAX_SIZE)
    im_scales.append(im_scale)
    processed_ims_left.append(img_left)
    processed_ims_right.append(img_right)

  # Create a blob to hold the input images
  blob_left, blob_right = im_list_to_blob(processed_ims_left, processed_ims_right)

  return blob_left, blob_right, im_scales 
开发者ID:HKUST-Aerial-Robotics,项目名称:Stereo-RCNN,代码行数:45,代码来源:minibatch.py


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