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


Python cfg.PIXEL_MEANS属性代码示例

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


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

示例1: _get_image_blob

# 需要导入模块: from model.config import cfg [as 别名]
# 或者: from model.config.cfg import PIXEL_MEANS [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 model.config import cfg [as 别名]
# 或者: from model.config.cfg import PIXEL_MEANS [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 
开发者ID:Sanster,项目名称:tf_ctpn,代码行数:23,代码来源:minibatch.py

示例3: _add_image_summary

# 需要导入模块: from model.config import cfg [as 别名]
# 或者: from model.config.cfg import PIXEL_MEANS [as 别名]
def _add_image_summary(self, image, boxes):
    # add back mean
    image += cfg.PIXEL_MEANS

    # bgr to rgb (opencv uses bgr)
    channels = tf.unstack (image, axis=-1)
    image    = tf.stack ([channels[2], channels[1], channels[0]], axis=-1)
    # dims for normalization
    width  = tf.to_float(tf.shape(image)[2])
    height = tf.to_float(tf.shape(image)[1])
    # from [x1, y1, x2, y2, cls] to normalized [y1, x1, y1, x1]
    cols = tf.unstack(boxes, axis=1)
    boxes = tf.stack([cols[1] / height,
                      cols[0] / width,
                      cols[3] / height,
                      cols[2] / width], axis=1)
    # add batch dimension (assume batch_size==1)
    assert image.get_shape()[0] == 1
    boxes = tf.expand_dims(boxes, dim=0)
    image = tf.image.draw_bounding_boxes(image, boxes)

    
    return tf.summary.image('ground_truth', image) 
开发者ID:pengzhou1108,项目名称:RGB-N,代码行数:25,代码来源:network_fusion.py

示例4: _add_noise_summary

# 需要导入模块: from model.config import cfg [as 别名]
# 或者: from model.config.cfg import PIXEL_MEANS [as 别名]
def _add_noise_summary(self, noise, boxes):
    # add back mean
    noise += cfg.PIXEL_MEANS
    noise_channels = tf.unstack (noise, axis=-1)
    noise    = tf.stack ([noise_channels[2], noise_channels[1], noise_channels[0]], axis=-1)
    # dims for normalization
    width  = tf.to_float(tf.shape(noise)[2])
    height = tf.to_float(tf.shape(noise)[1])
    # from [x1, y1, x2, y2, cls] to normalized [y1, x1, y1, x1]
    cols = tf.unstack(boxes, axis=1)
    boxes = tf.stack([cols[1] / height,
                      cols[0] / width,
                      cols[3] / height,
                      cols[2] / width], axis=1)
    # add batch dimension (assume batch_size==1)
    assert noise.get_shape()[0] == 1
    boxes = tf.expand_dims(boxes, dim=0)
    noise = tf.image.draw_bounding_boxes(noise, boxes)

    
    return tf.summary.image('noise', noise) 
开发者ID:pengzhou1108,项目名称:RGB-N,代码行数:23,代码来源:network_fusion.py

示例5: _add_image_summary

# 需要导入模块: from model.config import cfg [as 别名]
# 或者: from model.config.cfg import PIXEL_MEANS [as 别名]
def _add_image_summary(self, image, boxes):
    # add back mean
    image += cfg.PIXEL_MEANS
    # bgr to rgb (opencv uses bgr)
    channels = tf.unstack (image, axis=-1)
    image    = tf.stack ([channels[2], channels[1], channels[0]], axis=-1)
    # dims for normalization
    width  = tf.to_float(tf.shape(image)[2])
    height = tf.to_float(tf.shape(image)[1])
    # from [x1, y1, x2, y2, cls] to normalized [y1, x1, y1, x1]
    cols = tf.unstack(boxes, axis=1)
    boxes = tf.stack([cols[1] / height,
                      cols[0] / width,
                      cols[3] / height,
                      cols[2] / width], axis=1)
    # add batch dimension (assume batch_size==1)
    assert image.get_shape()[0] == 1
    boxes = tf.expand_dims(boxes, dim=0)
    image = tf.image.draw_bounding_boxes(image, boxes)
    
    return tf.summary.image('ground_truth', image) 
开发者ID:pengzhou1108,项目名称:RGB-N,代码行数:23,代码来源:network_noise.py

