From 5452901f958b370025c3484abc116e0a80fd228f Mon Sep 17 00:00:00 2001 From: vandanavk Date: Wed, 1 Aug 2018 11:52:42 -0700 Subject: [PATCH] Fix undefined names in SSD example maskUtils is disabled. Comment out all code referencing it. Initializing start_offset. --- example/ssd/dataset/pycocotools/coco.py | 31 +++++++++++++------------ example/ssd/symbol/common.py | 3 +++ 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/example/ssd/dataset/pycocotools/coco.py b/example/ssd/dataset/pycocotools/coco.py index 19a7b8b7f64d..1d2651394aa8 100755 --- a/example/ssd/dataset/pycocotools/coco.py +++ b/example/ssd/dataset/pycocotools/coco.py @@ -255,22 +255,23 @@ def showAnns(self, anns): color.append(c) else: # mask - t = self.imgs[ann['image_id']] - if type(ann['segmentation']['counts']) == list: + raise NotImplementedError("maskUtils disabled!") + # 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']] + # 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) )) + # 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 @@ -432,4 +433,4 @@ def annToMask(self, ann): rle = self.annToRLE(ann) # m = maskUtils.decode(rle) raise NotImplementedError("maskUtils disabled!") - return m + # return m diff --git a/example/ssd/symbol/common.py b/example/ssd/symbol/common.py index 4a0458f87288..a2fb4e69d18c 100644 --- a/example/ssd/symbol/common.py +++ b/example/ssd/symbol/common.py @@ -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)