Giter VIP home page Giter VIP logo

tensorrt-for-yolo-series's Introduction

YOLO Series TensorRT Python/C++

Support

YOLOv8YOLOv7YOLOv6YOLOXYOLOV5YOLOv3

  • YOLOv8
  • YOLOv7
  • YOLOv6
  • YOLOX
  • YOLOv5
  • YOLOv3

Update

  • 2023.8.15 Support cuda-python
  • 2023.5.12 Update
  • 2023.1.7 support YOLOv8
  • 2022.11.29 fix some bug thanks @JiaPai12138
  • 2022.8.13 rename reop、 public new version、 C++ for end2end
  • 2022.8.11 nms plugin support ==> Now you can set --end2end flag while use export.py get a engine file
  • 2022.7.8 support YOLOv7
  • 2022.7.3 support TRT int8 post-training quantization

Prepare TRT Env

Install via Python

pip install --upgrade setuptools pip --user
pip install nvidia-pyindex
pip install --upgrade nvidia-tensorrt
pip install pycuda
pip install cuda-python

Install via C++

By Docker

Try YOLOv8

Install && Download Weights

pip install ultralytics

Export ONNX

from ultralytics import YOLO

model = YOLO("yolov8s.pt")
model.fuse()  
model.info(verbose=False)  # Print model information
model.export(format='onnx')  # TODO: 

Generate TRT File

python export.py -o yolov8n.onnx -e yolov8n.trt --end2end --v8 --fp32

Inference

python trt.py -e yolov8n.trt  -i src/1.jpg -o yolov8n-1.jpg --end2end 

Python Demo

Expand
  1. YOLOv5
  2. YOLOx
  3. YOLOv6
  4. YOLOv7

YOLOv5

!git clone https://github.com/ultralytics/yolov5.git
!wget https://github.com/ultralytics/yolov5/releases/download/v6.1/yolov5n.pt
!python yolov5/export.py --weights yolov5n.pt --include onnx --simplify --inplace 

include NMS Plugin

!python export.py -o yolov5n.onnx -e yolov5n.trt --end2end
!python trt.py -e yolov5n.trt  -i src/1.jpg -o yolov5n-1.jpg --end2end 

exclude NMS Plugin

!python export.py -o yolov5n.onnx -e yolov5n.trt 
!python trt.py -e yolov5n.trt  -i src/1.jpg -o yolov5n-1.jpg 

YOLOX

!git clone https://github.com/Megvii-BaseDetection/YOLOX.git
!wget https://github.com/Megvii-BaseDetection/YOLOX/releases/download/0.1.1rc0/yolox_s.pth
!cd YOLOX && pip3 install -v -e . --user
!cd YOLOX && python tools/export_onnx.py --output-name ../yolox_s.onnx -n yolox-s -c ../yolox_s.pth --decode_in_inference

include NMS Plugin

!python export.py -o yolox_s.onnx -e yolox_s.trt --end2end
!python trt.py -e yolox_s.trt  -i src/1.jpg -o yolox-1.jpg --end2end 

exclude NMS Plugin

!python export.py -o yolox_s.onnx -e yolox_s.trt 
!python trt.py -e yolox_s.trt  -i src/1.jpg -o yolox-1.jpg 

YOLOv6

!wget https://github.com/meituan/YOLOv6/releases/download/0.1.0/yolov6s.onnx

include NMS Plugin

!python export.py -o yolov6s.onnx -e yolov6s.trt --end2end
!python trt.py -e yolov6s.trt  -i src/1.jpg -o yolov6s-1.jpg --end2end

exclude NMS Plugin

!python export.py -o yolov6s.onnx -e yolov6s.trt 
!python trt.py -e yolov6s.trt  -i src/1.jpg -o yolov6s-1.jpg 

YOLOv7

!git clone https://github.com/WongKinYiu/yolov7.git
!wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-tiny.pt
!pip install -r yolov7/requirements.txt
!python yolov7/export.py --weights yolov7-tiny.pt --grid  --simplify

include NMS Plugin

!python export.py -o yolov7-tiny.onnx -e yolov7-tiny.trt --end2end
!python trt.py -e yolov7-tiny.trt  -i src/1.jpg -o yolov7-tiny-1.jpg --end2end

exclude NMS Plugin

!python export.py -o yolov7-tiny.onnx -e yolov7-tiny-norm.trt
!python trt.py -e yolov7-tiny-norm.trt  -i src/1.jpg -o yolov7-tiny-norm-1.jpg

C++ Demo

support NMS plugin show in C++ Demo

Citing

If you use this repo in your publication, please cite it by using the following BibTeX entry.

