-
Notifications
You must be signed in to change notification settings - Fork 141
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
Why is the TRT model of yolov7 not as fast as the PT model #41
Comments
which model? |
your device ? |
The same model was obtained using the official yolov7 tiny training |
GTX 1080 |
try FP32 precsion |
I'll try |
thanks, expect your report! |
我测了确实快很多,就是置信度结果不对, 您的对么? |
如果您使用pred.get_fps() 获取FPS会得到180-200左右,相当于5ms左右耗时,但这并不是整个识别的流程耗时 |
是的, 目前大部分汇报FPS 都是指推理时间耗时 |
|
T4上也是如此吗? |
v7 的预处理流程和本仓库的不一致, 建议将预处理统一,重新测试 |
def preproc(image, input_size=(640, 640), mean=None, std=None, swap=(2, 0, 1)):
image = np.array(image, np.float32)
image = image[:, :, ::-1]
oh, ow = image.shape[:2]
dh, dw = input_size
scale = min(dw / ow, dh / oh)
M = np.array([
[scale, 0, 0],
[0, scale, 0]
])
padded_img = cv2.warpAffine(image, M, input_size)
padded_img /= 255.
if mean is not None:
padded_img -= mean
if std is not None:
padded_img /= std
padded_img = padded_img.transpose(swap)
padded_img = np.ascontiguousarray(padded_img, dtype=np.float32)
return padded_img, scale 期待您的测试, 建议您使用这个预处理方法重新测试, 如果有效的话,我们将在以后版本中使用该预处理方法 |
感谢Linaom1214老师的耐心解答,这份新的代码结果看起来更糟 22.135257720947266 ms 20.000696182250977 ms 19.888877868652344 ms 20.226716995239258 ms 20.84493637084961 ms 20.862102508544922 ms |
hhhhhhh, 等我们尝试一些更稳定的办法, 目前来看时间差异应该还是在数据预处理部分, pytorch 的数据加载和一些后处理都在GPU上实现, 我们的数据处理是完全基于CPU的, 还需要一段时间的优化。感谢您的测试数据 |
顺便一提,昨天,使用C++部署了一下,结果耗时久到吓人,直接用pt模型,通信截图识别耗时在15-31ms,使用trt模型耗时60-120ms,暂时不清楚哪里搞错,都是来自0延时循环高速请求识别 |
具体是哪个代码呢? 端到端代码吗? |
可以尝试更稳定的V5 |
目前v7 使用onnx-> trt 精度也存在损失的问题 |
好的,抽时间尝试一下,今天第一次使用Colab ,体验不错 |
C++ 这个可以详细说说吗? |
end2end这个 |
写的是读取共享内存,C++编译出来的是个通信程序,通过发送WMCOPYDATA信息,得到数据长度,然后读取共享内存里的图片,进行识别,完成后将识别结果写到共享内存,关闭共享内存映射,返回结果的数据长度,另一个程序就可以读取共享内存获得结果 |
可以用不包含nms的方式测试一下吗? 仓库提供的代码也都比较简单, 如果有什么BUG欢迎反馈 |
171ms 这个耗时是C++启动nms trt模型消耗的 |
好的,这需要一些时间,缺少dirent.h文件,并且部分配置未完成 |
这也太夸张了,pt是用libtorch调用吗? |
C++没有使用pt,是使用pyinstaller编译的一套大文件框架,使用的pytorh,这在多台计算机上移动不太方便,4G+文件空间 |
补充一下 我说的同样的C++代码,是因为之前使用C++编译了yolov4调用weights模型,使用的同样的代码,yolov4耗时在50ms内 |
单张图片推理
|
你的v6好快,我的yolov7-tiny.trt end2end 直接使用您的C++文件编译出来,耗时20ms |
v7 的end2end c++ 我还真没试过,我的TRT版本是8.2的 onnx模型有一个节点识别不了 |
engine init finished yolov7-tiny.trt normal竟然比end2end更快 yolo.hpp开头需要增加#define NOMINMAX 还有自己新建一个dirent.h文件 |
dirent.h文件内容
|
看来end2end 这个代码还需要优化呀 |
Do you know why it takes only 9 milliseconds to infer using Pt model, but 20 milliseconds to infer using TRT model? They have already warmed up 10 times. If so, tensorrt does not seem to accelerate. Maybe there is a configuration error
The text was updated successfully, but these errors were encountered: