dmlc / gluon-cv

Gluon CV Toolkit
http://gluon-cv.mxnet.io
Apache License 2.0
5.85k stars 1.22k forks source link

problems with faster rcnn with gluoncv==0.3.0b20180813 #254

Open ghost opened 6 years ago

ghost commented 6 years ago

this is the code following with tutorial

In [1]: from gluoncv import model_zoo, data, utils

In [2]: net = model_zoo.get_model('faster_rcnn_resnet50_v1b_voc', pretrained=True)

In [4]: im_fname = 'biking.jpg'

In [5]: x, orig_img = data.transforms.presets.rcnn.load_test(im_fname)

In [6]: box_ids, scores, bboxes = net(x)

when I run the box_ids, scores, bboxes = net(x), it raises error like following:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-6-83c95a88bb0d> in <module>()
----> 1 box_ids, scores, bboxes = net(x)

/opt/anaconda2/envs/python3-cv/lib/python3.6/site-packages/mxnet/gluon/block.py in __call__(self, *args)
    469     def __call__(self, *args):
    470         """Calls forward. Only accepts positional arguments."""
--> 471         return self.forward(*args)
    472
    473     def forward(self, *args):

/opt/anaconda2/envs/python3-cv/lib/python3.6/site-packages/mxnet/gluon/block.py in forward(self, x, *args)
    711                     return self._call_cached_op(x, *args)
    712                 params = {i: j.data(ctx) for i, j in self._reg_params.items()}
--> 713                 return self.hybrid_forward(ndarray, x, *args, **params)
    714
    715         assert isinstance(x, Symbol), \

/opt/anaconda2/envs/python3-cv/lib/python3.6/site-packages/gluoncv/model_zoo/faster_rcnn/faster_rcnn.py in hybrid_forward(self, F, x, gt_box)
    204             rpn_box, samples, matches = self.sampler(rpn_box, rpn_score, gt_box)
    205         else:
--> 206             _, rpn_box = self.rpn(feat, F.zeros_like(x))
    207
    208         # create batchid for roi

/opt/anaconda2/envs/python3-cv/lib/python3.6/site-packages/mxnet/gluon/block.py in __call__(self, *args)
    469     def __call__(self, *args):
    470         """Calls forward. Only accepts positional arguments."""
--> 471         return self.forward(*args)
    472
    473     def forward(self, *args):

/opt/anaconda2/envs/python3-cv/lib/python3.6/site-packages/mxnet/gluon/block.py in forward(self, x, *args)
    711                     return self._call_cached_op(x, *args)
    712                 params = {i: j.data(ctx) for i, j in self._reg_params.items()}
--> 713                 return self.hybrid_forward(ndarray, x, *args, **params)
    714
    715         assert isinstance(x, Symbol), \

/opt/anaconda2/envs/python3-cv/lib/python3.6/site-packages/gluoncv/model_zoo/rpn/rpn.py in hybrid_forward(self, F, x, img)
     99         rpn_box_pred = self.loc(x).transpose(axes=(0, 2, 3, 1)).reshape((0, -1, 4))
    100         rpn_score, rpn_box = self.region_proposaler(
--> 101             anchors, rpn_scores, F.stop_gradient(rpn_box_pred), img)
    102         if autograd.is_training():
    103             # return raw predictions as well in training for bp

/opt/anaconda2/envs/python3-cv/lib/python3.6/site-packages/mxnet/gluon/block.py in __call__(self, *args)
    469     def __call__(self, *args):
    470         """Calls forward. Only accepts positional arguments."""
--> 471         return self.forward(*args)
    472
    473     def forward(self, *args):

/opt/anaconda2/envs/python3-cv/lib/python3.6/site-packages/mxnet/gluon/block.py in forward(self, x, *args)
    711                     return self._call_cached_op(x, *args)
    712                 params = {i: j.data(ctx) for i, j in self._reg_params.items()}
--> 713                 return self.hybrid_forward(ndarray, x, *args, **params)
    714
    715         assert isinstance(x, Symbol), \

/opt/anaconda2/envs/python3-cv/lib/python3.6/site-packages/gluoncv/model_zoo/rpn/proposal.py in hybrid_forward(self, F, anchor, score, bbox_pred, img)
     66             # clip rois to image's boundary
     67             # roi = F.Custom(roi, img, op_type='bbox_clip_to_image')
---> 68             roi = self._clipper(roi, img)
     69
     70             # remove bounding boxes that don't meet the min_size constraint

/opt/anaconda2/envs/python3-cv/lib/python3.6/site-packages/mxnet/gluon/block.py in __call__(self, *args)
    469     def __call__(self, *args):
    470         """Calls forward. Only accepts positional arguments."""
--> 471         return self.forward(*args)
    472
    473     def forward(self, *args):

/opt/anaconda2/envs/python3-cv/lib/python3.6/site-packages/mxnet/gluon/block.py in forward(self, x, *args)
    711                     return self._call_cached_op(x, *args)
    712                 params = {i: j.data(ctx) for i, j in self._reg_params.items()}
--> 713                 return self.hybrid_forward(ndarray, x, *args, **params)
    714
    715         assert isinstance(x, Symbol), \

/opt/anaconda2/envs/python3-cv/lib/python3.6/site-packages/gluoncv/nn/bbox.py in hybrid_forward(self, F, x, img)
    219         x = F.maximum(x, 0.0)
    220         # window [B, 2] -> reverse hw -> tile [B, 4] -> [B, 1, 4], boxes [B, N, 4]
--> 221         window = F.shape_array(img).slice_axis(axis=0, begin=2, end=None).expand_dims(0)
    222         m = F.tile(F.reverse(window, axis=1), reps=(2,)).reshape((0, -4, 1, -1))
    223         return F.broadcast_minimum(x, F.cast(m, dtype='float32'))

AttributeError: module 'mxnet.ndarray' has no attribute 'shape_array'
ijkguo commented 6 years ago

https://github.com/dmlc/gluon-cv/issues/239

shape_array is merged on July 12th. Please use latest mxnet or at least 1.3.0b20180713