mmdnn实现模型转换

1、转IR

mmtoir/python3 -m mmdnn.conversion._script.convertToIR

python3 -m mmdnn.conversion._script.convertToIR -f mxnet -n model-symbol.json -w model-0000.params --inputShape 3,112,112 -o IR34

输出:

UserWarning: You created Module with Module(..., label_names=['softmax_label']) but input with name 'softmax_label' is not found in symbol.list_arguments(). Did you mean one of:
    data
  warnings.warn(msg)
Warning: MXNet Parser has not supported operator null with name data.
Warning: convert the null operator with name [data] into input layer.
IR network structure is saved as [IR34.json].
IR network structure is saved as [IR34.pb].
IR weights are saved as [IR34.npy]

2、IR转输出模型Code

mmtocode/python3 -m mmdnn.conversion._script.IRToCode

python3 -m mmdnn.conversion._script.IRToCode -f pytorch --IRModelPath IR34.pb --IRWeightPath IR34.npy  -o IR34-2.py -dw IR34-2.npy

输出:

Parse file [IR34.pb] with binary format successfully.
Target network code snippet is saved as [IR34-2.py].
Target weights are saved as [IR34-2.npy].
 

3、导出最终模型

mmtomodel -f pytorch -in IR34-2.py -iw IR34-2.npy -o IR34_pytorch.pth

输出:

PyTorch model file is saved as [IR34_pytorch.pth], generated by [IR34-2.py] and [IR34-2.npy]. Notice that you may need [IR34-2.py] to load the model back.

用mmdnn.conversion._script.IRToCode会报错,不知道啥鬼。

你可能感兴趣的:(general)