mmdnn Command Description

  Caffe turn mxnet model --mmdnn mentioned mmdnn using the model conversion was not very clear command conversion, recently re-checked some, finishing at mmdnn conversion command.

Step conversion

  mmdnn step conversion command is mmconvert, from mmdnn / conversion / _script / convert.py, whose parameters are:

command meaning
-sf Enter the model type
-in Enter the model of the network (if the network file independent)
-iw Enter the weights file
-df Output model type
-if Output Model Name

  During generated .py, .npy intermediate structure model as a model of the target code form. In addition, like TensorFlow model need to specify the output node, such as -dstNode MMdnn_Output, but -dstNode I did not find the key value in the convert.py do not know running will not be a problem.
  Example:

mmconvert -sf tensorflow -in imagenet_resnet_v2_152.ckpt.meta -iw imagenet_resnet_v2_152.ckpt --dstNode MMdnn_Output -df pytorch -om tf_to_pytorch_resnet_152.pth
python -m mmdnn.conversion._script.convertToIR -sf tensorflow -in imagenet_resnet_v2_152.ckpt.meta -iw imagenet_resnet_v2_152.ckpt --dstNode MMdnn_Output -df pytorch -om tf_to_pytorch_resnet_152.pth



Step conversion

1, turn IR

  Other models to convert mmdnn IR command format is mmtoir, from mmdnn / conversion / _script / convertToIR.py, which parameters are:

command meaning
-f Enter the model type
-n Enter the model of the network (if the network file independent)
-w Enter the weights file
–inputShape Input Size (optional)
-node An output node (TensorFlow)
-O Intermediate file name .json, .pb, .npy

  Example:

mmtoir -f tensorflow -n imagenet_resnet_v2_152.ckpt.meta -w imagenet_resnet_v2_152.ckpt --inputShape 3,112,112 -node MMdnn_Output -o converted
python -m mmdnn.conversion._script.convertToIR -f tensorflow -n imagenet_resnet_v2_152.ckpt.meta -w imagenet_resnet_v2_152.ckpt --inputShape 3,112,112 -node MMdnn_Output -o converted

2, IR turn output model Code

  mmdnn transform IR code format to another form of the model command mmtocode, from mmdnn / conversion / _script / IRToCode.py, which parameters are:

command meaning
-f Output model type
-n IR model structure
-w IR model weights
-O Output model structure
-dw Output model weights (optional)

  Example:

mmtocode -f pytorch -n converted.pb -w converted.npy -o converted_pytorch.py -dw converted_pytorch.npy
python -m mmdnn.conversion._script. IRToCode -f pytorch -n converted.pb -w converted.npy -o converted_pytorch.py -dw converted_pytorch.npy

3. Export final model

  mmdnn Export command the ultimate goal of the model is mmtomodel, from mmdnn / conversion / _script / IRToModel.py, whose parameters are:

command meaning
-f Output model type
-in Output model structure
-iw IR model weights
-O Output Model Name

  Example:

mmtomodel -f pytorch -in converted_pytorch.py -iw converted_pytorch.npy -o converted_pytorch.pth
python -m mmdnn.conversion._script. IRToModel -f pytorch -in converted_pytorch.py -iw converted_pytorch.npy -o converted_pytorch.pth

  

  

发布了24 篇原创文章 · 获赞 8 · 访问量 2万+

Guess you like

Origin blog.csdn.net/yangjf91/article/details/90676419