@Misc{yolotrt2022,
  author =       {Jian Lin},
  title =        {YOLOTRT: tensorrt for yolo series},
  howpublished = {\url{[https://github.com/Linaom1214/TensorRT-For-YOLO-Series]}},
  year =         {2022}
}

Sponsor

Buy me a cup of coffee

tensorrt-for-yolo-series's People

Contributors

ai-m-bot avatar linaom1214 avatar zeyad-mansour avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tensorrt-for-yolo-series's Issues

infer time

1.What's your gpu type?
2.What's single image infer time of the yolov6s.trt and yolov7.trt?
The author said yolov7 was faster, but it was not so when I tested it.
In my test:
yolov6s : 14ms
yolov7: about 40ms
gpu:GeForce GTX 1060
Driver Version: 455.28

Yolov6 low fps on .trt model with fp16

Using export.py file. I am able to convert my model from .onnx to .trt
While using the trt.py file.
Cuda utilization is only 354 MB and I m getting fps 23-27 only.
can help me to resolve this issue to increase my fps.

yolov7 trt.py推理报错

报错信息:
/home/zmw/anaconda3/envs/yolov7/lib/python3.7/site-packages/numpy/core/_asarray.py:83: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
return array(a, dtype, copy=False, order=order)
Traceback (most recent call last):
File "/home/zmw/tensorrt-python/yolov7/trt.py", line 30, in
origin_img = pred.inference(img_path, conf=0.3)
File "/home/zmw/tensorrt-python/utils/utils.py", line 87, in inference
predictions = np.reshape(data, (1, -1, int(5+self.n_classes)))[0]
File "<array_function internals>", line 6, in reshape
File "/home/zmw/anaconda3/envs/yolov7/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 299, in reshape
return _wrapfunc(a, 'reshape', newshape, order=order)
File "/home/zmw/anaconda3/envs/yolov7/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 55, in _wrapfunc
return _wrapit(obj, method, *args, **kwds)
File "/home/zmw/anaconda3/envs/yolov7/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 44, in _wrapit
result = getattr(asarray(obj), method)(*args, **kwds)
ValueError: cannot reshape array of size 4 into shape (1,newaxis,85)

完全跟着指导走的,不知道这里要怎么修改代码

AttributeError: 'NoneType' object has no attribute 'create_execution_context'

HI,

我按照你的流程安装环境后,报了以下问题,我的环境python3.8, tensorRT版本nvidia_tensorrt-8.4.1.5-cp38-none-linux_x86_64.whl

python trt.py [07/31/2022-16:12:30] [TRT] [E] 1: [stdArchiveReader.cpp::StdArchiveReader::35] Error Code 1: Serialization (Serialization assertion safeVersionRead == safeSerializationVersion failed.Version tag does not match. Note: Current Version: 0, Serialized Engine Version: 43) [07/31/2022-16:12:30] [TRT] [E] 4: [runtime.cpp::deserializeCudaEngine::50] Error Code 4: Internal Error (Engine deserialization failed.) Traceback (most recent call last): File "trt.py", line 28, in <module> pred = Predictor(engine_path='../yolov7-nms.trt') File "trt.py", line 13, in __init__ super(Predictor, self).__init__(engine_path) File "/home/jack/data1/project/tensorrt-python/yolov7/../utils/utils.py", line 29, in __init__ self.context = engine.create_execution_context() AttributeError: 'NoneType' object has no attribute 'create_execution_context'

"Resize scales must be an initializer" when try to convert yolov7 model.

Hi there,

I am following the instructions in your google colab notebook (here).

I start by downloading the model file:
wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-tiny.pt

Then I convert to onnx:
python3 ~/work/repos/yolov7/export.py --weights yolov7-tiny.pt --grid --simplify

Which prints out the following:

Namespace(batch_size=1, conf_thres=0.25, device='cpu', dynamic=False, dynamic_batch=False, end2end=False, fp16=False, grid=True, img_size=[640, 640], include_nms=False, int8=False, iou_thres=0.45, max_wh=None, simplify=True, topk_all=100, weights='yolov7-tiny.pt')
YOLOR 🚀 v0.1-107-g44d8ab4 torch 1.12.1+cu102 CPU

Fusing layers... 
Model Summary: 200 layers, 6219709 parameters, 6219709 gradients
/home/cyrus/.local/lib/python3.8/site-packages/torch/functional.py:478: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at  ../aten/src/ATen/native/TensorShape.cpp:2895.)
  return _VF.meshgrid(tensors, **kwargs)  # type: ignore[attr-defined]

Starting TorchScript export with torch 1.12.1+cu102...
/home/cyrus/work/repos/yolov7/models/yolo.py:52: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if self.grid[i].shape[2:4] != x[i].shape[2:4]:
TorchScript export success, saved as yolov7-tiny.torchscript.pt
CoreML export failure: No module named 'coremltools'

Starting TorchScript-Lite export with torch 1.12.1+cu102...
TorchScript-Lite export success, saved as yolov7-tiny.torchscript.ptl

Starting ONNX export with onnx 1.12.0...
/home/cyrus/work/repos/yolov7/models/yolo.py:582: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if augment:
/home/cyrus/work/repos/yolov7/models/yolo.py:614: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if profile:
/home/cyrus/work/repos/yolov7/models/yolo.py:629: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if profile:
Simplifier failure: No module named 'onnxsim'
ONNX export success, saved as yolov7-tiny.onnx

Export complete (4.02s). Visualize with https://github.com/lutzroeder/netron.

Finally, I try converting to tensorrt by running:
python export.py -o yolov7-tiny.onnx -e yolov7-tiny.trt --end2end

This produces the following error:

Namespace(calib_batch_size=8, calib_cache='./calibration.cache', calib_input=None, calib_num_images=5000, conf_thres=0.4, end2end=True, engine='yolov7-tiny.trt', iou_thres=0.5, max_det=100, onnx='yolov7-tiny.onnx', precision='fp16', verbose=False, workspace=1)
[09/12/2022-15:41:59] [TRT] [I] [MemUsageChange] Init CUDA: CPU +449, GPU +0, now: CPU 475, GPU 283 (MiB)
[09/12/2022-15:41:59] [TRT] [I] [MemUsageSnapshot] Begin constructing builder kernel library: CPU 475 MiB, GPU 283 MiB
[09/12/2022-15:41:59] [TRT] [I] [MemUsageSnapshot] End constructing builder kernel library: CPU 629 MiB, GPU 327 MiB
[09/12/2022-15:41:59] [TRT] [W] onnx2trt_utils.cpp:366: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32.
Failed to load ONNX file: /home/cyrus/work/repos/TensorRT-For-YOLO-Series/yolov7-tiny.onnx
In node 88 (importResize): UNSUPPORTED_NODE: Assertion failed: scales.is_weights() && "Resize scales must be an initializer!"

Please help.

trt model conf is negative

I train a single class model by yolov7 and conver trt.
python3 yolov7/export.py --grid --simplify
python3 T_F_Y_S/export.py -o xxx.onnx -e xxx.engine -p fp16 --end2end
when I use trt model inference, the boxes and class are same as pth model, but conf is negative and always in [-0.4,-0.6]
can you help me,thanks!!!

yolov7-tiny onnx -> engine 报错

利用官方yolov7-tiny.pt转onnx可顺利运行
但是在onnx -> engine 过程中报错

Failed to load ONNX file: /home/user/05.yolov7/yolov7-tiny.onnx
In node 67 (parseGraph): INVALID_GRAPH: Assertion failed: ctx->tensors().count(inputName)

请问楼主遇到过相同的问题吗?

what's your tensorrt version?

command:
python export_trt.py -m ../weights/yolov6s.onnx -o yolov6s.trt

error:
[TensorRT] VERBOSE: ModelImporter.cpp:129: Reshape_214 [Reshape] inputs: [411 -> (1, 1, 20, 20, 85)], [467 -> (3)],
[TensorRT] VERBOSE: ImporterContext.hpp:122: Registering layer: Reshape_214 for ONNX node: Reshape_214
[TensorRT] VERBOSE: ImporterContext.hpp:97: Registering tensor: 418 for ONNX tensor: 418
[TensorRT] VERBOSE: ModelImporter.cpp:180: Reshape_214 [Reshape] outputs: [418 -> (1, 400, 85)],
[TensorRT] VERBOSE: ModelImporter.cpp:107: Parsing node: Concat_215 [Concat]
[TensorRT] VERBOSE: ModelImporter.cpp:123: Searching for input: 302
[TensorRT] VERBOSE: ModelImporter.cpp:123: Searching for input: 360
[TensorRT] VERBOSE: ModelImporter.cpp:123: Searching for input: 418
[TensorRT] VERBOSE: ModelImporter.cpp:129: Concat_215 [Concat] inputs: [302 -> (1, 6400, 85)], [360 -> (1, 1600, 85)], [418 -> (1, 400, 85)],
[TensorRT] VERBOSE: ImporterContext.hpp:122: Registering layer: Concat_215 for ONNX node: Concat_215
[TensorRT] VERBOSE: ImporterContext.hpp:97: Registering tensor: outputs_1 for ONNX tensor: outputs
[TensorRT] VERBOSE: ModelImporter.cpp:180: Concat_215 [Concat] outputs: [outputs -> (1, 8400, 85)],
[TensorRT] VERBOSE: ModelImporter.cpp:494: Marking outputs_1 as output: outputs
Traceback (most recent call last):
File "export_trt.py", line 54, in
engine = builder.build_serialized_network(network,config)
AttributeError: 'tensorrt.tensorrt.Builder' object has no attribute 'build_serialized_network'

my tensorrt version is 7.0.0.11

C++ script shows nothing

I used the commands int the official repository of the yolov7 (here) to convert the yolov7_tiny.py to a TensorRT model.
I converted the yolov7.pt to yolov7-tiny.onnx with this command:

python export.py --weights ./yolov7-tiny.pt --grid --end2end --simplify --topk-all 100 --iou-thres 0.65 --conf-thres 0.35 --img-size 640 640

And then converted the yolov7-tiny.onnx model to the TensorRT model (yolov7-tiny-nms.trt )with this command:

git clone https://github.com/Linaom1214/tensorrt-python.git
python ./tensorrt-python/export.py -o yolov7-tiny.onnx -e yolov7-tiny-nms.trt -p fp16

I used the file cpp/end2end/main.cpp to inference, but got no result. This is the output on my terminal:

model size: 37371054
Registered plugin creator - ::GridAnchor_TRT version 1
Registered plugin creator - ::GridAnchorRect_TRT version 1
Registered plugin creator - ::NMS_TRT version 1
Registered plugin creator - ::Reorg_TRT version 1
Registered plugin creator - ::Region_TRT version 1
Registered plugin creator - ::Clip_TRT version 1
Registered plugin creator - ::LReLU_TRT version 1
Registered plugin creator - ::PriorBox_TRT version 1
Registered plugin creator - ::Normalize_TRT version 1
Registered plugin creator - ::ScatterND version 1
Registered plugin creator - ::RPROI_TRT version 1
Registered plugin creator - ::BatchedNMS_TRT version 1
Registered plugin creator - ::BatchedNMSDynamic_TRT version 1
Registered plugin creator - ::BatchTilePlugin_TRT version 1
Registered plugin creator - ::FlattenConcat_TRT version 1
Registered plugin creator - ::CropAndResize version 1
Registered plugin creator - ::CropAndResizeDynamic version 1
Registered plugin creator - ::DetectionLayer_TRT version 1
Registered plugin creator - ::EfficientNMS_TRT version 1
Registered plugin creator - ::EfficientNMS_ONNX_TRT version 1
Registered plugin creator - ::EfficientNMS_Explicit_TF_TRT version 1
Registered plugin creator - ::EfficientNMS_Implicit_TF_TRT version 1
Registered plugin creator - ::ProposalDynamic version 1
Registered plugin creator - ::Proposal version 1
Registered plugin creator - ::ProposalLayer_TRT version 1
Registered plugin creator - ::PyramidROIAlign_TRT version 1
Registered plugin creator - ::ResizeNearest_TRT version 1
Registered plugin creator - ::Split version 1
Registered plugin creator - ::SpecialSlice_TRT version 1
Registered plugin creator - ::InstanceNormalization_TRT version 1
Registered plugin creator - ::InstanceNormalization_TRT version 2
Registered plugin creator - ::CoordConvAC version 1
Registered plugin creator - ::DecodeBbox3DPlugin version 1
Registered plugin creator - ::GenerateDetection_TRT version 1
Registered plugin creator - ::MultilevelCropAndResize_TRT version 1
Registered plugin creator - ::MultilevelProposeROI_TRT version 1
Registered plugin creator - ::NMSDynamic_TRT version 1
Registered plugin creator - ::PillarScatterPlugin version 1
Registered plugin creator - ::VoxelGeneratorPlugin version 1
Registered plugin creator - ::MultiscaleDeformableAttnPlugin_TRT version 1
Using cublas as a tactic source
Using cuDNN as a tactic source
Deserialization required 472693 microseconds.
3: Cannot find binding of given name: image_arrays
3: [engine.cpp::getBindingDimensions::1305] Error Code 3: API Usage Error (Parameter check failed at: runtime/api/engine.cpp::getBindingDimensions::1305, condition: bindIndex >= 0 && bindIndex < getNbBindings()
)
3: Cannot find binding of given name: num
3: [engine.cpp::getBindingDimensions::1305] Error Code 3: API Usage Error (Parameter check failed at: runtime/api/engine.cpp::getBindingDimensions::1305, condition: bindIndex >= 0 && bindIndex < getNbBindings()
)
3: Cannot find binding of given name: boxes
3: [engine.cpp::getBindingDimensions::1305] Error Code 3: API Usage Error (Parameter check failed at: runtime/api/engine.cpp::getBindingDimensions::1305, condition: bindIndex >= 0 && bindIndex < getNbBindings()
)
3: Cannot find binding of given name: scores
3: [engine.cpp::getBindingDimensions::1305] Error Code 3: API Usage Error (Parameter check failed at: runtime/api/engine.cpp::getBindingDimensions::1305, condition: bindIndex >= 0 && bindIndex < getNbBindings()
)
3: Cannot find binding of given name: classes
3: [engine.cpp::getBindingDimensions::1305] Error Code 3: API Usage Error (Parameter check failed at: runtime/api/engine.cpp::getBindingDimensions::1305, condition: bindIndex >= 0 && bindIndex < getNbBindings()
)
Using cublas as a tactic source
Using cuDNN as a tactic source
Total per-runner device persistent memory is 1428480
Total per-runner host persistent memory is 115152
Allocated activation device memory of size 66407424

It seems some of the bindings can not be done by the model.

yolov7 C++

按照流程说明下来出现了这个错误: 这是因为什么的版本问题造成的吗?
./yolov7 ../yolov7.engine -i ../../../../assets/dog.jpg
[08/01/2022-19:43:48] [E] [TRT] 1: [stdArchiveReader.cpp::StdArchiveReader::40] Error Code 1: Serialization (Serialization assertion stdVersionRead == serializationVersion failed.Version tag does not match. Note: Current Version: 205, Serialized Engine Version: 213)

inference on video

after the model is converted into .trt we want to do inference on video.

convert yolov5n.onnx to yolov5n.trt found errors

python export.py -o yolov5n.onnx -e yolov5n.trt --end2end
Namespace(calib_batch_size=8, calib_cache='./calibration.cache', calib_input=None, calib_num_images=5000, conf_thres=0.4, end2end=True, engine='yolov5n.trt', iou_thres=0.5, max_det=100, onnx='yolov5n.onnx', precision='fp16', verbose=False, workspace=1)
[TensorRT] WARNING: onnx2trt_utils.cpp:220: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32.
[TensorRT] INFO: ModelImporter.cpp:135: No importer registered for op: ScatterND. Attempting to import as plugin.
[TensorRT] INFO: builtin_op_importers.cpp:3771: Searching for plugin: ScatterND, plugin_version: 1, plugin_namespace:
[TensorRT] ERROR: INVALID_ARGUMENT: getPluginCreator could not find plugin ScatterND version 1
Failed to load ONNX file: /home/cash/CV/TensorRT-For-YOLO-Series-main/yolov5n.onnx
In node -1 (importFallbackPluginImporter): UNSUPPORTED_NODE: Assertion failed: creator && "Plugin not found, are the plugin name, version, and namespace correct?"

TensorRT cpp inference is slow.

Really simple code for TensorRT inference! It's a good job. However, in my experiment, the inference seems to be slow.

I do YOLOv7 inference with your cpp code, and get average inference time 59ms (FP32) and 40ms (INT8), which is really slow compared to the average time 30ms(FP32) and 7ms (INT8) got from trtexec. Have you done any experiment on inference time?

yolox官方模型导出,进行推理时无检测结果

您好,大佬 麻烦请教下

使用的官方模型为 https://github.com/Megvii-BaseDetection/YOLOX/releases/download/0.1.1rc0/yolox_s.pth / https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox_s.pth 这两个版本的

按照您的如下教程 修改后:

修改 export_onnx.py 为 model.head.decode_in_inference = True

修改 yolox/models/yolox_head.py文件

# [batch, n_anchors_all, 85]
# outputs = torch.cat(
#     [x.flatten(start_dim=2) for x in outputs], dim=2

# ).permute(0, 2, 1)
outputs = torch.cat(
    [x.view(-1,int(x.size(1)),int(x.size(2)*x.size(3))) for x in outputs], dim=2

).permute(0, 2, 1)

# outputs[..., :2] = (outputs[..., :2] + grids) * strides
# outputs[..., 2:4] = torch.exp(outputs[..., 2:4]) * strides
# return outputs
xy =  (outputs[..., :2] + grids) * strides
wh = torch.exp(outputs[..., 2:4]) * strides
return torch.cat((xy, wh, outputs[..., 4:]), dim=-1) 

可以生成.onnx文件,然后 转换tensorrt引擎(fp32) 都成功

但是运行trt.py文件 后,图片无检测结果,打印dets 显示为None, 请问下是什么原因呢 ? 望解答,非常感谢

windows yolov7-tiny.onnx convert engine error

Environment:
windows10
tensorrt==8.2.3.0
cuda11.1
cudnn8.2.0

C:\Users\Administrator\Desktop\TensorRT-For-YOLO-Series-main>python export.py -o E:\ai\yolov7-20220806\weights\yolov7-tiny.onnx -e yolov7-tiny.trt --end2end
Namespace(calib_batch_size=8, calib_cache='./calibration.cache', calib_input=None, calib_num_images=5000, conf_thres=0.4, end2end=True, engine='yolov7-tiny.trt', iou_thres=0.5, max_det=100, onnx='E:\ai\yolov7-20220806\weights\yolov7-tiny.onnx', precision='fp32', verbose=False, workspace=1)
[09/25/2022-19:38:25] [TRT] [I] [MemUsageChange] Init CUDA: CPU +196, GPU +0, now: CPU 8170, GPU 416 (MiB)
[09/25/2022-19:38:26] [TRT] [I] [MemUsageSnapshot] Begin constructing builder kernel library: CPU 8234 MiB, GPU 416 MiB
[09/25/2022-19:38:26] [TRT] [I] [MemUsageSnapshot] End constructing builder kernel library: CPU 8299 MiB, GPU 416 MiB
[09/25/2022-19:38:26] [TRT] [W] onnx2trt_utils.cpp:366: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32.
[09/25/2022-19:38:26] [TRT] [W] onnx2trt_utils.cpp:392: One or more weights outside the range of INT32 was clamped
[09/25/2022-19:38:26] [TRT] [W] onnx2trt_utils.cpp:392: One or more weights outside the range of INT32 was clamped
[09/25/2022-19:38:26] [TRT] [W] onnx2trt_utils.cpp:392: One or more weights outside the range of INT32 was clamped
[09/25/2022-19:38:26] [TRT] [W] onnx2trt_utils.cpp:392: One or more weights outside the range of INT32 was clamped
Network Description
Input 'images' with shape (1, 3, 640, 640) and dtype DataType.FLOAT
Output 'classes' with shape (1, 25200, 4) and dtype DataType.FLOAT
Output 'boxes' with shape (1, 25200, 80) and dtype DataType.FLOAT
Building fp32 Engine in C:\Users\Administrator\Desktop\TensorRT-For-YOLO-Series-main\yolov7-tiny.trt
export.py:242: DeprecationWarning: Use build_serialized_network instead.
with self.builder.build_engine(self.network, self.config) as engine, open(engine_path, "wb") as f:
[09/25/2022-19:38:26] [TRT] [E] 4: [network.cpp::nvinfer1::Network::validate::2665] Error Code 4: Internal Error (Repeated tensor name: classes (tensors must have distinct names))
Traceback (most recent call last):
File "export.py", line 288, in
main(args)
File "export.py", line 249, in main
builder.create_engine(args.engine, args.precision, args.calib_input, args.calib_cache, args.calib_num_images,
File "export.py", line 242, in create_engine
with self.builder.build_engine(self.network, self.config) as engine, open(engine_path, "wb") as f:
AttributeError: enter

ONNXRuntimeError

Starting to simplify ONNX...
Warning: Unsupported operator EfficientNMS_TRT. No schema registered for this operator.
Warning: Unsupported operator EfficientNMS_TRT. No schema registered for this operator.
Simplifier failure: [ONNXRuntimeError] : 1 : FAIL : Fatal error: EfficientNMS_TRT is not a registered function/op
ONNX export success, saved as yolov7-tiny.onnx

Subnormal FP16 values detected.

When running the export.py script using the following command python export.py -o yolov7-tiny.onnx -e yolov7-tiny.trt --end2end I get tons of the following errors. Is this an issue? Should I be using fp32 inference instead?

[09/19/2022-11:35:56] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:35:56] [TRT] [W] Weights [name=Conv_613 + PWN(PWN(Sigmoid_614), Mul_615).weight] had the following issues when converted to FP16:
[09/19/2022-11:35:56] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:35:56] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:35:56] [TRT] [W] Weights [name=Conv_613 + PWN(PWN(Sigmoid_614), Mul_615).weight] had the following issues when converted to FP16:
[09/19/2022-11:35:56] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:35:56] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:35:56] [TRT] [W] Weights [name=Conv_613 + PWN(PWN(Sigmoid_614), Mul_615).weight] had the following issues when converted to FP16:
[09/19/2022-11:35:56] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:35:56] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:35:56] [TRT] [W] Weights [name=Conv_613 + PWN(PWN(Sigmoid_614), Mul_615).weight] had the following issues when converted to FP16:
[09/19/2022-11:35:56] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:35:56] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:35:57] [TRT] [W] Weights [name=Conv_613 + PWN(PWN(Sigmoid_614), Mul_615).weight] had the following issues when converted to FP16:
[09/19/2022-11:35:57] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:35:57] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:35:57] [TRT] [W] Weights [name=Conv_613 + PWN(PWN(Sigmoid_614), Mul_615).weight] had the following issues when converted to FP16:
[09/19/2022-11:35:57] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:35:57] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:00] [TRT] [W] Weights [name=Conv_817 + PWN(PWN(Sigmoid_818), Mul_819).weight] had the following issues when converted to FP16:
[09/19/2022-11:36:00] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:00] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:01] [TRT] [W] Weights [name=Conv_817 + PWN(PWN(Sigmoid_818), Mul_819).weight] had the following issues when converted to FP16:
[09/19/2022-11:36:01] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:01] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:01] [TRT] [W] Weights [name=Conv_817 + PWN(PWN(Sigmoid_818), Mul_819).weight] had the following issues when converted to FP16:
[09/19/2022-11:36:01] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:01] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:01] [TRT] [W] Weights [name=Conv_817 + PWN(PWN(Sigmoid_818), Mul_819).weight] had the following issues when converted to FP16:
[09/19/2022-11:36:01] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:01] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:01] [TRT] [W] Weights [name=Conv_817 + PWN(PWN(Sigmoid_818), Mul_819).weight] had the following issues when converted to FP16:
[09/19/2022-11:36:01] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:01] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:01] [TRT] [W] Weights [name=Conv_817 + PWN(PWN(Sigmoid_818), Mul_819).weight] had the following issues when converted to FP16:
[09/19/2022-11:36:01] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:01] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:01] [TRT] [W] Weights [name=Conv_817 + PWN(PWN(Sigmoid_818), Mul_819).weight] had the following issues when converted to FP16:
[09/19/2022-11:36:01] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:01] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:01] [TRT] [W] Weights [name=Conv_817 + PWN(PWN(Sigmoid_818), Mul_819).weight] had the following issues when converted to FP16:
[09/19/2022-11:36:01] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:01] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:03] [TRT] [W] Weights [name=Conv_620 + PWN(PWN(Sigmoid_621), Mul_622).weight] had the following issues when converted to FP16:
[09/19/2022-11:36:03] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:03] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:03] [TRT] [W] Weights [name=Conv_620 + PWN(PWN(Sigmoid_621), Mul_622).weight] had the following issues when converted to FP16:
[09/19/2022-11:36:03] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:03] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:03] [TRT] [W] Weights [name=Conv_620 + PWN(PWN(Sigmoid_621), Mul_622).weight] had the following issues when converted to FP16:
[09/19/2022-11:36:03] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:03] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:03] [TRT] [W] Weights [name=Conv_620 + PWN(PWN(Sigmoid_621), Mul_622).weight] had the following issues when converted to FP16:
[09/19/2022-11:36:03] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:03] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:03] [TRT] [W] Weights [name=Conv_620 + PWN(PWN(Sigmoid_621), Mul_622).weight] had the following issues when converted to FP16:
[09/19/2022-11:36:03] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:03] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:03] [TRT] [W] Weights [name=Conv_620 + PWN(PWN(Sigmoid_621), Mul_622).weight] had the following issues when converted to FP16:
[09/19/2022-11:36:03] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:03] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:03] [TRT] [W] Weights [name=Conv_620 + PWN(PWN(Sigmoid_621), Mul_622).weight] had the following issues when converted to FP16:
[09/19/2022-11:36:03] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:03] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:03] [TRT] [W] Weights [name=Conv_620 + PWN(PWN(Sigmoid_621), Mul_622).weight] had the following issues when converted to FP16:
[09/19/2022-11:36:03] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:03] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:03] [TRT] [W] Weights [name=Conv_620 + PWN(PWN(Sigmoid_621), Mul_622).weight] had the following issues when converted to FP16:
[09/19/2022-11:36:03] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:03] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:03] [TRT] [W] Weights [name=Conv_620 + PWN(PWN(Sigmoid_621), Mul_622).weight] had the following issues when converted to FP16:
[09/19/2022-11:36:03] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:03] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:03] [TRT] [W] Weights [name=Conv_620 + PWN(PWN(Sigmoid_621), Mul_622).weight] had the following issues when converted to FP16:
[09/19/2022-11:36:03] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:03] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:03] [TRT] [W] Weights [name=Conv_620 + PWN(PWN(Sigmoid_621), Mul_622).weight] had the following issues when converted to FP16:
[09/19/2022-11:36:03] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:03] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:03] [TRT] [W] Weights [name=Conv_620 + PWN(PWN(Sigmoid_621), Mul_622).weight] had the following issues when converted to FP16:
[09/19/2022-11:36:03] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:03] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:03] [TRT] [W] Weights [name=Conv_620 + PWN(PWN(Sigmoid_621), Mul_622).weight] had the following issues when converted to FP16:
[09/19/2022-11:36:03] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:03] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:04] [TRT] [W] Weights [name=Conv_616 + PWN(PWN(Sigmoid_617), Mul_618).weight] had the following issues when converted to FP16:
[09/19/2022-11:36:04] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:04] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:04] [TRT] [W] Weights [name=Conv_616 + PWN(PWN(Sigmoid_617), Mul_618).weight] had the following issues when converted to FP16:
[09/19/2022-11:36:04] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:04] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:04] [TRT] [W] Weights [name=Conv_616 + PWN(PWN(Sigmoid_617), Mul_618).weight] had the following issues when converted to FP16:
[09/19/2022-11:36:04] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:04] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:04] [TRT] [W] Weights [name=Conv_616 + PWN(PWN(Sigmoid_617), Mul_618).weight] had the following issues when converted to FP16:
[09/19/2022-11:36:04] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:04] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:04] [TRT] [W] Weights [name=Conv_616 + PWN(PWN(Sigmoid_617), Mul_618).weight] had the following issues when converted to FP16:
[09/19/2022-11:36:04] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:04] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:04] [TRT] [W] Weights [name=Conv_616 + PWN(PWN(Sigmoid_617), Mul_618).weight] had the following issues when converted to FP16:
[09/19/2022-11:36:04] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:04] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:04] [TRT] [W] Weights [name=Conv_616 + PWN(PWN(Sigmoid_617), Mul_618).weight] had the following issues when converted to FP16:
[09/19/2022-11:36:04] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:04] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:04] [TRT] [W] Weights [name=Conv_616 + PWN(PWN(Sigmoid_617), Mul_618).weight] had the following issues when converted to FP16:
[09/19/2022-11:36:04] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:04] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:05] [TRT] [W] Weights [name=Conv_829.weight] had the following issues when converted to FP16:
[09/19/2022-11:36:05] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:05] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:05] [TRT] [W] Weights [name=Conv_829.weight] had the following issues when converted to FP16:
[09/19/2022-11:36:05] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:05] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:05] [TRT] [W] Weights [name=Conv_829.weight] had the following issues when converted to FP16:
[09/19/2022-11:36:05] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:05] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:05] [TRT] [W] Weights [name=Conv_829.weight] had the following issues when converted to FP16:
[09/19/2022-11:36:05] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:05] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:05] [TRT] [W] Weights [name=Conv_829.weight] had the following issues when converted to FP16:
[09/19/2022-11:36:05] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:05] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:05] [TRT] [W] Weights [name=Conv_829.weight] had the following issues when converted to FP16:
[09/19/2022-11:36:05] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:05] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:05] [TRT] [W] Weights [name=Conv_829.weight] had the following issues when converted to FP16:
[09/19/2022-11:36:05] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:05] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:05] [TRT] [W] Weights [name=Conv_829.weight] had the following issues when converted to FP16:
[09/19/2022-11:36:05] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:05] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:05] [TRT] [W] Weights [name=Conv_829.weight] had the following issues when converted to FP16:
[09/19/2022-11:36:05] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:05] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:05] [TRT] [W] Weights [name=Conv_829.weight] had the following issues when converted to FP16:
[09/19/2022-11:36:05] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:05] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:05] [TRT] [W] Weights [name=Conv_829.weight] had the following issues when converted to FP16:
[09/19/2022-11:36:05] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:05] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:05] [TRT] [W] Weights [name=Conv_829.weight] had the following issues when converted to FP16:
[09/19/2022-11:36:05] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:05] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:05] [TRT] [W] Weights [name=Conv_829.weight] had the following issues when converted to FP16:
[09/19/2022-11:36:05] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:05] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:05] [TRT] [W] Weights [name=Conv_829.weight] had the following issues when converted to FP16:
[09/19/2022-11:36:05] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:05] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:35] [TRT] [W] Weights [name=Conv_624 || Conv_627 || Conv_652 || Conv_655.weight] had the following issues when converted to FP16:
[09/19/2022-11:36:35] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:35] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:35] [TRT] [W] Weights [name=Conv_624 || Conv_627 || Conv_652 || Conv_655.weight] had the following issues when converted to FP16:
[09/19/2022-11:36:35] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:35] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:35] [TRT] [W] Weights [name=Conv_624 || Conv_627 || Conv_652 || Conv_655.weight] had the following issues when converted to FP16:
[09/19/2022-11:36:35] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:35] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:35] [TRT] [W] Weights [name=Conv_624 || Conv_627 || Conv_652 || Conv_655.weight] had the following issues when converted to FP16:
[09/19/2022-11:36:35] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:35] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:35] [TRT] [W] Weights [name=Conv_624 || Conv_627 || Conv_652 || Conv_655.weight] had the following issues when converted to FP16:
[09/19/2022-11:36:35] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:35] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:35] [TRT] [W] Weights [name=Conv_624 || Conv_627 || Conv_652 || Conv_655.weight] had the following issues when converted to FP16:
[09/19/2022-11:36:35] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:35] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:35] [TRT] [W] Weights [name=Conv_624 || Conv_627 || Conv_652 || Conv_655.weight] had the following issues when converted to FP16:
[09/19/2022-11:36:35] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:35] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:35] [TRT] [W] Weights [name=Conv_624 || Conv_627 || Conv_652 || Conv_655.weight] had the following issues when converted to FP16:
[09/19/2022-11:36:35] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:35] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[09/19/2022-11:36:35] [TRT] [W] Weights [name=Conv_624 || Conv_627 || Conv_652 || Conv_655.weight] had the following issues when converted to FP16:
[09/19/2022-11:36:35] [TRT] [W]  - Subnormal FP16 values detected. 
[09/19/2022-11:36:35] [TRT] [W] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.

