MXNet: simple_bind error when loading model

Hi,

I’m trying to use the trained mobilenet-ssd-512 model from the following link:

https://github.com/zhreshold/mxnet-ssd/releases/download/v0.7-alpha/ssd_resnet50_512_voc0712trainval.zip

The repo:

I’ve tried to load it as follow:

# User input- model
model_path = "./models/"
model_name = 'mobilenet-ssd-512'
input_size = 512

# Load the model
print('Start import model %s' % (model_path + model_name))
ctx = mx.cpu()
sym, arg_params, aux_params = mx.model.load_checkpoint(model_path+model_name, 0)
mod = mx.mod.Module(symbol=sym, context=ctx, label_names=None)
mod.bind(data_shapes=[('data', (1, 3, input_size, input_size))]) 
mod.set_params(arg_params, aux_params, allow_missing=True)
print('Finish import model %s' % (model_path + model_name))

However, got the following error:

Start import model ./models/mobilenet-ssd-512
[11:47:40] src/nnvm/legacy_json_util.cc:190: Loading symbol saved by previous version v0.12.0. Attempting to upgrade…
[11:47:40] src/nnvm/legacy_json_util.cc:198: Symbol successfully upgraded!

mxnet.base.MXNetError: Error in operator multibox_target: [11:47:40] src/operator/contrib/./multibox_target-inl.h:225: Check failed: lshape.ndim() == 3 (0 vs. 3) Label should be [batch-num_labels-(>=5)] tensor

RuntimeError: simple_bind error. Arguments:
data: (1, 3, 512, 512)
Error in operator multibox_target: [11:47:40] src/operator/contrib/./multibox_target-inl.h:225: Check failed: lshape.ndim() == 3 (0 vs. 3) Label should be [batch-num_labels-(>=5)] tensor

Did i missed something?

here is my similar issue

The model you are loading was created for training. For inference, you need a model created for inference without training artifacts like MultiBoxTarget.

If you still want to load the model with MultiBoxTarget, you need to provide label shape too. Example:

mod.bind(data_shapes=[( 'data', (1, 3, input_size, input_size))], label_shapes=[('label', (1, 1, 5))])
1 Like