Toybrick

rknn1.4.0转pytorch模型报除0错误

fly

注册会员

积分
70
楼主
发表于 2021-1-6 20:36:07    查看: 10527|回复: 1 | [复制链接]    打印 | 只看该作者
模型是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

注册会员

积分
70
沙发
 楼主| 发表于 2021-1-7 13:03:24 | 只看该作者
把div的后处理从网络中剥离掉,就可以了。
回复

使用道具 举报

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

本版积分规则

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


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