Toybrick

Couldn't not load resnet18.pt

nvnn

注册会员

积分
124
楼主
发表于 2020-2-20 10:37:10    查看: 10835|回复: 8 | [复制链接]    打印 | 只看该作者
本帖最后由 nvnn 于 2020-2-20 10:41 编辑

Hi, I am trying to run the provided pytorch example, However I met the error below.
The code I tried is from rknn-toolkit: https://github.com/rockchip-linux/rknn-toolkit/blob/master/examples/pytorch/resnet18/test.py
Please let me know if you have any suggestions. Thanks
Here is the error log:
Downloading: "https://download.pytorch.org/models/resnet18-5c106cde.pth" to /home/nvnn/.cache/torch/checkpoints/resnet18-5c106cde.pth
100.0%
--> config model
done
--> Loading model
/home/nvnn/Downloads/env_rknn11/lib/python3.6/site-packages/onnx_tf/common/__init__.py:87: UserWarning: FrontendHandler.get_outputs_names is deprecated. It will be removed in future release.. Use node.outputs instead.
  warnings.warn(message)
./resnet18.pt ********************
WARNING: Token 'COMMENT' defined, but not used
WARNING: There is 1 unused token
Syntax error in input! LexToken(NAMED_IDENTIFIER,'__torch__',1,16)
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
!!!!! Illegal character '.'
done
--> Building model
W Genreate input meta fail, please check model.
W External input meta file "/tmp/tmpzjk3unin/resnet18_inputmeta.yml" is not exists.
Traceback (most recent call last):
  File "test.py", line 66, in <module>
    ret = rknn.build(do_quantization=True, dataset='./dataset.txt')
  File "/home/nvnn/Downloads/env_rknn11/lib/python3.6/site-packages/rknn/api/rknn.py", line 238, in build
    ret = self.rknn_base.build(do_quantization=do_quantization, dataset=dataset, pack_vdata=pre_compile, batch_size=rknn_batch_size)
  File "rknn/api/rknn_base.py", line 719, in rknn.api.rknn_base.RKNNBase.build
  File "rknn/api/rknn_base.py", line 2249, in rknn.api.rknn_base.RKNNBase._generate_inputmeta
IndexError: list index out of range


回复

使用道具 举报

jefferyzhang

版主

积分
13580
沙发
发表于 2020-2-20 11:26:44 | 只看该作者
pytorch version MUST equals 1.2
回复

使用道具 举报

nvnn

注册会员

积分
124
板凳
 楼主| 发表于 2020-2-24 08:22:32 | 只看该作者
Hi, pytorch version is 1.2.0. However still has some problem converting resnet18.pt
resnet18.pt ********************
WARNING: Token 'COMMENT' defined, but not used
WARNING: There is 1 unused token
E Catch exception when loading pytorch model: resnet18.pt!
E Traceback (most recent call last):
E   File "rknn/api/rknn_base.py", line 567, in rknn.api.rknn_base.RKNNBase.load_pytorch
E   File "rknn/base/RKNNlib/app/importer/import_pytorch.py", line 95, in rknn.base.RKNNlib.app.importer.import_pytorch.ImportPytorch.run
E   File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 517, in rknn.base.RKNNlib.converter.convert_pytorch.convert_pytorch.__init__
E   File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 601, in rknn.base.RKNNlib.converter.convert_pytorch.convert_pytorch.model_simplify
E   File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 104, in rknn.base.RKNNlib.converter.convert_pytorch.torch_inference_engine.shape_pick
E   File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 139, in rknn.base.RKNNlib.converter.convert_pytorch.torch_inference_engine.__ir_shape_inference
E KeyError: 'aten::softmax'
Traceback (most recent call last):
  File "rknn_transform.py", line 28, in <module>
    rknn.build(do_quantization=True, dataset='./dataset.txt')
  File "/home/nvnn/Downloads/env_rknn11/lib/python3.6/site-packages/rknn/api/rknn.py", line 220, in build
    inputs = self.rknn_base.net.get_input_layers()
AttributeError: 'NoneType' object has no attribute 'get_input_layers'
回复

使用道具 举报

jefferyzhang

版主

积分
13580
地板
发表于 2020-2-24 17:20:50 | 只看该作者
nvnn 发表于 2020-2-24 08:22
Hi, pytorch version is 1.2.0. However still has some problem converting resnet18.pt
resnet18.pt **** ...

The resnet18 of torchvision version does't have softmax layer, aten::softmax is written by yourself?
You can try remove this op, and do softmax in 3399 side,
or try our fix version 1.3.1beta as below:
https://pan.baidu.com/s/1Kn2FGAdF_j3CMLNEsC3OPw
password:   rcds
回复

使用道具 举报

nvnn

注册会员

积分
124
5#
 楼主| 发表于 2020-2-26 08:33:36 | 只看该作者
本帖最后由 nvnn 于 2020-2-26 08:36 编辑
jefferyzhang 发表于 2020-2-24 17:20
The resnet18 of torchvision version does't have softmax layer, aten::softmax is written by yoursel ...

Thank you. I didn't add anything to resnet18.pt.
The code is from here:
  1. def export_pytorch_model():
  2.     net = models.resnet18(pretrained=True)
  3.     net.eval()
  4.     trace_model = torch.jit.trace(net, torch.Tensor(1,3,224,224))
  5.     trace_model.save('./resnet18.pt')
复制代码

I use this sample from rknn-toolkit: https://github.com/rockchip-linux/rknn-toolkit/blob/master/examples/pytorch/resnet18/test.py
so, it should be the origin resnet18 from pytorch
by the way, Can you upload version 1.3.1beta to onedrive? I am unable to download from baidu server. Thanks

回复

使用道具 举报

jefferyzhang

版主

积分
13580
6#
发表于 2020-2-26 08:37:46 | 只看该作者
Can the version 1.3.1beta fix this problem?
回复

使用道具 举报

nvnn

注册会员

积分
124
7#
 楼主| 发表于 2020-2-26 10:26:52 | 只看该作者
jefferyzhang 发表于 2020-2-26 08:37
Can the version 1.3.1beta fix this problem?

I am not sure, I could not download it from baidu. Can you upload it to drive? Thanks
回复

使用道具 举报

jefferyzhang

版主

积分
13580
8#
发表于 2020-2-26 10:54:45 | 只看该作者
回复

使用道具 举报

raul

中级会员

积分
235
9#
发表于 2020-3-10 16:02:18 | 只看该作者
What`s the version of torchvision? We tested it in 0.4.0 and 0.4.2, both are success. You can also update RKNN Toolkit to version 1.3.1beta, the softmax error should be fixed.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

产品中心 购买渠道 开源社区 Wiki教程 资料下载 关于Toybrick


快速回复 返回顶部 返回列表