MMdnn
MMdnn copied to clipboard
Error when using the converted pytorch model(mxnet->IR->pytorch)
Platform (ubuntu 14.04):
Python version: 3.5
Source framework with version (like mxnet 1.0.0 with GPU):
Destination framework with version (like pytorch 0.4.0 with GPU):
Pre-trained model path (LResNet34E , https://github.com/Microsoft/MMdnn/blob/72529a9f6b17f7298eacb7b2a0dae6dc5b9ce408/mmdnn/conversion/pytorch/README.md):
Running scripts:
import torch import imp import numpy as np MainModel = imp.load_source('MainModel', "tf_pytorch_vgg19.py")
the_model = torch.load("tf_pytorch_vgg19.pth") the_model.eval() x = np.random.random([112,112,3]) x = np.transpose(x, (2, 0, 1)) x = np.expand_dims(x, 0).copy() data = torch.from_numpy(x) data = torch.autograd.Variable(data, requires_grad = False).float() predict = the_model(data) Traceback (most recent call last): File "
", line 1, in File "/home/dbmeng/TooLdevkit/anaconda3/envs/gluon/lib/python3.6/site-packages/torch/nn/modules/module.py", line 491, in call result = self.forward(*input, **kwargs) File "IR50_2.py", line 163, in forward self.minusscalar0_second = torch.autograd.Variable(torch.from_numpy(__weights_dict['minusscalar0_second']['value']), requires_grad=False) NameError: name '_KitModel__weights_dict' is not defined
Hi @MengDebin18, I tested it locally without errors. Seems this problem is relevant to the global variable define , and have you modified the generated code?
Platform (ubuntu 14.04):
Python version: 3.5
Source framework with version (like mxnet 1.0.0 with GPU):
Destination framework with version (like pytorch 0.4.0 with GPU):
Pre-trained model path (LResNet34E , https://github.com/Microsoft/MMdnn/blob/72529a9f6b17f7298eacb7b2a0dae6dc5b9ce408/mmdnn/conversion/pytorch/README.md):
Running scripts:
import torch import imp import numpy as np MainModel = imp.load_source('MainModel', "tf_pytorch_vgg19.py")
the_model = torch.load("tf_pytorch_vgg19.pth") the_model.eval() x = np.random.random([112,112,3]) x = np.transpose(x, (2, 0, 1)) x = np.expand_dims(x, 0).copy() data = torch.from_numpy(x) data = torch.autograd.Variable(data, requires_grad = False).float() predict = the_model(data) Traceback (most recent call last): File "", line 1, in File "/home/dbmeng/TooLdevkit/anaconda3/envs/gluon/lib/python3.6/site-packages/torch/nn/modules/module.py", line 491, in call result = self.forward(*input, **kwargs) File "IR50_2.py", line 163, in forward self.minusscalar0_second = torch.autograd.Variable(torch.from_numpy(__weights_dict['minusscalar0_second']['value']), requires_grad=False) NameError: name '_KitModel__weights_dict' is not defined
Have you fixed it? Could you share how to solve this, please?
same problem, 1 year passed @kitstar @namizzz @JiahaoYao @zhantong @microsoftopensource similar issue #631