Skip to content

Commit

Permalink
fixed int conversion issue in faster rcnn
Browse files Browse the repository at this point in the history
  • Loading branch information
Bharat Singh committed Feb 6, 2017
1 parent 56bdc72 commit 70311df
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion experiments/cfgs/faster_rcnn_end2end.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ TRAIN:
PROPOSAL_METHOD: gt
BG_THRESH_LO: 0.0
TEST:
HAS_RPN: True
HAS_RPN: True
7 changes: 4 additions & 3 deletions lib/roi_data_layer/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
class RoIDataLayer(caffe.Layer):
"""Fast R-CNN data layer used for training."""

def _shuffle_roidb_inds(self, gpu_id):
def _shuffle_roidb_inds(self, gpu_id=0):
self.gpu_id = gpu_id
"""Randomly permute the training roidb."""
if cfg.TRAIN.ASPECT_GROUPING:
Expand Down Expand Up @@ -64,7 +64,7 @@ def _get_next_minibatch(self):
minibatch_db = [self._roidb[i] for i in db_inds]
return get_minibatch(minibatch_db, self._num_classes)

def set_roidb(self, roidb, gpu_id):
def set_roidb(self, roidb, gpu_id=0):
"""Set the roidb to be used by this layer during training."""
self._roidb = roidb
self._shuffle_roidb_inds(gpu_id)
Expand Down Expand Up @@ -125,6 +125,7 @@ def setup(self, bottom, top):
# bbox_targets blob: R bounding-box regression targets with 4
# targets per class
num_reg_class = 2 if cfg.TRAIN.AGNOSTIC else self._num_classes

top[idx].reshape(1, num_reg_class * 4, 1, 1)
self._name_to_top_map['bbox_targets'] = idx
idx += 1
Expand Down Expand Up @@ -167,7 +168,7 @@ def reshape(self, bottom, top):

class BlobFetcher(Process):
"""Experimental class for prefetching blobs in a separate process."""
def __init__(self, queue, roidb, num_classes, gpu_id):
def __init__(self, queue, roidb, num_classes, gpu_id=0):
super(BlobFetcher, self).__init__()
self._queue = queue
self._roidb = roidb
Expand Down
9 changes: 4 additions & 5 deletions lib/rpn/proposal_target_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from fast_rcnn.config import cfg
from fast_rcnn.bbox_transform import bbox_transform
from utils.cython_bbox import bbox_overlaps

DEBUG = False

class ProposalTargetLayer(caffe.Layer):
Expand Down Expand Up @@ -141,8 +140,8 @@ def _get_bbox_regression_labels(bbox_target_data, num_classes):
else:
for ind in inds:
cls = clss[ind]
start = 4 * cls
end = start + 4
start = int(4 * cls)
end = int(start + 4)
bbox_targets[ind, start:end] = bbox_target_data[ind, 1:]
bbox_inside_weights[ind, start:end] = cfg.TRAIN.BBOX_INSIDE_WEIGHTS
return bbox_targets, bbox_inside_weights
Expand Down Expand Up @@ -179,7 +178,7 @@ def _sample_rois(all_rois, gt_boxes, fg_rois_per_image, rois_per_image, num_clas
fg_inds = np.where(max_overlaps >= cfg.TRAIN.FG_THRESH)[0]
# Guard against the case when an image has fewer than fg_rois_per_image
# foreground RoIs
fg_rois_per_this_image = min(fg_rois_per_image, fg_inds.size)
fg_rois_per_this_image = int(min(fg_rois_per_image, fg_inds.size))
# Sample foreground regions without replacement
if fg_inds.size > 0:
fg_inds = npr.choice(fg_inds, size=fg_rois_per_this_image, replace=False)
Expand All @@ -190,7 +189,7 @@ def _sample_rois(all_rois, gt_boxes, fg_rois_per_image, rois_per_image, num_clas
# Compute number of background RoIs to take from this image (guarding
# against there being fewer than desired)
bg_rois_per_this_image = rois_per_image - fg_rois_per_this_image
bg_rois_per_this_image = min(bg_rois_per_this_image, bg_inds.size)
bg_rois_per_this_image = int(min(bg_rois_per_this_image, bg_inds.size))
# Sample background regions without replacement
if bg_inds.size > 0:
bg_inds = npr.choice(bg_inds, size=bg_rois_per_this_image, replace=False)
Expand Down

0 comments on commit 70311df

Please sign in to comment.