pytorch导出onnx格式时报错,RuntimeError: Failed to export an ONNX attribute, since it's not constant, please

运行程序,Pytorch版YOLOv3,链接地址

https://github.com/eriklindernoren/PyTorch-YOLOv3

Pytorch版本:1.1.0

 

onnx转换程序

import torch
import torchvision
from models import *
import argparse


def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--model_def", type=str, default="config/yolov3-tiny.cfg", help="path to model definition file")
    opt = parser.parse_args()
    dummy_input = torch.randn(1, 3, 416, 416)
    model = Darknet(opt.model_def)
    torch.onnx.export(model, dummy_input, "yolov3.onnx", verbose=True)


if __name__ == '__main__':
    main()

错误提示:

File "D:\Anaconda3\lib\site-packages\torch\onnx\symbolic.py", line 90, in _parse_arg
    raise RuntimeError("Failed to export an ONNX attribute, "
RuntimeError: Failed to export an ONNX attribute, since it's not constant, please try to make things (e.g., kernel size) static if possible
 

解决办法:

1.我将pytorch更新到了,当前最新版本pytorch1.2.0,这个问题自己解决了

2.下面这个人将pytorch推到了1.0.1版,

https://www.lizenghai.com/archives/15436.html

总体而言,应该是pytorch版本的问题

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值