msnh2012 / Msnhnet

🔥 (yolov3 yolov4 yolov5 unet ...)A mini pytorch inference framework which inspired from darknet.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

转换报错

simplehappy2600 opened this issue · comments

你好,用https://github.com/bat67/pytorch-FCN-easiest-demo生成的模型,用下面的代码转换报错

import torch
import PytorchToMsnhnet

device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')

fcn_model = torch.load(r'pytorch-FCN-easiest-demo\checkpoints\fcn_model_95.pt').to("cpu")
fcn_model.requires_grad_(False)
fcn_model.eval()

input = torch.ones([1, 3, 160, 160], dtype=torch.float)

trans msnhnet and msnhbin file

PytorchToMsnhnet.trans(fcn_model, input, "fcn.msnhnet", "fcn.msnhbin", False)

输出:
E:\python\Python38\python.exe pytorch-FCN-easiest-demo/toMsnhnet.py
conv2d-i 2163667712896
conv2d-o 2163667704448
weights: 1728
bias: 64
relu-i 2163667704448
relu-o 2163667704448
conv2d-i 2163667704448
conv2d-o 2163667709056
weights: 36864
bias: 64
relu-i 2163667709056
relu-o 2163667709056
max2d-i 2163667709056
max2d-o 2163667703424
conv2d-i 2163667703424
conv2d-o 2163667705472
weights: 73728
bias: 128
relu-i 2163667705472
relu-o 2163667705472
conv2d-i 2163667705472
conv2d-o 2163667713152
weights: 147456
bias: 128
relu-i 2163667713152
relu-o 2163667713152
max2d-i 2163667713152
max2d-o 2163667706240
conv2d-i 2163667706240
conv2d-o 2163667699072
weights: 294912
bias: 256
relu-i 2163667699072
relu-o 2163667699072
conv2d-i 2163667699072
conv2d-o 2163667700864
weights: 589824
bias: 256
relu-i 2163667700864
relu-o 2163667700864
conv2d-i 2163667700864
conv2d-o 2163667706752
weights: 589824
bias: 256
relu-i 2163667706752
relu-o 2163667706752
max2d-i 2163667706752
max2d-o 2163667703680
conv2d-i 2163667703680
conv2d-o 2163667703936
weights: 1179648
bias: 512
relu-i 2163667703936
relu-o 2163667703936
conv2d-i 2163667703936
conv2d-o 2163667707008
weights: 2359296
bias: 512
relu-i 2163667707008
relu-o 2163667707008
conv2d-i 2163667707008
conv2d-o 2163667707520
weights: 2359296
bias: 512
relu-i 2163667707520
relu-o 2163667707520
max2d-i 2163667707520
max2d-o 2163667704960
conv2d-i 2163667704960
conv2d-o 2163667698816
weights: 2359296
bias: 512
relu-i 2163667698816
relu-o 2163667698816
conv2d-i 2163667698816
conv2d-o 2163667705216
weights: 2359296
bias: 512
relu-i 2163667705216
relu-o 2163667705216
conv2d-i 2163667705216
conv2d-o 2163667699584
weights: 2359296
bias: 512
relu-i 2163667699584
relu-o 2163667699584
max2d-i 2163667699584
max2d-o 2163667707776
relu-i 2163667704704
relu-o 2163667704704
'2163667704704' is not in list
Traceback (most recent call last):
File "MsnhBuilder.py", line 33, in checkInput
ID = self.getIndexFromName(str(inAddr._cdata))
File "MsnhBuilder.py", line 17, in getIndexFromName
ids = self.indexes[self.names.index(name)]
ValueError: '2163667704704' is not in list

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "toMsnhnet.py", line 18, in
PytorchToMsnhnet.trans(fcn_model, input, "fcn.msnhnet", "fcn.msnhbin", False)
File "PytorchToMsnhnet.py", line 1389, in trans
net.forward(inputVar)
File "FCN.py", line 142, in forward
score = self.relu(score)
File "E:\python\Python38\lib\site-packages\torch\nn\modules\module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "E:\python\Python38\lib\site-packages\torch\nn\modules\activation.py", line 102, in forward
return F.relu(input, inplace=self.inplace)
File "PytorchToMsnhnet.py", line 31, in call
out=self.obj(self.raw,*args,**kwargs)
File "PytorchToMsnhnet.py", line 392, in _relu
msnhnet.checkInput(inData,sys._getframe().f_code.co_name)
File "MsnhBuilder.py", line 37, in checkInput
raise NotImplementedError("last op is not supported " + fun + str(inAddr._cdata))
NotImplementedError: last op is not supported _relu2163667704704

Process finished with exit code 1

转换里应该是有不支持的算子, 你找的这个里面有转置卷积, deconv暂不支持. 你可以用Upsample的双线性差值代替