當前位置: 首頁>>代碼示例>>Python>>正文


Python cfg.POOLING_SIZE屬性代碼示例

本文整理匯總了Python中model.config.cfg.POOLING_SIZE屬性的典型用法代碼示例。如果您正苦於以下問題:Python cfg.POOLING_SIZE屬性的具體用法?Python cfg.POOLING_SIZE怎麽用?Python cfg.POOLING_SIZE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在model.config.cfg的用法示例。


在下文中一共展示了cfg.POOLING_SIZE屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _crop_pool_layer

# 需要導入模塊: from model.config import cfg [as 別名]
# 或者: from model.config.cfg import POOLING_SIZE [as 別名]
def _crop_pool_layer(self, bottom, rois, name):
    with tf.variable_scope(name) as scope:
      batch_ids = tf.squeeze(tf.slice(rois, [0, 0], [-1, 1], name="batch_id"), [1])
      # Get the normalized coordinates of bboxes
      bottom_shape = tf.shape(bottom)
      height = (tf.to_float(bottom_shape[1]) - 1.) * np.float32(self._feat_stride[0])
      width = (tf.to_float(bottom_shape[2]) - 1.) * np.float32(self._feat_stride[0])
      x1 = tf.slice(rois, [0, 1], [-1, 1], name="x1") / width
      y1 = tf.slice(rois, [0, 2], [-1, 1], name="y1") / height
      x2 = tf.slice(rois, [0, 3], [-1, 1], name="x2") / width
      y2 = tf.slice(rois, [0, 4], [-1, 1], name="y2") / height  #revised
      # Won't be backpropagated to rois anyway, but to save time
      bboxes = tf.stop_gradient(tf.concat(1,[y1, x1, y2, x2]))
      pre_pool_size = cfg.POOLING_SIZE * 2
      crops = tf.image.crop_and_resize(bottom, bboxes, tf.to_int32(batch_ids), [pre_pool_size, pre_pool_size], name="crops")

    return slim.max_pool2d(crops, [2, 2], padding='SAME') 
開發者ID:pengzhou1108,項目名稱:RGB-N,代碼行數:19,代碼來源:network_fusion.py

示例2: _crop_pool_layer

# 需要導入模塊: from model.config import cfg [as 別名]
# 或者: from model.config.cfg import POOLING_SIZE [as 別名]
def _crop_pool_layer(self, bottom, rois, name):
    with tf.variable_scope(name) as scope:
      batch_ids = tf.squeeze(tf.slice(rois, [0, 0], [-1, 1], name="batch_id"), [1])
      # Get the normalized coordinates of bboxes
      bottom_shape = tf.shape(bottom)
      height = (tf.to_float(bottom_shape[1]) - 1.) * np.float32(self._feat_stride[0])
      width = (tf.to_float(bottom_shape[2]) - 1.) * np.float32(self._feat_stride[0])
      x1 = tf.slice(rois, [0, 1], [-1, 1], name="x1") / width
      y1 = tf.slice(rois, [0, 2], [-1, 1], name="y1") / height
      x2 = tf.slice(rois, [0, 3], [-1, 1], name="x2") / width
      y2 = tf.slice(rois, [0, 4], [-1, 1], name="y2") / height
      # Won't be backpropagated to rois anyway, but to save time
      bboxes = tf.stop_gradient(tf.concat(1,[y1, x1, y2, x2]))
      if cfg.RESNET.MAX_POOL:
        pre_pool_size = cfg.POOLING_SIZE * 2
        crops = tf.image.crop_and_resize(bottom, bboxes, tf.to_int32(batch_ids), [pre_pool_size, pre_pool_size],
                                         name="crops")
        crops = slim.max_pool2d(crops, [2, 2], padding='SAME')
      else:
        crops = tf.image.crop_and_resize(bottom, bboxes, tf.to_int32(batch_ids), [cfg.POOLING_SIZE, cfg.POOLING_SIZE],
                                         name="crops")
    return crops

  # Do the first few layers manually, because 'SAME' padding can behave inconsistently
  # for images of different sizes: sometimes 0, sometimes 1 
開發者ID:pengzhou1108,項目名稱:RGB-N,代碼行數:27,代碼來源:resnet_fusion_noise.py

示例3: _crop_pool_layer