示例6: get_image_blob

# 需要导入模块: from model.config import cfg [as 别名]
# 或者: from model.config.cfg import PIXEL_MEANS [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 
开发者ID:endernewton,项目名称:iter-reason,代码行数:23,代码来源:minibatch.py

示例7: _get_image_blob

# 需要导入模块: from model.config import cfg [as 别名]
# 或者: from model.config.cfg import PIXEL_MEANS [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:Sundrops,项目名称:pytorch-faster-rcnn,代码行数:24,代码来源:minibatch.py

示例8: _add_gt_image

# 需要导入模块: from model.config import cfg [as 别名]
# 或者: from model.config.cfg import PIXEL_MEANS [as 别名]
def _add_gt_image(self):
    # add back mean
    image = self._image_gt_summaries['image'] + cfg.PIXEL_MEANS
    image = imresize(image[0], self._im_info[:2] / self._im_info[2])
    # BGR to RGB (opencv uses BGR)
    self._gt_image = image[np.newaxis, :,:,::-1].copy(order='C') 
开发者ID:Sunarker,项目名称:Collaborative-Learning-for-Weakly-Supervised-Object-Detection,代码行数:8,代码来源:network.py

示例9: _get_image_blob

# 需要导入模块: from model.config import cfg [as 别名]
# 或者: from model.config.cfg import PIXEL_MEANS [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 (list): list of image scales (relative to im) used
      in the image pyramid
  """
  im_orig = im.astype(np.float32, copy=True)
  im_orig -= cfg.PIXEL_MEANS

  im_shape = im_orig.shape
  im_size_min = np.min(im_shape[0:2])
  im_size_max = np.max(im_shape[0:2])

  processed_ims = []
  im_scale_factors = []

  for target_size in cfg.TEST.SCALES:
    im_scale = float(target_size) / float(im_size_min)
    # Prevent the biggest axis from being more than MAX_SIZE
    if np.round(im_scale * im_size_max) > cfg.TEST.MAX_SIZE:
      im_scale = float(cfg.TEST.MAX_SIZE) / float(im_size_max)
    im = cv2.resize(im_orig, None, None, fx=im_scale, fy=im_scale,
            interpolation=cv2.INTER_LINEAR)
    im_scale_factors.append(im_scale)
    processed_ims.append(im)

  # Create a blob to hold the input images
  blob = im_list_to_blob(processed_ims)

  return blob, np.array(im_scale_factors) 
开发者ID:Sunarker,项目名称:Collaborative-Learning-for-Weakly-Supervised-Object-Detection,代码行数:35,代码来源:test.py

示例10: _add_gt_image

# 需要导入模块: from model.config import cfg [as 别名]
# 或者: from model.config.cfg import PIXEL_MEANS [as 别名]
def _add_gt_image(self):
        # add back mean
        image = self._image + cfg.PIXEL_MEANS
        # BGR to RGB (opencv uses BGR)
        resized = tf.image.resize_bilinear(image, tf.to_int32(self._im_info[:2] / self._im_info[2]))
        self._gt_image = tf.reverse(resized, axis=[-1]) 
开发者ID:wanjinchang,项目名称:SSH-TensorFlow,代码行数:8,代码来源:network.py

示例11: _get_image_blob

# 需要导入模块: from model.config import cfg [as 别名]
# 或者: from model.config.cfg import PIXEL_MEANS [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 (list): list of image scales (relative to im) used
        in the image pyramid
    """
    im_orig = im.astype(np.float32, copy=True)
    im_orig -= cfg.PIXEL_MEANS

    im_shape = im_orig.shape
    im_size_min = np.min(im_shape[0:2])
    im_size_max = np.max(im_shape[0:2])

    processed_ims = []
    im_scale_factors = []

    for target_size in cfg.TEST.SCALES:
        im_scale = float(target_size) / float(im_size_min)
        # Prevent the biggest axis from being more than MAX_SIZE
        if np.round(im_scale * im_size_max) > cfg.TEST.MAX_SIZE:
            im_scale = float(cfg.TEST.MAX_SIZE) / float(im_size_max)
        im = cv2.resize(im_orig, None, None, fx=im_scale, fy=im_scale,
                        interpolation=cv2.INTER_LINEAR)
        im_scale_factors.append(im_scale)
        processed_ims.append(im)

    # Create a blob to hold the input images
    blob = im_list_to_blob(processed_ims)

    return blob, np.array(im_scale_factors) 
