Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
[MXNET-696] Fix undefined variable errors (#11982)
Browse files Browse the repository at this point in the history
* Fix undefined error in image segmentation

ctx is used undefined. Setting the default ctx to cpu and
editing the comment to let the user know that it can be
changed to GPU as required.

* Fix undefined names in SSD example

maskUtils is disabled. Remove code referencing it.
Initializing start_offset.
  • Loading branch information
vandanavk authored and nswamy committed Aug 9, 2018
1 parent 39a4ea4 commit b9673a9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
4 changes: 2 additions & 2 deletions example/fcn-xs/image_segmentaion.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def main():
model_prefix = "FCN8s_VGG16"
epoch = 19

# By default, MXNet will run on the CPU. Uncomment the line below to execute on the GPU
# ctx = mx.gpu()
# By default, MXNet will run on the CPU. Change to ctx = mx.gpu() to run on GPU.
ctx = mx.cpu()

fcnxs, fcnxs_args, fcnxs_auxs = mx.model.load_checkpoint(model_prefix, epoch)
fcnxs_args["data"] = mx.nd.array(get_data(args.input), ctx)
Expand Down
17 changes: 0 additions & 17 deletions example/ssd/dataset/pycocotools/coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,22 +255,7 @@ def showAnns(self, anns):
color.append(c)
else:
# mask
t = self.imgs[ann['image_id']]
if type(ann['segmentation']['counts']) == list:
# rle = maskUtils.frPyObjects([ann['segmentation']], t['height'], t['width'])
raise NotImplementedError("maskUtils disabled!")
else:
rle = [ann['segmentation']]
# m = maskUtils.decode(rle)
raise NotImplementedError("maskUtils disabled!")
img = np.ones( (m.shape[0], m.shape[1], 3) )
if ann['iscrowd'] == 1:
color_mask = np.array([2.0,166.0,101.0])/255
if ann['iscrowd'] == 0:
color_mask = np.random.random((1, 3)).tolist()[0]
for i in range(3):
img[:,:,i] = color_mask[i]
ax.imshow(np.dstack( (img, m*0.5) ))
if 'keypoints' in ann and type(ann['keypoints']) == list:
# turn skeleton into zero-based index
sks = np.array(self.loadCats(ann['category_id'])[0]['skeleton'])-1
Expand Down Expand Up @@ -430,6 +415,4 @@ def annToMask(self, ann):
:return: binary mask (numpy 2D array)
"""
rle = self.annToRLE(ann)
# m = maskUtils.decode(rle)
raise NotImplementedError("maskUtils disabled!")
return m
3 changes: 3 additions & 0 deletions example/ssd/symbol/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ def multibox_layer(from_layers, num_classes, sizes=[.2, .95],
assert sizes[0] > 0 and sizes[0] < 1
assert sizes[1] > 0 and sizes[1] < 1 and sizes[1] > sizes[0]
tmp = np.linspace(sizes[0], sizes[1], num=(len(from_layers)-1))
# Ref for start_offset value:
# https://arxiv.org/abs/1512.02325
start_offset = 0.1
min_sizes = [start_offset] + tmp.tolist()
max_sizes = tmp.tolist() + [tmp[-1]+start_offset]
sizes = zip(min_sizes, max_sizes)
Expand Down

0 comments on commit b9673a9

Please sign in to comment.