Why is the TRT model of yolov7 not as fast as the PT model

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

Assertion `engine.getNbBindings() == 2' failed.

HI ,

我想知道我遇到的这个问题如何解决,我是用cpp进行推理,流程根据官方介绍生成(https://github.com/WongKinYiu/yolov7),
wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-tiny.pt python export.py --weights yolov7-tiny.pt --grid --include-nms git clone https://github.com/Linaom1214/tensorrt-python.git python ./tensorrt-python/export.py -o yolov7-tiny.onnx -e yolov7-tiny-nms.trt -p fp16
blob image engine.getNbBindings() 3 yolov7: /home/jack/data1/project/tensorrt-python/yolov7/cpp/yolov7.cpp:396: void doInference(nvinfer1::IExecutionContext&, float*, float*, int, cv::Size): Assertionengine.getNbBindings() == 2' failed.
已放弃 (核心已转储)

`

nms插件

nms是指非极大值抑制吗?请问为什么分开使用nms和不使用nms两个版本,如果不使用nms岂不是会得到很多重复的框?

Batch processing?

@Linaom1214 Hello sir.
I would like to process a batch of 5 images in my c++ application. As this repository supports only single image processing, is there any way to process a batch of images with this repository? If you have a code script for that already, it would be great if you could share it.
Thank you in advance.

