LSTR环境安装

文章描述了一个使用Transformer架构的车道线检测模型LSTR在旧版Python和PyTorch环境中导出ONNX模型时遇到的问题,包括类型推断警告和形状不匹配错误。作者发现将环境升级到Python3.7或3.8,PyTorch1.12.1后,这些问题可以得到解决,并能成功生成可由TensorRT8.4解析的引擎。文章提供了环境配置和问题解决的步骤。

ane Shape Prediction with Transformers  GitHub - liuruijin17/LSTR: This is an official repository of End-to-end Lane Shape Prediction with Transformers.出来虽然两年了但依然是一个非常优秀的车道线检测模型,可以同来拓展检测其他线形,而且占用资源较少推理速度非常快。但是,它的使用python3.6和torch1.5等软件版本比较老了,写导出的onnx脚本在该环境下导出的onnx用现在比较新的TensorRT8.4来解析生成engine时可能会报错,python3.6下即使把torch升级到1.10.1后也还是存在这个问题,例如用下面的脚本导出onnx:

torch.onnx.export(model,         
         images,       # model input (or a tuple for multiple inputs) 
         onnx_file,       
         export_params=True,  # store the trained parameter weights inside the model file 
         opset_version=11,    
         do_constant_folding=True,  # whether to execute constant folding for optimization 
         input_names = ['images', 'masks'],   # the model's input names 
         output_names = ['output_class', 'output_curve'])

会报错:

/root/anaconda3/envs/lstr/lib/python3.6/site-packages/torch/onnx/symbolic_helper.py:325: UserWarning: Type cannot be inferred, which might cause exported graph to produce incorrect results.
  warnings.warn("Type cannot be inferred, which might cause exported graph to produce incorrect results.")
[W shape_type_inference.cpp:434] Warning: Constant folding in symbolic shape inference fails: shape '[240, 1, 1, 240]' is invalid for input of size 240 (function ComputeConstantFolding)
[W shape_type_inference.cpp:434] Warning: Constant folding in symbolic shape inference fails: shape '[3, 1, 1, 240]' is invalid for input of size 240 (function ComputeConstantFolding)
[W shape_type_inference.cpp:434] Warning: Constant folding in symbolic shape inference fails: shape '[3, 1, 1, 240]' is invalid for input of size 240 (function ComputeConstantFolding)
Traceback (most recent call last):
  File "experiments/ex
评论 9
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Arnold-FY-Chen

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值