Skip to content

Commit

Permalink
Update proposal_layer.py
Browse files Browse the repository at this point in the history
  • Loading branch information
unsky authored Jan 6, 2018
1 parent 9a28d3d commit d952d5b
Showing 1 changed file with 0 additions and 128 deletions.
128 changes: 0 additions & 128 deletions lib/rpn/proposal_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,134 +221,6 @@ def forward(self, bottom, top):
top[0].reshape(*(blob.shape))
top[0].data[...] = blob






















# p2_shape = bottom[3].data.shape
# p3_shape = bottom[4].data.shape
# p4_shape = bottom[5].data.shape
# p5_shape = bottom[6].data.shape
# p6_shape = bottom[7].data.shape
# feat_shape = []
# feat_shape.append(p2_shape)
# feat_shape.append(p3_shape)
# feat_shape.append(p4_shape)
# feat_shape.append(p5_shape)
# feat_shape.append(p6_shape)

# num_feat = len(feat_shape)#[1,5,4]
# score_index_start=0
# bbox_index_start=0
# keep_proposal = []
# keep_scores = []
# #########################

# for i in range(num_feat):
# feat_stride = int(self._feat_stride[i])#4,8,16,32,64
# #print 'feat_stride:', feat_stride
# anchor = generate_anchors(base_size=feat_stride, ratios=self._ratios, scales=self._scales)
# num_anchors = anchor.shape[0]#3
# height = feat_shape[i][2]
# width = feat_shape[i][3]
# shift_x = np.arange(0, width) * feat_stride
# shift_y = np.arange(0, height) * feat_stride
# shift_x, shift_y = np.meshgrid(shift_x, shift_y)
# shifts = np.vstack((shift_x.ravel(), shift_y.ravel(), shift_x.ravel(), shift_y.ravel())).transpose()
# A = num_anchors#3
# K = shifts.shape[0]#height*width
# anchors = anchor.reshape((1, A, 4)) + shifts.reshape((1, K, 4)).transpose((1, 0, 2))
# anchors = anchors.reshape((K * A, 4))#3*height*widht,4
# print scores_list.shape

# scores = scores_list[:,:,int(score_index_start):int(score_index_start+K*A)]

# bbox_deltas = bbox_deltas_list[int(bbox_index_start):int(bbox_index_start+K*A),:]
# score_index_start += K*A
# bbox_index_start += K*A

# bbox_deltas = clip_pad(bbox_deltas, (height, width))
# bbox_deltas = bbox_deltas.transpose((0, 2, 3, 1)).reshape((-1, 4))#[1,h,w,12]--->[1*h*w*3,4]
# scores = clip_pad(scores, (height, width))
# scores = scores.transpose((0, 2, 3, 1)).reshape((-1, 1))#[1,h,w,3]--->[1*h*w*3,1]
# proposals = bbox_transform_inv(anchors, bbox_deltas)#debug here, corresponding?
# proposals = clip_boxes(proposals, im_info[:2])

# keep = _filter_boxes(proposals, self._min_sizes[i] * im_info[2])

# keep_proposal.append(proposals[keep, :])
# keep_scores.append(scores[keep])
# proposals = keep_proposal[0]
# scores = keep_scores[0]
# for i in range(1,num_feat):
# proposals=np.vstack((proposals, keep_proposal[i]))
# scores=np.vstack((scores, keep_scores[i]))
# #print 'roi concate t_1 spends :{:.4f}s'.format(time.time()-t_1)
# # 4. sort all (proposal, score) pairs by score from highest to lowest
# # 5. take top pre_nms_topN (e.g. 6000)
# #t_2 = time.time()
# order = scores.ravel().argsort()[::-1]
# if pre_nms_topN > 0:
# order = order[:pre_nms_topN]
# proposals = proposals[order, :]
# scores = scores[order]
# #print 'roi concate t_2_1_1 spends :{:.4f}s'.format(time.time()-t_2)
# # 6. apply nms (e.g. threshold = 0.7)
# # 7. take after_nms_topN (e.g. 300)
# # 8. return the top proposals (-> RoIs top)
# #t_nms = time.time()
# det = np.hstack((proposals, scores)).astype(np.float32)
# keep = nms(det,nms_thresh)
# #print 'roi concate nms spends :{:.4f}s'.format(time.time()-t_nms)
# print len(keep)

# if post_nms_topN > 0:
# keep = keep[:post_nms_topN]

# # pad to ensure output size remains unchanged
# # if len(keep) < post_nms_topN:
# # try:
# # pad = npr.choice(keep, size=post_nms_topN - len(keep))
# # except:
# # proposals = np.zeros((post_nms_topN, 4), dtype=np.float32)
# # proposals[:,2] = 16
# # proposals[:,3] = 16
# # batch_inds = np.zeros((proposals.shape[0], 1), dtype=np.float32)
# # blob = np.hstack((batch_inds, proposals.astype(np.float32, copy=False)))
# # top[0].reshape(*(blob.shape))
# # top[0].data[...] = blob
# # return
# # keep = np.hstack((keep, pad))

# proposals = proposals[keep, :]
# scores = scores[keep]
# #print 'roi concate t_2 spends :{:.4f}s'.format(time.time()-t_2)
# # Output rois array
# # Our RPN implementation only supports a single input image, so all
# # batch inds are 0
# batch_inds = np.zeros((proposals.shape[0], 1), dtype=np.float32)
# blob = np.hstack((batch_inds, proposals.astype(np.float32, copy=False)))


# top[0].reshape(*(blob.shape))
# top[0].data[...] = blob

def backward(self, top, propagate_down, bottom):
"""This layer does not propagate gradients."""
Expand Down

0 comments on commit d952d5b

Please sign in to comment.