本文整理匯總了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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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