Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
7b31a531
Unverified
提交
7b31a531
authored
1月 04, 2022
作者:
Glenn Jocher
提交者:
GitHub
1月 04, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add `tensorrt>=7.0.0` checks (#6193)
* Add `tensorrt>=7.0.0` checks * Update export.py * Update common.py * Update export.py
上级
a2f4a179
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
7 行增加
和
7 行删除
+7
-7
export.py
export.py
+6
-6
common.py
models/common.py
+1
-1
没有找到文件。
export.py
浏览文件 @
7b31a531
...
@@ -61,8 +61,8 @@ from models.experimental import attempt_load
...
@@ -61,8 +61,8 @@ from models.experimental import attempt_load
from
models.yolo
import
Detect
from
models.yolo
import
Detect
from
utils.activations
import
SiLU
from
utils.activations
import
SiLU
from
utils.datasets
import
LoadImages
from
utils.datasets
import
LoadImages
from
utils.general
import
(
LOGGER
,
check_dataset
,
check_img_size
,
check_requirements
,
c
olorstr
,
file_size
,
print_args
,
from
utils.general
import
(
LOGGER
,
check_dataset
,
check_img_size
,
check_requirements
,
c
heck_version
,
colorstr
,
url2file
)
file_size
,
print_args
,
url2file
)
from
utils.torch_utils
import
select_device
from
utils.torch_utils
import
select_device
...
@@ -174,14 +174,14 @@ def export_engine(model, im, file, train, half, simplify, workspace=4, verbose=F
...
@@ -174,14 +174,14 @@ def export_engine(model, im, file, train, half, simplify, workspace=4, verbose=F
check_requirements
((
'tensorrt'
,))
check_requirements
((
'tensorrt'
,))
import
tensorrt
as
trt
import
tensorrt
as
trt
opset
=
(
12
,
13
)[
trt
.
__version__
[
0
]
==
'8'
]
# test on TensorRT 7.x and 8.x
if
trt
.
__version__
[
0
]
==
7
:
# TensorRT 7 handling https://github.com/ultralytics/yolov5/issues/6012
if
opset
==
12
:
# TensorRT 7 handling https://github.com/ultralytics/yolov5/issues/6012
grid
=
model
.
model
[
-
1
]
.
anchor_grid
grid
=
model
.
model
[
-
1
]
.
anchor_grid
model
.
model
[
-
1
]
.
anchor_grid
=
[
a
[
...
,
:
1
,
:
1
,
:]
for
a
in
grid
]
model
.
model
[
-
1
]
.
anchor_grid
=
[
a
[
...
,
:
1
,
:
1
,
:]
for
a
in
grid
]
export_onnx
(
model
,
im
,
file
,
opset
,
train
,
False
,
simplify
)
export_onnx
(
model
,
im
,
file
,
12
,
train
,
False
,
simplify
)
# opset 12
model
.
model
[
-
1
]
.
anchor_grid
=
grid
model
.
model
[
-
1
]
.
anchor_grid
=
grid
else
:
# TensorRT >= 8
else
:
# TensorRT >= 8
export_onnx
(
model
,
im
,
file
,
opset
,
train
,
False
,
simplify
)
check_version
(
trt
.
__version__
,
'7.0.0'
,
hard
=
True
)
# require tensorrt>=8.0.0
export_onnx
(
model
,
im
,
file
,
13
,
train
,
False
,
simplify
)
# opset 13
onnx
=
file
.
with_suffix
(
'.onnx'
)
onnx
=
file
.
with_suffix
(
'.onnx'
)
assert
onnx
.
exists
(),
f
'failed to export ONNX file: {onnx}'
assert
onnx
.
exists
(),
f
'failed to export ONNX file: {onnx}'
...
...
models/common.py
浏览文件 @
7b31a531
...
@@ -337,7 +337,7 @@ class DetectMultiBackend(nn.Module):
...
@@ -337,7 +337,7 @@ class DetectMultiBackend(nn.Module):
elif
engine
:
# TensorRT
elif
engine
:
# TensorRT
LOGGER
.
info
(
f
'Loading {w} for TensorRT inference...'
)
LOGGER
.
info
(
f
'Loading {w} for TensorRT inference...'
)
import
tensorrt
as
trt
# https://developer.nvidia.com/nvidia-tensorrt-download
import
tensorrt
as
trt
# https://developer.nvidia.com/nvidia-tensorrt-download
check_version
(
trt
.
__version__
,
'
8.0.0'
,
verbose
=
True
)
# version requirement
check_version
(
trt
.
__version__
,
'
7.0.0'
,
hard
=
True
)
# require tensorrt>=7.0.0
Binding
=
namedtuple
(
'Binding'
,
(
'name'
,
'dtype'
,
'shape'
,
'data'
,
'ptr'
))
Binding
=
namedtuple
(
'Binding'
,
(
'name'
,
'dtype'
,
'shape'
,
'data'
,
'ptr'
))
logger
=
trt
.
Logger
(
trt
.
Logger
.
INFO
)
logger
=
trt
.
Logger
(
trt
.
Logger
.
INFO
)
with
open
(
w
,
'rb'
)
as
f
,
trt
.
Runtime
(
logger
)
as
runtime
:
with
open
(
w
,
'rb'
)
as
f
,
trt
.
Runtime
(
logger
)
as
runtime
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论