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

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





