tensorrtx icon indicating copy to clipboard operation
tensorrtx copied to clipboard

yolov5s 6.1 pytorch模型和TRT输出结果有差异 [TRT and pytorch have different inference result]

Open dao027 opened this issue 2 years ago • 3 comments

Env

  • GPU, e.g. RTX3090
  • OS, Centos 8
  • Cuda version 11.2
  • TensorRT version 8.4.1.5

About this repo

  • which branch/tag/commit are you using?
  • which model? Yolov5 v6.1

Your problem

使用官方yolov5s v6.1训练的pth模型,按照readme依次执行:[follow by readme in this repo/yolov5]

python gen_wts.py -w aaa.pt -o aaa.wts 编译后 ./yolov5 -s aaa.wts aaa.engine s ./yolov5 -d aaa.engine ../samples

pytorch这边命令是: python detect.py --source imgs/ --weights aaa.pt --conf-thres 0.1 --device 0 --save-txt --save-conf

得到的结果,和使用官方pytorch infer的结果有差异,主要是模型输出的置信度和bbox的数量有明显差异。 [pytorch and TRT have different result, especially bbox nums and output conf]

以下参数两边保持一致:[parameter same] MAX_OUTPUT_BBOX_COUNT = 1000 NMS_THRESH = 0.45 CONF_THRESH = 0.1 BATCH_SIZE = 1 INPUT_H = INPUT_W = 640 TRT这边 MAX_IMAGE_INPUT_SIZE_THRESH=4000*4000

请教各位大佬。。。有遇到相同问题的吗?或者是不是yolov5 V6.1版本更新后不能使用本repo呢?(看了下官方v6.1相对v6.0模型结构应该没有更新的)

PS: 目前已经排除了nms造成差异的原因,因为在本repo/yolov5/yolov5.cpp line403中将模型输出的prob打印出来看了下,和pytorch那边nms之前的结果就已经差异较大了。。。 [nms exclude, diff already arise before nms]

dao027 avatar Jul 21 '22 10:07 dao027

Are you using the pretrained model provided by them or your own trained model? And have you tried v.6.0?

wang-xinyu avatar Jul 22 '22 03:07 wang-xinyu

Are you using the pretrained model provided by them or your own trained model? And have you tried v.6.0?

i have tried the pretrained model provided by them according to your advice : yolov5s v6.0 pytorch VS TRT yolov5s v6.1 pytorch VS TRT

there is still diff in the output the TRT result is acceptable, but bboxnum and output conf of each test img are always different

dao027 avatar Jul 22 '22 10:07 dao027

If the result is acceptable, you can try to compare the mAP.

wang-xinyu avatar Jul 25 '22 03:07 wang-xinyu

I meet the some problem by using yolov5s v6.1 . the same picture but different results. @dao027 , do you solve it?

caihaocong avatar Aug 12 '22 03:08 caihaocong

I meet the some problem by using yolov5s v6.1 . the same picture but different results. @dao027 , do you solve it?

not yet, but result of TRT is acceptable, i'm trying more experiment another way(using ONNX)

dao027 avatar Aug 12 '22 03:08 dao027