开发者ID:wanjinchang,项目名称:SSH-TensorFlow,代码行数:35,代码来源:test.py

示例12: _get_image_blobs

# 需要导入模块: from model.config import cfg [as 别名]
# 或者: from model.config.cfg import PIXEL_MEANS [as 别名]
def _get_image_blobs(im):
    """Converts an image into a network input for faster version.
        Arguments:
          im (ndarray): a color image in BGR order
        Returns:
          blob (ndarray): a data blob holding an image pyramid
          im_scale_factors (list): list of image scales (relative to im) used
            in the image pyramid
    """
    im_orig = im.astype(np.float32, copy=True)
    im_scale_factors = []
    h, w = im.shape[:2]
    im_size_min = np.min(im.shape[0:2])
    im_size_max = np.max(im.shape[0:2])
    im_scale = float(cfg.TEST.SCALES[0]) / float(im_size_min)
    if np.round(im_scale * im_size_max) > cfg.TEST.MAX_SIZE:
        im_scale = float(cfg.TEST.MAX_SIZE) / float(im_size_max)
    im_scale_factors.append(im_scale)
    target_size = (int(im_scale * w), int(im_scale * h))
    im = cv2.resize(im_orig, target_size)
    im -= cfg.PIXEL_MEANS

    # Create a blob to hold the input images
    blob = im[np.newaxis, :, :, :]

    return blob, np.array(im_scale_factors) 
开发者ID:wanjinchang,项目名称:SSH-TensorFlow,代码行数:28,代码来源:test.py

示例13: _get_image_blob

# 需要导入模块: from model.config import cfg [as 别名]
# 或者: from model.config.cfg import PIXEL_MEANS [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 (list): list of image scales (relative to im) used
        in the image pyramid
    """
    im_orig = im.astype(np.float32, copy=True)
    im_orig -= cfg.PIXEL_MEANS

    im_shape = im_orig.shape
    im_size_min = np.min(im_shape[0:2])
    im_size_max = np.max(im_shape[0:2])
    # print(">>>>>>>>", im_shape[0], im_shape[1])

    processed_ims = []
    im_scale_factors = []

    for target_size in cfg.TEST.SCALES:
        im_scale = float(target_size) / float(im_size_min)
        # Prevent the biggest axis from being more than MAX_SIZE
        if np.round(im_scale * im_size_max) > cfg.TEST.MAX_SIZE:
            im_scale = float(cfg.TEST.MAX_SIZE) / float(im_size_max)
        im = cv2.resize(im_orig, None, None, fx=im_scale, fy=im_scale,
                        interpolation=cv2.INTER_LINEAR)
        im_scale_factors.append(im_scale)
        processed_ims.append(im)

    # Create a blob to hold the input images
    print(">>>>>>>>", im.shape[0], im.shape[1])
    blob = im_list_to_blob(processed_ims)

    return blob, np.array(im_scale_factors) 
开发者ID:wanjinchang,项目名称:SSH-TensorFlow,代码行数:37,代码来源:inference.py

示例14: _add_gt_image

# 需要导入模块: from model.config import cfg [as 别名]
# 或者: from model.config.cfg import PIXEL_MEANS [as 别名]
def _add_gt_image(self):
    # add back mean
    image = self._image + cfg.PIXEL_MEANS
    # BGR to RGB (opencv uses BGR)
    resized = tf.image.resize_bilinear(image, tf.to_int32(self._im_info[:2] / self._im_info[2]))
    self._gt_image = tf.reverse(resized, axis=[-1]) 
开发者ID:endernewton,项目名称:tf-faster-rcnn,代码行数:8,代码来源:network.py

示例15: _add_gt_image

# 需要导入模块: from model.config import cfg [as 别名]
# 或者: from model.config.cfg import PIXEL_MEANS [as 别名]
def _add_gt_image(self):
    # add back mean
    image = self._image + cfg.PIXEL_MEANS
    # BGR to RGB (opencv uses BGR)
    self._gt_image = tf.reverse(image, axis=[-1]) 
开发者ID:endernewton,项目名称:iter-reason,代码行数:7,代码来源:network.py


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