gluon ssd"ssd_512_resnet50_v1_custom" failed to convert to onnx !
Description
I tried to convert gluon model(ssd_512_resnet50_v1_custom) to onnx, but failed !
Error Message
Traceback (most recent call last):
File “ssd_gluon.py”, line 79, in
converted_model_path = onnx_mxnet.export_model(net_sym, net_params, [input_shape], np.float32, onnx_file, verbose=True)
File “anaconda2/envs/Python3/lib/python3.6/site-packages/mxnet/contrib/onnx/mx2onnx/export_model.py”, line 89, in export_model
raise ValueError(“Input sym and params should either be files or objects”)
ValueError: Input sym and params should either be files or objects
To Reproduce
import os
import mxnet as mx
import numpy as np
from mxnet import gluon, sym
from gluoncv.model_zoo import get_model
from mxnet.contrib import onnx as onnx_mxnet
from mxnet.contrib.onnx.mx2onnx._export_helper import load_module
# Load Model
model_name = 'ssd_512_resnet50_v1_custom'
resume_params = './ssd/ssd_512_resnet50_v1_custom_best.params'
pretrained = False
ctx = [mx.gpu(1)]
class_names = ['car','truck','bus','moto']
net = get_model(model_name, ctx=ctx, pretrained=False, norm_layer=gluon.nn.BatchNorm, classes=class_names, transfer='voc')
net.load_parameters(resume_params, ctx = ctx)
net.set_nms(nms_thresh=0.45, nms_topk=200)
net.hybridize()
net_sym = net(sym.Variable('data'))
net_params = {name:param._reduce() for name, param in net.collect_params().items()}
#net_params.update({})
# Standard Imagenet input - 3 channels, 224*224
input_shape = (1,3,512,512)
# Path of the output file
onnx_file = './ssd_gluon.onnx'
converted_model_path = onnx_mxnet.export_model(net_sym, net_params, [input_shape], np.float32, onnx_file, verbose=True)
Environment
Mxnet: 1.5.0
onnx: 1.6.0