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