在利用trt文件推理时,遇到了一个错误

(yolo) D:\hskj\code\tensorrt-python-main\yolov7>python trt.py
[08/11/2022-17:42:29] [TRT] [E] 1: [pluginV2Runner.cpp::nvinfer1::rt::load::293] Error Code 1: Serialization (Serialization assertion creator failed.Cannot deserialize plugin since corresponding IPluginCreator not found in Plugin Registry)
[08/11/2022-17:42:29] [TRT] [E] 4: [runtime.cpp::nvinfer1::Runtime::deserializeCudaEngine::50] Error Code 4: Internal Error (Engine deserialization failed.)
Traceback (most recent call last):
File "trt.py", line 21, in
pred = Predictor(engine_path='D:/hskj/code/tensorrt-python-main/v7_last.engine')
File "trt.py", line 13, in init
super(Predictor, self).init(engine_path)
File "D:\hskj\code\tensorrt-python-main\yolov7..\utils\utils.py", line 22, in init
self.context = engine.create_execution_context()
AttributeError: 'NoneType' object has no attribute '

请问这个是我模型转换的不对么?

Int8 TensorRT engine version has no output

When I export my yolov7.onnx file with the following command
python3 ./export.py --onnx ../model/yolov7.onnx --engine model.trt -p int8 -v --calib_input ../data/images/ --calib_batch_size 256

When I run the resulting model.trt I get no output. I have tried on several images, and none have produced an output.

The one thing i changed in the export python script was to uncomment this line https://github.com/Linaom1214/TensorRT-For-YOLO-Series/blob/main/export.py#L234 and comment on the following line.

Any help would be appreciated.

使用trtexec命令行转换得到的trt推理报错

首先非常感谢你的分享。
我在windows11下使用pip 安装nvidia-tensorrt会报错,所以在docker环境中使用trtexec命令进行转换,在用trt.py推理时遇到如下报错:
Namespace(end2end=False, engine='../yolov7/weights/weights/test_no_sim.trt', image='../yolov7/inference/images/boat.jpg', output='test2.jpg', video=None)
[09/01/2022-03:26:21] [TRT] [E] 1: [stdArchiveReader.cpp::StdArchiveReader::35] Error Code 1: Serialization (Serialization assertion safeVersionRead == safeSerializationVersion failed.Version tag does not match. Note: Current Version: 0, Serialized Engine Version: 43)
[09/01/2022-03:26:21] [TRT] [E] 4: [runtime.cpp::deserializeCudaEngine::50] Error Code 4: Internal Error (Engine deserialization failed.)
Traceback (most recent call last):
File "trt.py", line 27, in
pred = Predictor(engine_path=args.engine)
File "trt.py", line 11, in init
super(Predictor, self).init(engine_path)
File "/mnt/tensorrt-python/utils/utils.py", line 31, in init
self.context = engine.create_execution_context()
AttributeError: 'NoneType' object has no attribute 'create_execution_context'
使用的是自己训练的yolov7,转onnx命令是:python export.py --weights weights/weights/best_rep.pt
转trt命令是/usr/src/tensorrt/bin/trtexec --onnx=best_rep.onnx --saveEngine=test_no_sim.trt --fp16
推理命令是python trt.py -e ../yolov7/weights/weights/test_no_sim.trt -i ../yolov7/inference/images/boat.jpg -o test2.jpg
docker环境是参照yolov7和你的pip安装搭建的,可以跑end2end,trt的版本不存在问题。

