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

KeyError while converting PyTorch model to IR #926

Open JoMe2704 opened 3 years ago

JoMe2704 commented 3 years ago

Platform: Win10

Python version: 3.8.5

Source framework with version: PyTorch (torch 1.7.1+cpu)

Destination framework with version: IR

Pre-trained model path: https://drive.google.com/drive/folders/1CXsEL_qUefIHrjVaBH1-Zf7LjKoBEKGL?usp=sharing

Running scripts: mmtoir -f pytorch -d cavaface --inputShape 3,112,112 -n IR-100_entire_model.pth

Output: Traceback (most recent call last): File "c:\program files\python38\lib\runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "c:\program files\python38\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Program Files\Python38\Scripts\mmtoir.exe__main__.py", line 7, in File "c:\program files\python38\lib\site-packages\mmdnn\conversion_script\convertToIR.py", line 200, in _main ret = _convert(args) File "c:\program files\python38\lib\site-packages\mmdnn\conversion_script\convertToIR.py", line 123, in _convert parser.run(args.dstPath) File "c:\program files\python38\lib\site-packages\mmdnn\conversion\common\DataStructure\parser.py", line 22, in run self.gen_IR() File "c:\program files\python38\lib\site-packages\mmdnn\conversion\pytorch\pytorch_parser.py", line 106, in gen_IR func(current_node) File "c:\program files\python38\lib\site-packages\mmdnn\conversion\pytorch\pytorch_parser.py", line 238, in rename_Conv weights_scope = self.get_weight_name(source_node) File "c:\program files\python38\lib\site-packages\mmdnn\conversion\pytorch\pytorch_parser.py", line 527, in get_weight_name return self.pytorch_graph.layer_weight_map[node.name] KeyError: 'node1085'

Note: In convertToIR.py, I included the lines sys.path.append('path/to/folder/with/resnet_irse.py') import resnet_irse to ensure that this module defining the network structure is loaded