MMdnn icon indicating copy to clipboard operation
MMdnn copied to clipboard

Error when using the converted pytorch model(mxnet->IR->pytorch)

Open MengDebin18 opened this issue 6 years ago • 3 comments
trafficstars

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

MengDebin18 avatar Jun 03 '19 16:06 MengDebin18

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?

rainLiuplus avatar Jun 04 '19 02:06 rainLiuplus

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?

Jar7 avatar Jul 25 '19 04:07 Jar7

same problem, 1 year passed @kitstar @namizzz @JiahaoYao @zhantong @microsoftopensource similar issue #631

Light-- avatar Jun 11 '20 01:06 Light--