简体   繁体   中英

mxnet sagemaker load model

I'm trying to load an already trained model from sagemaker MXnet.

I have the model.tar.gz file, however, when I try to do

> %%bash
> tar -xzf model.tar.gz rm model.tar.gz
> prefix = 'model_name' 
> sym, arg_params, aux_params = mx.model.load_checkpoint(prefix, 0) 
> mod = mx.mod.Module(symbol=sym,
> context=ctx, label_names=None) mod.bind(for_training=False, data_shapes=[('data', (1,3,480,480))], label_shapes=mod._label_shapes)
> mod.set_params(arg_params, aux_params)

I keep getting the error Error in operator multibox_target: [09:08:47] src/operator/contrib/./multibox_target-inl.h:225: Check failed: lshape.ndim() == 3 (0 vs. 3) Label should be [batch-num_labels-(>=5)] tensor

Can anyone help me with this?

I believe you have to run deploy.py prior to being able to prediction. check out incubator-mxnet\\example\\ssd\\deploy.py and note the model files need to be in a subdirectory of the directory where deploy.py is located.

this worked for my resnet50 based model.

python deploy.py --network resnet50 --prefix model2/model_algo_1 --num-class 2 --data-shape 416

Thank you @lwebuser suggestion. I wrote an end-to-end example at the jupyter notebook. Here is the link

You can see the result:

推理结果

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM