-
Notifications
You must be signed in to change notification settings - Fork 0
Description
I've followed exactly that's been provided:
%matplotlib inline
import os
from matplotlib import pyplot as plt
import matplotlib.pylab as pylab
from mlearning.mlearning import util
from mlearning.mlearning.coco import Annotation
from mlearning.mlearning.plotting import plot_bboxes_and_masks
pylab.rcParams['figure.figsize'] = 12, 12
ann = Annotation(path=os.path.join(os.path.expanduser('~'), 'Documents/DAS/train_ann'))
plot_bboxes_and_masks(ann)
Error
ValueError Traceback (most recent call last)
in
16
17 # this is the function that displays a random example
---> 18 plot_bboxes_and_masks(ann)
~/Downloads/mlearning/mlearning/plotting.py in plot_bboxes_and_masks(ann, image_id)
16
17 def plot_bboxes_and_masks(ann, image_id=None):
---> 18 image_ids = ann.get_image_ids()
19 imageid_to_ann = ann.get_imageid_to_ann()
20 imageid_to_imageann = ann.get_imageid_to_imageann()
~/Downloads/mlearning/mlearning/coco.py in get_image_ids(self)
182 def get_image_ids(self):
183 "Returns a list of image ids"
--> 184 return list(self.get_imageid_to_ann())
185
186 def get_category_id_to_name(self):
~/Downloads/mlearning/mlearning/coco.py in get_imageid_to_ann(self)
175 imageid_to_anns[img['id']] = []
176
--> 177 for a in self.get_annotations():
178 imageid_to_anns[a['image_id']].append(a)
179
~/Downloads/mlearning/mlearning/coco.py in get_annotations(self)
144 d = {
145 'area': None,
--> 146 'bbox': self.get_annotation_bbox(shape['points']),
147 'category_id': label_to_category_id_map[shape['label']],
148 'id': ann_id,
~/Downloads/mlearning/mlearning/coco.py in get_annotation_bbox(self, labelme_bb)
116 def get_annotation_bbox(self, labelme_bb):
117 np_bbs = np.array(labelme_bb)
--> 118 bbs = np.reshape(np_bbs, (-1, 4))
119 return np.array(
120 [bbs[:,0], bbs[:,1], bbs[:,2]-bbs[:,0], bbs[:,3]-bbs[:,1]]
~/anaconda3/lib/python3.7/site-packages/numpy/core/fromnumeric.py in reshape(a, newshape, order)
290 [5, 6]])
291 """
--> 292 return _wrapfunc(a, 'reshape', newshape, order=order)
293
294
~/anaconda3/lib/python3.7/site-packages/numpy/core/fromnumeric.py in _wrapfunc(obj, method, *args, **kwds)
54 def _wrapfunc(obj, method, *args, **kwds):
55 try:
---> 56 return getattr(obj, method)(*args, **kwds)
57
58 # An AttributeError occurs if the object does not have
ValueError: cannot reshape array of size 26 into shape (4)