tensorrt 7版本

您好,能否支持tensorrt 7版本,某些场景无法使用tensorrt8

Getting an issue with int8 precession

Hi
First of all Thankyou very much for sharing this with us
I am getting an issue when I am trying to convert the Yolov6 model weights to Tensorrt with int8 precession the conversion has been done but the detections are not working
and also I have tried to reduce the threshold to 0.001 still the detections are not working
and when I convert that model with fp32,fp16 is working fine
Could you please help me with this

Thanks & Regards,
Pavan

YOLOv7 C++ ERROR

Dear authors,

Based on your code, I can cmake and make it, however, when I ran ./yolo and got the following error:

model size: 88806240
Registered plugin creator - ::GridAnchor_TRT version 1
Registered plugin creator - ::GridAnchorRect_TRT version 1
Registered plugin creator - ::NMS_TRT version 1
Registered plugin creator - ::Reorg_TRT version 1
Registered plugin creator - ::Region_TRT version 1
Registered plugin creator - ::Clip_TRT version 1
Registered plugin creator - ::LReLU_TRT version 1
Registered plugin creator - ::PriorBox_TRT version 1
Registered plugin creator - ::Normalize_TRT version 1
Registered plugin creator - ::ScatterND version 1
Registered plugin creator - ::RPROI_TRT version 1
Registered plugin creator - ::BatchedNMS_TRT version 1
Registered plugin creator - ::BatchedNMSDynamic_TRT version 1
Registered plugin creator - ::FlattenConcat_TRT version 1
Registered plugin creator - ::CropAndResize version 1
Registered plugin creator - ::DetectionLayer_TRT version 1
Registered plugin creator - ::EfficientNMS_ONNX_TRT version 1
Registered plugin creator - ::EfficientNMS_TRT version 1
Registered plugin creator - ::Proposal version 1
Registered plugin creator - ::ProposalLayer_TRT version 1
Registered plugin creator - ::PyramidROIAlign_TRT version 1
Registered plugin creator - ::ResizeNearest_TRT version 1
Registered plugin creator - ::Split version 1
Registered plugin creator - ::SpecialSlice_TRT version 1
Registered plugin creator - ::InstanceNormalization_TRT version 1
Using cublasLt a tactic source
TensorRT was linked against cuBLAS/cuBLAS LT 11.5.1 but loaded cuBLAS/cuBLAS LT 11.2.1
Using cuDNN as a tactic source
Deserialization required 1053496 microseconds.
3: Cannot find binding of given name: num
3: [engine.cpp::getBindingDimensions::1197] Error Code 3: Internal Error (Parameter check failed at: runtime/api/engine.cpp::getBindingDimensions::1197, condition: bindIndex >= 0 && bindIndex < getNbBindings()
)
3: Cannot find binding of given name: boxes
3: [engine.cpp::getBindingDimensions::1197] Error Code 3: Internal Error (Parameter check failed at: runtime/api/engine.cpp::getBindingDimensions::1197, condition: bindIndex >= 0 && bindIndex < getNbBindings()
)
3: Cannot find binding of given name: scores
3: [engine.cpp::getBindingDimensions::1197] Error Code 3: Internal Error (Parameter check failed at: runtime/api/engine.cpp::getBindingDimensions::1197, condition: bindIndex >= 0 && bindIndex < getNbBindings()
)
3: Cannot find binding of given name: classes
3: [engine.cpp::getBindingDimensions::1197] Error Code 3: Internal Error (Parameter check failed at: runtime/api/engine.cpp::getBindingDimensions::1197, condition: bindIndex >= 0 && bindIndex < getNbBindings()
)
Using cublasLt a tactic source
TensorRT was linked against cuBLAS/cuBLAS LT 11.5.1 but loaded cuBLAS/cuBLAS LT 11.2.1
Using cuDNN as a tactic source
Total per-runner device memory is 77268480
Total per-runner host memory is 201984
Allocated activation device memory of size 60621312
[ WARN:[email protected]] global /home/bydcv/Downloads/softwares/opencv-4.6.0/modules/imgcodecs/src/loadsave.cpp (239) findDecoder imread_('../horses_new.jpg'): can't open/read file: check file path/integrity
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.6.0) /home/bydcv/Downloads/softwares/opencv-4.6.0/modules/imgproc/src/resize.cpp:4052: error: (-215:Assertion failed) !ssize.empty() in function 'resize'

