Toybrick

标题: rknn1.4.0转pytorch模型报除0错误 [打印本页]

作者: fly    时间: 2021-1-6 20:36
标题: rknn1.4.0转pytorch模型报除0错误
模型是deep_sort_pytorch   https://github.com/ZQPei/deep_sort_pytorch

保存成torchscript模型:
  1.     net = Net(reid=True)
  2.     model_path = "/home/fly/ai/project/led/deep_sort_pytorch-master/deep_sort/deep/checkpoint/ckpt.t7"
  3.     state_dict = torch.load(model_path, map_location=lambda storage, loc: storage)['net_dict']
  4.     net.load_state_dict(state_dict)
  5.     x = torch.randn(1,3,128,64)
  6.     torch.jit.trace(net, x).save("./deep_sort.pt")
复制代码

转换代码
  1. input_size_list = [[3, 128, 64]]

  2.     # Create RKNN object
  3.     rknn = RKNN()

  4.     # pre-process config
  5.     print('--> config model')
  6.     rknn.config(reorder_channel='0 1 2')
  7.     print('done')

  8.     # Load pytorch model
  9.     print('--> Loading model')
  10.     ret = rknn.load_pytorch(model=model, input_size_list=input_size_list)
复制代码


错误日志
  1. <p>
  2. </p><p>/home/fly/ai/project/led/deep_sort_pytorch-master/deep_sort/deep/deep_sort.pt ********************</p><p>WARNING: Token 'COMMENT' defined, but not used</p><p>WARNING: There is 1 unused token</p><p>Load pytorch model failed!</p><p>E Catch exception when loading pytorch model: /home/fly/ai/project/led/deep_sort_pytorch-master/deep_sort/deep/deep_sort.pt!</p><p>E Traceback (most recent call last):</p><p>E   File "rknn/api/rknn_base.py", line 657, in rknn.api.rknn_base.RKNNBase.load_pytorch</p><p>E   File "rknn/base/RKNNlib/app/importer/import_pytorch.py", line 97, in rknn.base.RKNNlib.app.importer.import_pytorch.ImportPytorch.run</p><p>E   File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 755, in rknn.base.RKNNlib.converter.convert_pytorch.convert_pytorch.__init__</p><p>E   File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 839, in rknn.base.RKNNlib.converter.convert_pytorch.convert_pytorch.model_simplify</p><p>E   File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 124, in rknn.base.RKNNlib.converter.convert_pytorch.torch_inference_engine.shape_pick</p><p>E   File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 159, in rknn.base.RKNNlib.converter.convert_pytorch.torch_inference_engine.__ir_shape_inference</p><p>E   File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 233, in rknn.base.RKNNlib.converter.convert_pytorch.torch_inference_engine.elementwise_boardcast_shape</p><p>E   File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 124, in rknn.base.RKNNlib.converter.convert_pytorch.torch_inference_engine.shape_pick</p><p>E   File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 159, in rknn.base.RKNNlib.converter.convert_pytorch.torch_inference_engine.__ir_shape_inference</p><p>E   File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 281, in rknn.base.RKNNlib.converter.convert_pytorch.torch_inference_engine.view_shape</p><p>E ZeroDivisionError: integer division or modulo by zero</p>
复制代码

python环境
  1. torch               1.2.0
  2. torchvision         0.4.0
  3. rknn-toolkit        1.4.0
复制代码
请问这个除零错误是什么原因呢?


作者: fly    时间: 2021-1-7 13:03
把div的后处理从网络中剥离掉,就可以了。




欢迎光临 Toybrick (https://t.rock-chips.com/) Powered by Discuz! X3.3