# 需要導入模塊: from model.config import cfg [as 別名]
# 或者: from model.config.cfg import POOLING_SIZE [as 別名]
def _crop_pool_layer(self, bottom, rois, name):
    with tf.variable_scope(name) as scope:
      batch_ids = tf.squeeze(tf.slice(rois, [0, 0], [-1, 1], name="batch_id"), [1])
      # Get the normalized coordinates of bboxes
      bottom_shape = tf.shape(bottom)
      height = (tf.to_float(bottom_shape[1]) - 1.) * np.float32(self._feat_stride[0])
      width = (tf.to_float(bottom_shape[2]) - 1.) * np.float32(self._feat_stride[0])
      x1 = tf.slice(rois, [0, 1], [-1, 1], name="x1") / width
      y1 = tf.slice(rois, [0, 2], [-1, 1], name="y1") / height
      x2 = tf.slice(rois, [0, 3], [-1, 1], name="x2") / width
      y2 = tf.slice(rois, [0, 4], [-1, 1], name="y2") / height
      # Won't be backpropagated to rois anyway, but to save time
      bboxes = tf.stop_gradient(tf.concat(1,[y1, x1, y2, x2]))
      pre_pool_size = cfg.POOLING_SIZE * 2
      crops = tf.image.crop_and_resize(bottom, bboxes, tf.to_int32(batch_ids), [pre_pool_size, pre_pool_size], name="crops")

    return slim.max_pool2d(crops, [2, 2], padding='SAME') 
開發者ID:pengzhou1108,項目名稱:RGB-N,代碼行數:19,代碼來源:network_noise.py

示例4: _crop_pool_layer

# 需要導入模塊: from model.config import cfg [as 別名]
# 或者: from model.config.cfg import POOLING_SIZE [as 別名]
def _crop_pool_layer(self, bottom, rois, name):
    with tf.variable_scope(name) as scope:
      batch_ids = tf.squeeze(tf.slice(rois, [0, 0], [-1, 1], name="batch_id"), [1])
      # Get the normalized coordinates of bounding boxes
      bottom_shape = tf.shape(bottom)
      height = (tf.to_float(bottom_shape[1]) - 1.) * np.float32(self._feat_stride[0])
      width = (tf.to_float(bottom_shape[2]) - 1.) * np.float32(self._feat_stride[0])
      x1 = tf.slice(rois, [0, 1], [-1, 1], name="x1") / width
      y1 = tf.slice(rois, [0, 2], [-1, 1], name="y1") / height
      x2 = tf.slice(rois, [0, 3], [-1, 1], name="x2") / width
      y2 = tf.slice(rois, [0, 4], [-1, 1], name="y2") / height
      # Won't be back-propagated to rois anyway, but to save time
      bboxes = tf.stop_gradient(tf.concat([y1, x1, y2, x2], axis=1))
      pre_pool_size = cfg.POOLING_SIZE * 2
      crops = tf.image.crop_and_resize(bottom, bboxes, tf.to_int32(batch_ids), [pre_pool_size, pre_pool_size], name="crops")

    return slim.max_pool2d(crops, [2, 2], padding='SAME') 
開發者ID:endernewton,項目名稱:tf-faster-rcnn,代碼行數:19,代碼來源:network.py

示例5: _crop_pool_layer

# 需要導入模塊: from model.config import cfg [as 別名]
# 或者: from model.config.cfg import POOLING_SIZE [as 別名]
def _crop_pool_layer(self, bottom, rois, name):
    with tf.variable_scope(name) as scope:
      batch_ids = tf.squeeze(tf.slice(rois, [0, 0], [-1, 1], name="batch_id"), [1])
      # Get the normalized coordinates of bboxes
      bottom_shape = tf.shape(bottom)
      height = (tf.to_float(bottom_shape[1]) - 1.) * np.float32(self._feat_stride[0])
      width = (tf.to_float(bottom_shape[2]) - 1.) * np.float32(self._feat_stride[0])
      x1 = tf.slice(rois, [0, 1], [-1, 1], name="x1") / width
      y1 = tf.slice(rois, [0, 2], [-1, 1], name="y1") / height
      x2 = tf.slice(rois, [0, 3], [-1, 1], name="x2") / width
      y2 = tf.slice(rois, [0, 4], [-1, 1], name="y2") / height
      # Won't be back-propagated to rois anyway, but to save time
      bboxes = tf.stop_gradient(tf.concat([y1, x1, y2, x2], 1))
      if cfg.RESNET.MAX_POOL:
        pre_pool_size = cfg.POOLING_SIZE * 2
        crops = tf.image.crop_and_resize(bottom, bboxes, tf.to_int32(batch_ids), [pre_pool_size, pre_pool_size],
                                         name="crops")
        crops = slim.max_pool2d(crops, [2, 2], padding='SAME')
      else:
        crops = tf.image.crop_and_resize(bottom, bboxes, tf.to_int32(batch_ids), [cfg.POOLING_SIZE, cfg.POOLING_SIZE],
                                         name="crops")
    return crops

  # Do the first few layers manually, because 'SAME' padding can behave inconsistently
  # for images of different sizes: sometimes 0, sometimes 1 
