本文整理汇总了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
示例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
示例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
示例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
示例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
示例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)
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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