Category: gluoncv

gluoncv is based on mxnet, it’s very flexible and easy to use for object detection.

Since mxnet is almost ready on rocm platform, gluoncv would be possiblely available to be used on rocm.

This post is to track to building of gluoncv on rocm.

1. git clone

git clone --recurse-submodules https://github.com/ROCmSoftwarePlatform/mxnet.git -b downstream_27Mar2018

there are 3rd party components so –recurse-submodules is needed.

2. hipfft has been replaced by rocfft, so change hipfft to rocfft in mxnet/Makefile.

3. mxnet requested version is 1.3.0, but the downstream branch is 1.2.0. So changed this version in gluon-cv/gluoncv/__init__.py.

4. met an error when running:

from gluoncv import model_zoo, data, utils

net = model_zoo.get_model('ssd_512_resnet50_v1_voc', pretrained=True)

mxnet.gluon.Block has no attribute ‘load_parameters’. The current supported function is ‘load_params’. So changed it in gluon-cv/gluoncv/model_zoo/ssd/ssd.py

5. slice_like is missing in mxnet/symbol/gen_op.py.

Similar issue is reported here: https://discuss.gluon.ai/t/topic/7934/11

seems need to update mxnet. (need to check newer version of rocm based mxnet)

hacked gluoncv/model_zoo/ssd/anchor.py:

def hybrid_forward(self, F, x, anchors):
    #a = F.slice_like(anchors, x * 0, axes=(2, 3))
    #------- rocky 20181022: ---------------
    a = F.slice(anchors, begin=tuple([0]*len(anchors.shape)), end=(None,None, x.shape[2], x.shape[3], None))
    #---------------------------------------

temp solved this issue.

6. mxnet.base.MXNetError: Cannot find argument ‘valid_thresh’

There is no ‘valid_thresh’ parameter in def box_nms in:

mxnet/python/mxnet/symbol/gen_contrib.py

So remove this param from  gluoncv/model_zoo/ssd/ssd.py

        if self.nms_thresh > 0 and self.nms_thresh < 1:

            #------- rockyli, mxnet 1.2.0 has no valid_thresh param for contrib.box_nms)
            print "debug before F.contrib.box_nms"
            print result
            result = F.contrib.box_nms(
                #result, overlap_thresh=self.nms_thresh, topk=self.nms_topk, valid_thresh=0.01,
                result, overlap_thresh=self.nms_thresh, topk=self.nms_topk,
                id_index=0, score_index=1, coord_start=2, force_suppress=False)

This can temp solve above issue.

Now the object detection is Ok using a pre trained ssd VOC model with a sample image.

 

www.000webhost.com