開發者ID:endernewton,項目名稱:tf-faster-rcnn,代碼行數:27,代碼來源:resnet_v1.py

示例6: gen_mask_parsing_labels

# 需要導入模塊: from model.config import cfg [as 別名]
# 或者: from model.config.cfg import POOLING_SIZE [as 別名]
def gen_mask_parsing_labels(parsing_labels, mask_rois):
  # parsing_labels (48, 320, 320)  mask_rois (48, 5)
  # rois = rois.detach()

  x1 = mask_rois[:, 1::4]
  y1 = mask_rois[:, 2::4]
  x2 = mask_rois[:, 3::4]
  y2 = mask_rois[:, 4::4]

  height = parsing_labels.size(1)
  width = parsing_labels.size(2)
  # affine theta
  theta = Variable(mask_rois.data.new(mask_rois.size(0), 2, 3).zero_())
  theta[:, 0, 0] = (x2 - x1) / (width - 1)
  theta[:, 0, 2] = (x1 + x2 - width + 1) / (width - 1)
  theta[:, 1, 1] = (y2 - y1) / (height - 1)
  theta[:, 1, 2] = (y1 + y2 - height + 1) / (height - 1)
  pre_pool_size = cfg.POOLING_SIZE * 8
  grid = F.affine_grid(theta, torch.Size((mask_rois.size(0), 1, pre_pool_size, pre_pool_size)))
  mask_parsing_labels = F.grid_sample(parsing_labels.unsqueeze(1), grid) # (48,1, 320, 320)
  mask_parsing_labels = torch.round(mask_parsing_labels)
  # mask_parsing_labels[mask_parsing_labels >=0.5] = 1
  # mask_parsing_labels[mask_parsing_labels < 0.5] = 0
  return mask_parsing_labels 
開發者ID:Sundrops,項目名稱:pytorch-faster-rcnn,代碼行數:26,代碼來源:proposal_target_layer.py

示例7: _roi_pool_layer

# 需要導入模塊: from model.config import cfg [as 別名]
# 或者: from model.config.cfg import POOLING_SIZE [as 別名]
def _roi_pool_layer(self, bottom, rois): # done
    return RoIPoolFunction(cfg.POOLING_SIZE, cfg.POOLING_SIZE, 1. / 16.)(bottom, rois) 
開發者ID:Sunarker,項目名稱:Collaborative-Learning-for-Weakly-Supervised-Object-Detection,代碼行數:4,代碼來源:network.py

示例8: _crop_pool_layer

# 需要導入模塊: from model.config import cfg [as 別名]
# 或者: from model.config.cfg import POOLING_SIZE [as 別名]
def _crop_pool_layer(self, bottom, rois, max_pool=True): # done
    # implement it using stn
    # box to affine
    # input (x1,y1,x2,y2)
    """
    [  x2-x1             x1 + x2 - W + 1  ]
    [  -----      0      ---------------  ]
    [  W - 1                  W - 1       ]
    [                                     ]
    [           y2-y1    y1 + y2 - H + 1  ]
    [    0      -----    ---------------  ]
    [           H - 1         H - 1      ]
    """
    rois = rois.detach()

    x1 = rois[:, 1::4] / 16.0
    y1 = rois[:, 2::4] / 16.0
    x2 = rois[:, 3::4] / 16.0
    y2 = rois[:, 4::4] / 16.0

    height = bottom.size(2)
    width = bottom.size(3)

    # affine theta
    theta = Variable(rois.data.new(rois.size(0), 2, 3).zero_())
    theta[:, 0, 0] = (x2 - x1) / (width - 1)
    theta[:, 0 ,2] = (x1 + x2 - width + 1) / (width - 1)
    theta[:, 1, 1] = (y2 - y1) / (height - 1)
    theta[:, 1, 2] = (y1 + y2 - height + 1) / (height - 1)

    if max_pool:
      pre_pool_size = cfg.POOLING_SIZE * 2
      grid = F.affine_grid(theta, torch.Size((rois.size(0), 1, pre_pool_size, pre_pool_size)))
      crops = F.grid_sample(bottom.expand(rois.size(0), bottom.size(1), bottom.size(2), bottom.size(3)), grid)
      crops = F.max_pool2d(crops, 2, 2)
    else:
      grid = F.affine_grid(theta, torch.Size((rois.size(0), 1, cfg.POOLING_SIZE, cfg.POOLING_SIZE)))
      crops = F.grid_sample(bottom.expand(rois.size(0), bottom.size(1), bottom.size(2), bottom.size(3)), grid)
    
    return crops 