Aborted (core dumped)

nvidia-tensorrt 报错

anaconda python3.7
win11

只能linux?
win有没办法的?

 pip install nvidia-pyindex
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple, https://pypi.ngc.nvidia.com
Requirement already satisfied: nvidia-pyindex in d:\anaconda3\lib\site-packages (1.0.9)

(yolov7) PS D:\> pip install --upgrade nvidia-tensorrt

Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple, https://pypi.ngc.nvidia.com
Collecting nvidia-tensorrt
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/b8/a3/3da2bd25b6243d7a19b6c08c0e92f7c04f9863e70d213fee3141d574dccb/nvidia-tensorrt-0.0.1.dev5.tar.gz (7.9 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [17 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\mm\AppData\Local\Temp\pip-install-86qwtshw\nvidia-tensorrt_2f4607caa6e542a3bcb5c92aa2e31d0e\setup.py", line 150, in <module>
          raise RuntimeError(open("ERROR.txt", "r").read())
      RuntimeError:
      ###########################################################################################
      The package you are trying to install is only a placeholder project on PyPI.org repository.
      This package is hosted on NVIDIA Python Package Index.

      This package can be installed as:
      ```
      $ pip install nvidia-pyindex
      $ pip install nvidia-tensorrt
      ```
      ###########################################################################################

      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

imgs order

您好,我想问一下:
这里的imgsz的值对应着(宽、高)还是(高、宽)呢?
image

请问需要安装哪个cuda和cudnn版本呢

目前 cuda v11.6 + cudnn v8.3.3 会报错 (已添加到path)

F:\tensorrt-python-main>python export.py -o v6n.onnx -e v6n.trt -p fp16
[07/04/2022-19:11:00] [TRT] [I] [MemUsageChange] Init CUDA: CPU +291, GPU +0, now: CPU 4590, GPU 1091 (MiB)
[07/04/2022-19:11:00] [TRT] [I] [MemUsageSnapshot] Begin constructing builder kernel library: CPU 4650 MiB, GPU 1091 MiB
[07/04/2022-19:11:01] [TRT] [I] [MemUsageSnapshot] End constructing builder kernel library: CPU 4870 MiB, GPU 1161 MiB
F:\tensorrt-python-main\export.py:109: DeprecationWarning: Use set_memory_pool_limit instead.
  self.config.max_workspace_size = workspace * (2 ** 30)
[07/04/2022-19:11:01] [TRT] [W] onnx2trt_utils.cpp:365: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32.
[07/04/2022-19:11:01] [TRT] [W] onnx2trt_utils.cpp:391: One or more weights outside the range of INT32 was clamped
[07/04/2022-19:11:01] [TRT] [W] onnx2trt_utils.cpp:391: One or more weights outside the range of INT32 was clamped
[07/04/2022-19:11:01] [TRT] [W] onnx2trt_utils.cpp:391: One or more weights outside the range of INT32 was clamped
Network Description
Input 'image_arrays' with shape (1, 3, 416, 416) and dtype DataType.FLOAT
Output 'outputs' with shape (1, 3549, 7) and dtype DataType.FLOAT
Building fp16 Engine in F:\tensorrt-python-main\v6n.trt
F:\tensorrt-python-main\export.py:187: DeprecationWarning: Use build_serialized_network instead.
  with self.builder.build_engine(self.network, self.config) as engine, open(engine_path, "wb") as f:
[07/04/2022-19:11:01] [TRT] [I] [MemUsageChange] Init cuBLAS/cuBLASLt: CPU +195, GPU +70, now: CPU 5034, GPU 1231 (MiB)
[07/04/2022-19:11:01] [TRT] [I] [MemUsageChange] Init cuDNN: CPU +110, GPU +46, now: CPU 5144, GPU 1277 (MiB)
[07/04/2022-19:11:01] [TRT] [I] Local timing cache in use. Profiling results in this builder pass will not be stored.
Could not load library cudnn_cnn_infer64_8.dll. Error code 193

trt 部署

大佬你好,
我按照readme里边将yolo.py对应代码改成:
return x if self.training else (torch.cat(z, 1), ) if not self.export else (torch.cat(z, 1), x)
然后训练的时候每次训练1个epoch就报这个错误

File "/home/yolov7/yolov7/test.py", line 110, in test
out, train_out = model(img, augment=augment) # inference and training outputs
ValueError: not enough values to unpack (expected 2, got 1)

假如不改这一块转换的onnx无法转出engine

段错误问题

您好,按照您给的指南成功转换模型后显示段错误,貌似是资源没有释放问题...我该如何解决呢?

使用这一份代码,推理速度提高了,例子中使用您的export.py导出的trt模型

https://colab.research.google.com/github/WongKinYiu/yolov7/blob/main/tools/YOLOv7trt.ipynb
import cv2
import torch
import random
import time
import numpy as np
import tensorrt as trt
from PIL import Image
from pathlib import Path
from collections import OrderedDict,namedtuple

w = './yolov7-tiny-nms.trt'
device = torch.device('cuda:0')
img = cv2.imread('src/1.jpg')

[08/23/2022-17:20:35] [TRT] [I] [MemUsageChange] Init CUDA: CPU +252, GPU +0, now: CPU 10507, GPU 1049 (MiB)
[08/23/2022-17:20:35] [TRT] [I] Loaded engine size: 27 MiB
[08/23/2022-17:20:35] [TRT] [I] [MemUsageChange] Init cuBLAS/cuBLASLt: CPU +132, GPU +46, now: CPU 10678, GPU 1122 (MiB)
[08/23/2022-17:20:35] [TRT] [I] [MemUsageChange] Init cuDNN: CPU +108, GPU +36, now: CPU 10786, GPU 1158 (MiB)
[08/23/2022-17:20:35] [TRT] [I] [MemUsageChange] TensorRT-managed allocation in engine deserialization: CPU +0, GPU +27, now: CPU 0, GPU 27 (MiB)
[08/23/2022-17:20:35] [TRT] [I] [MemUsageChange] Init cuBLAS/cuBLASLt: CPU +0, GPU +8, now: CPU 10761, GPU 1172 (MiB)
[08/23/2022-17:20:35] [TRT] [I] [MemUsageChange] Init cuDNN: CPU +0, GPU +8, now: CPU 10761, GPU 1180 (MiB)
[08/23/2022-17:20:35] [TRT] [I] [MemUsageChange] TensorRT-managed allocation in IExecutionContext creation: CPU +0, GPU +65, now: CPU 0, GPU 92 (MiB)
Cost 4.830199999999785 ms

GTX1080
torch 1.10.1+cu102
torchvision 0.11.2+cu102
tensorrt 8.4.1.5
opencv-python 4.5.1.48

yolox decode

您好,我想请教一下。在您的代码中,yolox在infer之后为什么没有进行decode操作,而是直接进行postprocess呢?
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.