Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
94557969
Unverified
提交
94557969
authored
5月 26, 2022
作者:
Glenn Jocher
提交者:
GitHub
5月 26, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove `formats` variable to avoid `pd` conflict (#7993)
* Remove `formats` variable to avoid `pd` conflict * Update export.py
上级
1dcb7749
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
7 行增加
和
9 行删除
+7
-9
export.py
export.py
+5
-5
benchmarks.py
utils/benchmarks.py
+2
-4
没有找到文件。
export.py
浏览文件 @
94557969
...
@@ -475,9 +475,9 @@ def run(
...
@@ -475,9 +475,9 @@ def run(
):
):
t
=
time
.
time
()
t
=
time
.
time
()
include
=
[
x
.
lower
()
for
x
in
include
]
# to lowercase
include
=
[
x
.
lower
()
for
x
in
include
]
# to lowercase
f
orma
ts
=
tuple
(
export_formats
()[
'Argument'
][
1
:])
# --include arguments
f
m
ts
=
tuple
(
export_formats
()[
'Argument'
][
1
:])
# --include arguments
flags
=
[
x
in
include
for
x
in
f
orma
ts
]
flags
=
[
x
in
include
for
x
in
f
m
ts
]
assert
sum
(
flags
)
==
len
(
include
),
f
'ERROR: Invalid --include {include}, valid --include arguments are {f
orma
ts}'
assert
sum
(
flags
)
==
len
(
include
),
f
'ERROR: Invalid --include {include}, valid --include arguments are {f
m
ts}'
jit
,
onnx
,
xml
,
engine
,
coreml
,
saved_model
,
pb
,
tflite
,
edgetpu
,
tfjs
=
flags
# export booleans
jit
,
onnx
,
xml
,
engine
,
coreml
,
saved_model
,
pb
,
tflite
,
edgetpu
,
tfjs
=
flags
# export booleans
file
=
Path
(
url2file
(
weights
)
if
str
(
weights
)
.
startswith
((
'http:/'
,
'https:/'
))
else
weights
)
# PyTorch weights
file
=
Path
(
url2file
(
weights
)
if
str
(
weights
)
.
startswith
((
'http:/'
,
'https:/'
))
else
weights
)
# PyTorch weights
...
@@ -499,7 +499,7 @@ def run(
...
@@ -499,7 +499,7 @@ def run(
im
=
torch
.
zeros
(
batch_size
,
3
,
*
imgsz
)
.
to
(
device
)
# image size(1,3,320,192) BCHW iDetection
im
=
torch
.
zeros
(
batch_size
,
3
,
*
imgsz
)
.
to
(
device
)
# image size(1,3,320,192) BCHW iDetection
# Update model
# Update model
if
half
and
not
(
coreml
or
xml
)
:
if
half
and
not
coreml
and
not
xml
:
im
,
model
=
im
.
half
(),
model
.
half
()
# to FP16
im
,
model
=
im
.
half
(),
model
.
half
()
# to FP16
model
.
train
()
if
train
else
model
.
eval
()
# training mode = no Detect() layer grid construction
model
.
train
()
if
train
else
model
.
eval
()
# training mode = no Detect() layer grid construction
for
k
,
m
in
model
.
named_modules
():
for
k
,
m
in
model
.
named_modules
():
...
@@ -531,7 +531,7 @@ def run(
...
@@ -531,7 +531,7 @@ def run(
if
any
((
saved_model
,
pb
,
tflite
,
edgetpu
,
tfjs
)):
if
any
((
saved_model
,
pb
,
tflite
,
edgetpu
,
tfjs
)):
if
int8
or
edgetpu
:
# TFLite --int8 bug https://github.com/ultralytics/yolov5/issues/5707
if
int8
or
edgetpu
:
# TFLite --int8 bug https://github.com/ultralytics/yolov5/issues/5707
check_requirements
((
'flatbuffers==1.12'
,))
# required before `import tensorflow`
check_requirements
((
'flatbuffers==1.12'
,))
# required before `import tensorflow`
assert
not
(
tflite
and
tfjs
)
,
'TFLite and TF.js models must be exported separately, please pass only one type.'
assert
not
tflite
or
not
tfjs
,
'TFLite and TF.js models must be exported separately, please pass only one type.'
model
,
f
[
5
]
=
export_saved_model
(
model
.
cpu
(),
model
,
f
[
5
]
=
export_saved_model
(
model
.
cpu
(),
im
,
im
,
file
,
file
,
...
...
utils/benchmarks.py
浏览文件 @
94557969
...
@@ -56,9 +56,8 @@ def run(
...
@@ -56,9 +56,8 @@ def run(
pt_only
=
False
,
# test PyTorch only
pt_only
=
False
,
# test PyTorch only
):
):
y
,
t
=
[],
time
.
time
()
y
,
t
=
[],
time
.
time
()
formats
=
export
.
export_formats
()
device
=
select_device
(
device
)
device
=
select_device
(
device
)
for
i
,
(
name
,
f
,
suffix
,
gpu
)
in
formats
.
iterrows
():
# index, (name, file, suffix, gpu-capable)
for
i
,
(
name
,
f
,
suffix
,
gpu
)
in
export
.
export_formats
()
.
iterrows
():
# index, (name, file, suffix, gpu-capable)
try
:
try
:
assert
i
!=
9
,
'Edge TPU not supported'
assert
i
!=
9
,
'Edge TPU not supported'
assert
i
!=
10
,
'TF.js not supported'
assert
i
!=
10
,
'TF.js not supported'
...
@@ -104,9 +103,8 @@ def test(
...
@@ -104,9 +103,8 @@ def test(
pt_only
=
False
,
# test PyTorch only
pt_only
=
False
,
# test PyTorch only
):
):
y
,
t
=
[],
time
.
time
()
y
,
t
=
[],
time
.
time
()
formats
=
export
.
export_formats
()
device
=
select_device
(
device
)
device
=
select_device
(
device
)
for
i
,
(
name
,
f
,
suffix
,
gpu
)
in
formats
.
iterrows
():
# index, (name, file, suffix, gpu-capable)
for
i
,
(
name
,
f
,
suffix
,
gpu
)
in
export
.
export_formats
()
.
iterrows
():
# index, (name, file, suffix, gpu-capable)
try
:
try
:
w
=
weights
if
f
==
'-'
else
\
w
=
weights
if
f
==
'-'
else
\
export
.
run
(
weights
=
weights
,
imgsz
=
[
imgsz
],
include
=
[
f
],
device
=
device
,
half
=
half
)[
-
1
]
# weights
export
.
run
(
weights
=
weights
,
imgsz
=
[
imgsz
],
include
=
[
f
],
device
=
device
,
half
=
half
)[
-
1
]
# weights
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论