microsoft / MMdnn

MMdnn is a set of tools to help users inter-operate among different deep learning frameworks. E.g. model conversion and visualization. Convert models between Caffe, Keras, MXNet, Tensorflow, CNTK, PyTorch Onnx and CoreML.
MIT License
5.8k stars 965 forks source link

Problem converting mxnet model to keras #871

Open mkhoshle opened 4 years ago

mkhoshle commented 4 years ago

Platform (like ubuntu 16.04/win10): macOS Catalina V10.15.6

Python version: 3.8 Source framework with version (like Tensorflow 1.4.1 with GPU): mxnet1.6.0 Destination framework with version (like CNTK 2.3 with GPU): Keras '2.4.3' Pre-trained model path (webpath or webdisk path): https://www.dropbox.com/s/tj96fsm6t6rq8ye/model-r100-arcface-ms1m-refine-v2.zip?dl=0

Running scripts:

  1. python3 -m mmdnn.conversion._script.convertToIR -f mxnet -n pretrained_model/model-r100-ii/model-symbol.json -w pretrained_model/model-r100-ii/model-0000.params -d . --inputShape 3,112,112

  2. python3 -m mmdnn.conversion._script.IRToCode -f keras --IRModelPath ArcModel.pb --dstModelPath converted_ArcModel.py --IRWeightPath ArcModel.npy

  3. python3 -m mmdnn.conversion.examples.keras.imagenet_test -n converted_ArcModel.py -w ArcModel.npy --dump mxnet_ArcModel.h5

When I run the third command I get the following error, could anyone help me with this error, please?

Traceback (most recent call last):
  File "/Users/mahzadkhoshlessan/miniconda3/envs/DMG/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/mahzadkhoshlessan/miniconda3/envs/DMG/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/mahzadkhoshlessan/miniconda3/envs/DMG/lib/python3.8/site-packages/mmdnn/conversion/examples/keras/imagenet_test.py", line 157, in <module>
    tester = TestKeras()
  File "/Users/mahzadkhoshlessan/miniconda3/envs/DMG/lib/python3.8/site-packages/mmdnn/conversion/examples/keras/imagenet_test.py", line 31, in __init__
    self.model = self.MainModel.KitModel(self.args.w)
  File "converted_ArcModel.py", line 61, in KitModel
    minusscalar0    = my_sub()(data, minusscalar0_second)
NameError: name 'minusscalar0_second' is not defined