Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

模型部署推理优化 #31

Open
tongchangD opened this issue Sep 29, 2024 · 5 comments
Open

模型部署推理优化 #31

tongchangD opened this issue Sep 29, 2024 · 5 comments

Comments

@tongchangD
Copy link

您好,很高兴拜读您的代码,我有以下问题想要请教您一下
问题1:yolov8seg 您尝试过直接转int8的trt模型吗
我使用nnexec 转trt时直接报错,然而使用export代码转的trt模型又不可使用

问题2:请问您有尝试过将nms 和 seg后续处理直接放在模型内部做吗
trt模型直接 输出 box([x,y,x,y,conf,cls]) seg([nxHxW] or [xy,xy,...xy,xy])

@Melody-Zhou
Copy link
Owner

您好,很高兴拜读您的代码,我有以下问题想要请教您一下 问题1:yolov8seg 您尝试过直接转int8的trt模型吗 我使用nnexec 转trt时直接报错,然而使用export代码转的trt模型又不可使用

问题2:请问您有尝试过将nms 和 seg后续处理直接放在模型内部做吗 trt模型直接 输出 box([x,y,x,y,conf,cls]) seg([nxHxW] or [xy,xy,...xy,xy])

  1. 我没有尝试过直接转 int8 的 engine,trtexec 转 engine 报错日志是什么呢?yolov8seg 没有奇怪的 op 算子按理来说转换没问题
  2. nms 和 seg 后处理没有尝试过放在 onnx 中,seg 后处理涉及到插值操作不太好放在 onnx 里面,另外 nms 这种按个人习惯来说我不太喜欢放在 onnx 里面,缺少灵活性

@tongchangD
Copy link
Author

@Melody-Zhou
[optimizer.cpp::computeCosts::3728] Error Code 10: Internal Error (Could not find any implementation for node /model.28/proto/cv3/conv/Conv + PWN(PWN(/model.28/proto/cv3/act/Sigmoid), /model.28/proto/cv3/act/Mul).)
[09/29/2024-09:02:59] [E] Error[2]: [builder.cpp::buildSerializedNetwork::751] Error Code 2: Internal Error (Assertion engine != nullptr failed. )

@Melody-Zhou
Copy link
Owner

@Melody-Zhou [optimizer.cpp::computeCosts::3728] Error Code 10: Internal Error (Could not find any implementation for node /model.28/proto/cv3/conv/Conv + PWN(PWN(/model.28/proto/cv3/act/Sigmoid), /model.28/proto/cv3/act/Mul).) [09/29/2024-09:02:59] [E] Error[2]: [builder.cpp::buildSerializedNetwork::751] Error Code 2: Internal Error (Assertion engine != nullptr failed. )

算子解析问题,提示网络中某些算子没有找到对应的实现,不过比较奇怪的是 yolov8-seg 没有一些奇怪的算子按理不会出现这个问题,你可以拿 onnx-simpifier 优化下导出的 onnx 试试,或者直接拿我这边提供的导出好的 onnx 试试,链接:Baidu Drive

@tongchangD
Copy link
Author

我是过了在新版本ultralytics能够转出int8精度的trt模型,但我用的是一个单通道的模型
然后就不能转出该单模型,
你可以移步至该issues

@tongchangD
Copy link
Author

考虑到这个,再回顾模型结构,我实在不知道问题出在那里

可能真的是模型不支持单通道吧

                   from  n    params  module                                       arguments                     
  0                  -1  1       176  ultralytics.nn.modules.conv.Conv             [1, 16, 3, 2]                 
  1                  -1  1      4672  ultralytics.nn.modules.conv.Conv             [16, 32, 3, 2]                
  2                  -1  1      7360  ultralytics.nn.modules.block.C2f             [32, 32, 1, True]             
  3                  -1  1     18560  ultralytics.nn.modules.conv.Conv             [32, 64, 3, 2]                
  4                  -1  2     49664  ultralytics.nn.modules.block.C2f             [64, 64, 2, True]             
  5                  -1  1     73984  ultralytics.nn.modules.conv.Conv             [64, 128, 3, 2]               
  6                  -1  2    197632  ultralytics.nn.modules.block.C2f             [128, 128, 2, True]           
  7                  -1  1    295424  ultralytics.nn.modules.conv.Conv             [128, 256, 3, 2]              
  8                  -1  1    460288  ultralytics.nn.modules.block.C2f             [256, 256, 1, True]           
  9                  -1  1    164608  ultralytics.nn.modules.block.SPPF            [256, 256, 5]  
 10                  -1  1         0  torch.nn.modules.upsampling.Upsample         [None, 2, 'nearest']          
 11             [-1, 6]  1         0  ultralytics.nn.modules.conv.Concat           [1]                           
 12                  -1  1    148224  ultralytics.nn.modules.block.C2f             [384, 128, 1]                 
 13                  -1  1         0  torch.nn.modules.upsampling.Upsample         [None, 2, 'nearest']          
 14             [-1, 4]  1         0  ultralytics.nn.modules.conv.Concat           [1]                           
 15                  -1  1     37248  ultralytics.nn.modules.block.C2f             [192, 64, 1]                  
 16                  -1  1         0  torch.nn.modules.upsampling.Upsample         [None, 2, 'nearest']          
 17             [-1, 2]  1         0  ultralytics.nn.modules.conv.Concat           [1]                           
 18                  -1  1      9408  ultralytics.nn.modules.block.C2f             [96, 32, 1]                   
 19                  -1  1      9280  ultralytics.nn.modules.conv.Conv             [32, 32, 3, 2]                
 20            [-1, 15]  1         0  ultralytics.nn.modules.conv.Concat           [1]                           
 21                  -1  1     31104  ultralytics.nn.modules.block.C2f             [96, 64, 1]                   
 22                  -1  1     36992  ultralytics.nn.modules.conv.Conv             [64, 64, 3, 2]                
 23            [-1, 12]  1         0  ultralytics.nn.modules.conv.Concat           [1]                           
 24                  -1  1    123648  ultralytics.nn.modules.block.C2f             [192, 128, 1]                 
 25                  -1  1    147712  ultralytics.nn.modules.conv.Conv             [128, 128, 3, 2]              
 26             [-1, 9]  1         0  ultralytics.nn.modules.conv.Concat           [1]                           
 27                  -1  1    493056  ultralytics.nn.modules.block.C2f             [384, 256, 1]                 
 28    [18, 21, 24, 27]  1    509092  ultralytics.nn.modules.head.Segment          [5, 32, 64, [32, 64, 128, 256]]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants