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