開發者ID:Sunarker,項目名稱:Collaborative-Learning-for-Weakly-Supervised-Object-Detection,代碼行數:42,代碼來源:network.py

示例9: _roi_pool_layer

# 需要導入模塊: from model.config import cfg [as 別名]
# 或者: from model.config.cfg import POOLING_SIZE [as 別名]
def _roi_pool_layer(self, bottom, rois):
    return RoIPoolFunction(cfg.POOLING_SIZE, cfg.POOLING_SIZE, 1. / 16.)(bottom, rois) 
開發者ID:yxgeee,項目名稱:pytorch-FPN,代碼行數:4,代碼來源:network.py

示例10: _crop_pool_layer

# 需要導入模塊: from model.config import cfg [as 別名]
# 或者: from model.config.cfg import POOLING_SIZE [as 別名]
def _crop_pool_layer(self, bottom, rois, name):
        with tf.variable_scope(name) as scope:
            batch_ids = tf.squeeze(tf.slice(rois, [0, 0], [-1, 1], name="batch_id"), [1])
            # Get the normalized coordinates of bboxes
            bottom_shape = tf.shape(bottom)
            height = (tf.to_float(bottom_shape[1]) - 1.) * np.float32(self._feat_stride[0])
            width = (tf.to_float(bottom_shape[2]) - 1.) * np.float32(self._feat_stride[0])
            x1 = tf.slice(rois, [0, 1], [-1, 1], name="x1") / width
            y1 = tf.slice(rois, [0, 2], [-1, 1], name="y1") / height
            x2 = tf.slice(rois, [0, 3], [-1, 1], name="x2") / width
            y2 = tf.slice(rois, [0, 4], [-1, 1], name="y2") / height
            # Won't be back-propagated to rois anyway, but to save time
            bboxes = tf.stop_gradient(tf.concat([y1, x1, y2, x2], 1))
            if cfg.RESNET.MAX_POOL:
                pre_pool_size = cfg.POOLING_SIZE * 2
                crops = tf.image.crop_and_resize(bottom, bboxes, tf.to_int32(batch_ids), [pre_pool_size, pre_pool_size],
                                                 name="crops")
                crops = slim.max_pool2d(crops, [2, 2], padding='SAME')
            else:
                crops = tf.image.crop_and_resize(bottom, bboxes, tf.to_int32(batch_ids),
                                                 [cfg.POOLING_SIZE, cfg.POOLING_SIZE],
                                                 name="crops")
        return crops

    # Do the first few layers manually, because 'SAME' padding can behave inconsistently
    # for images of different sizes: sometimes 0, sometimes 1 
開發者ID:wanjinchang,項目名稱:SSH-TensorFlow,代碼行數:28,代碼來源:resnet_v1.py

示例11: _roi_pool_layer

# 需要導入模塊: from model.config import cfg [as 別名]
# 或者: from model.config.cfg import POOLING_SIZE [as 別名]
def _roi_pool_layer(self, bootom, rois, name):
    with tf.variable_scope(name) as scope:
      return tf.image.roi_pooling(bootom, rois,
                                  pooled_height=cfg.POOLING_SIZE,
                                  pooled_width=cfg.POOLING_SIZE,
                                  spatial_scale=1. / 16.)[0] 
開發者ID:pengzhou1108,項目名稱:RGB-N,代碼行數:8,代碼來源:network_fusion.py

示例12: _crop_pool_layer

# 需要導入模塊: from model.config import cfg [as 別名]
# 或者: from model.config.cfg import POOLING_SIZE [as 別名]
def _crop_pool_layer(self, bottom, rois, batch_ids, name):
    with tf.variable_scope(name):
      pre_pool_size = cfg.POOLING_SIZE * 2
      crops = tf.image.crop_and_resize(bottom, 
                                       rois, 
                                       batch_ids, 
                                       [pre_pool_size, pre_pool_size], 
                                       name="crops")

    return slim.max_pool2d(crops, [2, 2], padding='SAME') 
開發者ID:endernewton,項目名稱:iter-reason,代碼行數:12,代碼來源:network.py

