Cannot load the json symbol of yolov3 provided by gluoncv


#1

First, I convert the models of yolo v3 to json

from gluoncv import model_zoo, data, utils

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

im_fname = utils.download('https://raw.githubusercontent.com/zhreshold/' +
                          'mxnet-ssd/master/data/demo/dog.jpg',
                          path='dog.jpg')
x, img = data.transforms.presets.yolo.load_test(im_fname, short=320)
print('Shape of pre-processed image:', x.shape)

net.hybridize()
class_IDs, scores, bounding_boxs = net(x)
net.export("yolov3.json", epoch=279)

Second, load the yolov3.json by c++ api

#include <mxnet-cpp/MxNetCpp.h>
#include <iostream>

using namespace mxnet::cpp;
using namespace std;


int main()try

{
    std::string const prefix("C:/Users/yyyy/.mxnet/models/yolo3");
    Symbol::Load(prefix + ".json");

    return 0;
}catch(std::exception const &amp;ex){
    cerr<<ex.what()<<endl;
}

But it throw exception

[21:09:34] …\3rdLibs\incubator-mxnet\build\install\include\mxnet-cpp/symbol.hpp:102: Check failed: MXSymbolCreateFromFile(file_name.c_str(), &(handle)) == 0 (-1 vs. 0)

What kind of error I commit?How could I solve it?Thanks

ps : This codes can load the symbol from MTCNN.


#2

Find solution in the tutorial folder of gluoncv

import gluoncv as gcv
from gluoncv.utils import export_block

net = gcv.model_zoo.get_model('yolo3_darknet53_coco', pretrained=True)
export_block('yolo3_darknet53_coco', net)

#3

thanks for reporting the solution @stereomatchingkiss!