Skip to content

Commit

Permalink
Fix some error when runing with Synopsys Caffe, but still not running
Browse files Browse the repository at this point in the history
Fixed error:
1. AttributeError: 'ProposalLayer' object has no attribute 'param_str_'
2. pre_nms_topN = cfg[cfg_key].RPN_PRE_NMS_TOP_N, KeyError: '1'
3. cached dataset not removed error, which will cause the test phase accuracy calculation fail

Reference:
rbgirshick#219

We need to manually remove the cached dataset in data/cache and data/VOCdevkit0712/annotations_cache when you change the train or test list in data/VOCdevkit0712/VOC0712/ImageSets/Main/

Current still facing issue
I0530 09:49:44.784348  8794 sgd_solver.cpp:144] Iteration 80, lr = 0.0005
F0530 09:50:07.775352  8794 io.cpp:87] Check failed: proto.SerializeToOstream(&output)
*** Check failure stack trace: ***
Aborted (core dumped)

Signed-off-by: Huaqi Fang <[email protected]>
  • Loading branch information
fanghuaqi committed May 30, 2018
1 parent 8e494b4 commit da737cd
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
4 changes: 4 additions & 0 deletions lib/datasets/voc_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ def voc_eval(detpath,
# extract gt objects for this class
class_recs = {}
npos = 0
#print "cachedir : {}".format(cachedir)
#print "imagenames " +str(imagenames)
for imagename in imagenames:
#for obj in recs[imagename]:
# print "Rec " +str(obj)
R = [obj for obj in recs[imagename] if obj['name'] == classname]
bbox = np.array([x['bbox'] for x in R])
difficult = np.array([x['difficult'] for x in R]).astype(np.bool)
Expand Down
2 changes: 1 addition & 1 deletion lib/roi_data_layer/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def setup(self, bottom, top):
"""Setup the RoIDataLayer."""

# parse the layer parameter string, which must be valid YAML
layer_params = yaml.load(self.param_str_)
layer_params = yaml.load(self.param_str)

self._num_classes = layer_params['num_classes']

Expand Down
2 changes: 1 addition & 1 deletion lib/rpn/anchor_target_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class AnchorTargetLayer(caffe.Layer):
"""

def setup(self, bottom, top):
layer_params = yaml.load(self.param_str_)
layer_params = yaml.load(self.param_str)
anchor_scales = layer_params.get('scales', (8, 16, 32))
self._anchors = generate_anchors(scales=np.array(anchor_scales))
self._num_anchors = self._anchors.shape[0]
Expand Down
4 changes: 2 additions & 2 deletions lib/rpn/proposal_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ProposalLayer(caffe.Layer):

def setup(self, bottom, top):
# parse the layer parameter string, which must be valid YAML
layer_params = yaml.load(self.param_str_)
layer_params = yaml.load(self.param_str)

self._feat_stride = layer_params['feat_stride']
anchor_scales = layer_params.get('scales', (8, 16, 32))
Expand Down Expand Up @@ -61,7 +61,7 @@ def forward(self, bottom, top):
assert bottom[0].data.shape[0] == 1, \
'Only single item batches are supported'

cfg_key = str(self.phase) # either 'TRAIN' or 'TEST'
cfg_key = 'TEST' if self.phase == 1 else 'TRAIN' # either 'TRAIN' or 'TEST'
pre_nms_topN = cfg[cfg_key].RPN_PRE_NMS_TOP_N
post_nms_topN = cfg[cfg_key].RPN_POST_NMS_TOP_N
nms_thresh = cfg[cfg_key].RPN_NMS_THRESH
Expand Down
2 changes: 1 addition & 1 deletion lib/rpn/proposal_target_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ProposalTargetLayer(caffe.Layer):
"""

def setup(self, bottom, top):
layer_params = yaml.load(self.param_str_)
layer_params = yaml.load(self.param_str)
self._num_classes = layer_params['num_classes']

# sampled rois (0, x1, y1, x2, y2)
Expand Down
9 changes: 6 additions & 3 deletions lib/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,24 @@ def locate_cuda():
Returns a dict with keys 'home', 'nvcc', 'include', and 'lib64'
and values giving the absolute path to each directory.
Starts by looking for the CUDAHOME env variable. If not found, everything
Starts by looking for the CUDAHOME or CUDA_HOME env variable. If not found, everything
is based on finding 'nvcc' in the PATH.
"""

# first check if the CUDAHOME env variable is in use
# first check if the CUDAHOME or CUDA_HOME env variable is in use
if 'CUDAHOME' in os.environ:
home = os.environ['CUDAHOME']
nvcc = pjoin(home, 'bin', 'nvcc')
elif 'CUDA_HOME' in os.environ:
home = os.environ['CUDA_HOME']
nvcc = pjoin(home, 'bin', 'nvcc')
else:
# otherwise, search the PATH for NVCC
default_path = pjoin(os.sep, 'usr', 'local', 'cuda', 'bin')
nvcc = find_in_path('nvcc', os.environ['PATH'] + os.pathsep + default_path)
if nvcc is None:
raise EnvironmentError('The nvcc binary could not be '
'located in your $PATH. Either add it to your path, or set $CUDAHOME')
'located in your $PATH. Either add it to your path, or set $CUDA_HOME or $CUDAHOME')
home = os.path.dirname(os.path.dirname(nvcc))

cudaconfig = {'home':home, 'nvcc':nvcc,
Expand Down

0 comments on commit da737cd

Please sign in to comment.