示例13: _crop_pool_layer

# 需要導入模塊: from model.config import cfg [as 別名]
# 或者: from model.config.cfg import POOLING_SIZE [as 別名]
def _crop_pool_layer(self, bottom, rois, batch_ids, name):
    with tf.variable_scope(name):
      if cfg.RESNET.MAX_POOL:
        pre_pool_size = cfg.POOLING_SIZE * 2
        crops = tf.image.crop_and_resize(bottom, rois, batch_ids, [pre_pool_size, pre_pool_size],
                                         name="crops")
        crops = slim.max_pool2d(crops, [2, 2], padding='SAME')
      else:
        crops = tf.image.crop_and_resize(bottom, rois, batch_ids, [cfg.POOLING_SIZE, cfg.POOLING_SIZE],
                                         name="crops")
    return crops

  # Do the first few layers manually, because 'SAME' padding can behave inconsistently
  # for images of different sizes: sometimes 0, sometimes 1 
開發者ID:endernewton,項目名稱:iter-reason,代碼行數:16,代碼來源:resnet_v1.py

示例14: _roi_pool_layer

# 需要導入模塊: from model.config import cfg [as 別名]
# 或者: from model.config.cfg import POOLING_SIZE [as 別名]
def _roi_pool_layer(self, bottom, rois):
    return RoIPoolFunction(cfg.POOLING_SIZE, cfg.POOLING_SIZE, 1. / 16.)(bottom, rois)
 # mode nearest, bilinear 
開發者ID:Sundrops,項目名稱:pytorch-faster-rcnn,代碼行數:5,代碼來源:network.py

示例15: _crop_pool_layer

# 需要導入模塊: from model.config import cfg [as 別名]
# 或者: from model.config.cfg import POOLING_SIZE [as 別名]
def _crop_pool_layer(self, bottom, rois, max_pool=True):
    # implement it using stn
    # box to affine
    # input (x1,y1,x2,y2)
    """
    [  x2-x1             x1 + x2 - W + 1  ]
    [  -----      0      ---------------  ]
    [  W - 1                  W - 1       ]
    [                                     ]
    [           y2-y1    y1 + y2 - H + 1  ]
    [    0      -----    ---------------  ]
    [           H - 1         H - 1      ]
    """
    rois = rois.detach()

    x1 = rois[:, 1::4] / 16.0
    y1 = rois[:, 2::4] / 16.0
    x2 = rois[:, 3::4] / 16.0
    y2 = rois[:, 4::4] / 16.0

    height = bottom.size(2)
    width = bottom.size(3)

    # affine theta
    theta = Variable(rois.data.new(rois.size(0), 2, 3).zero_())
    theta[:, 0, 0] = (x2 - x1) / (width - 1)
    theta[:, 0 ,2] = (x1 + x2 - width + 1) / (width - 1)
    theta[:, 1, 1] = (y2 - y1) / (height - 1)
    theta[:, 1, 2] = (y1 + y2 - height + 1) / (height - 1)

    if max_pool:
      pre_pool_size = cfg.POOLING_SIZE * 2
      grid = F.affine_grid(theta, torch.Size((rois.size(0), 1, pre_pool_size, pre_pool_size)))

      all_roi = []
      for j in range(rois.size(0)):
        _grid = grid.narrow(0, j, 1)
        _roi_feature = F.grid_sample(bottom.view(1,bottom.size(1), bottom.size(2), bottom.size(3)), _grid)
        all_roi.append(_roi_feature)
      crops = torch.cat(all_roi)
      # crops = F.grid_sample(bottom.expand(rois.size(0), bottom.size(1), bottom.size(2), bottom.size(3)), grid)
      crops = F.max_pool2d(crops, 2, 2)
    else:
      grid = F.affine_grid(theta, torch.Size((rois.size(0), 1, cfg.POOLING_SIZE, cfg.POOLING_SIZE)))

      all_roi = []
      for j in range(rois.size(0)):
        _grid = grid.narrow(0, j, 1)
        _roi_feature = F.grid_sample(bottom.view(1,bottom.size(1), bottom.size(2), bottom.size(3)), _grid)
        all_roi.append(_roi_feature)
      crops = torch.cat(all_roi)
      # crops = F.grid_sample(bottom.expand(rois.size(0), bottom.size(1), bottom.size(2), bottom.size(3)), grid)

    return crops 
開發者ID:yxgeee,項目名稱:pytorch-FPN,代碼行數:56,代碼來源:network.py


注:本文中的model.config.cfg.POOLING_SIZE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。