Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
0f2057ed
Unverified
提交
0f2057ed
authored
11月 26, 2020
作者:
Glenn Jocher
提交者:
GitHub
11月 26, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Targets scaling bug fix (#1529)
上级
2c3efa43
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
9 行增加
和
8 行删除
+9
-8
test.py
test.py
+6
-5
plots.py
utils/plots.py
+3
-3
没有找到文件。
test.py
浏览文件 @
0f2057ed
...
...
@@ -15,7 +15,7 @@ from utils.general import coco80_to_coco91_class, check_dataset, check_file, che
non_max_suppression
,
scale_coords
,
xyxy2xywh
,
xywh2xyxy
,
set_logging
,
increment_path
from
utils.loss
import
compute_loss
from
utils.metrics
import
ap_per_class
,
ConfusionMatrix
from
utils.plots
import
plot_images
,
output_to_target
from
utils.plots
import
plot_images
,
output_to_target
,
plot_study_txt
from
utils.torch_utils
import
select_device
,
time_synchronized
...
...
@@ -102,7 +102,6 @@ def test(data,
img
/=
255.0
# 0 - 255 to 0.0 - 1.0
targets
=
targets
.
to
(
device
)
nb
,
_
,
height
,
width
=
img
.
shape
# batch size, channels, height, width
targets
[:,
2
:]
*=
torch
.
Tensor
([
width
,
height
,
width
,
height
])
.
to
(
device
)
with
torch
.
no_grad
():
# Run model
...
...
@@ -115,8 +114,9 @@ def test(data,
loss
+=
compute_loss
([
x
.
float
()
for
x
in
train_out
],
targets
,
model
)[
1
][:
3
]
# box, obj, cls
# Run NMS
t
=
time_synchronized
()
t
argets
[:,
2
:]
*=
torch
.
Tensor
([
width
,
height
,
width
,
height
])
.
to
(
device
)
# to pixels
lb
=
[
targets
[
targets
[:,
0
]
==
i
,
1
:]
for
i
in
range
(
nb
)]
if
save_txt
else
[]
# for autolabelling
t
=
time_synchronized
()
output
=
non_max_suppression
(
inf_out
,
conf_thres
=
conf_thres
,
iou_thres
=
iou_thres
,
labels
=
lb
)
t1
+=
time_synchronized
()
-
t
...
...
@@ -324,8 +324,9 @@ if __name__ == '__main__':
y
=
[]
# y axis
for
i
in
x
:
# img-size
print
(
'
\n
Running
%
s point
%
s...'
%
(
f
,
i
))
r
,
_
,
t
=
test
(
opt
.
data
,
weights
,
opt
.
batch_size
,
i
,
opt
.
conf_thres
,
opt
.
iou_thres
,
opt
.
save_json
)
r
,
_
,
t
=
test
(
opt
.
data
,
weights
,
opt
.
batch_size
,
i
,
opt
.
conf_thres
,
opt
.
iou_thres
,
opt
.
save_json
,
plots
=
False
)
y
.
append
(
r
+
t
)
# results and times
np
.
savetxt
(
f
,
y
,
fmt
=
'
%10.4
g'
)
# save
os
.
system
(
'zip -r study.zip study_*.txt'
)
# utils.plots.
plot_study_txt(f, x) # plot
plot_study_txt
(
f
,
x
)
# plot
utils/plots.py
浏览文件 @
0f2057ed
...
...
@@ -140,7 +140,7 @@ def plot_images(images, targets, paths=None, fname='images.jpg', names=None, max
labels
=
image_targets
.
shape
[
1
]
==
6
# labels if no conf column
conf
=
None
if
labels
else
image_targets
[:,
6
]
# check for confidence presence (label vs pred)
if
boxes
.
max
()
<=
1
:
# if normalized
if
boxes
.
shape
[
1
]
and
boxes
.
max
()
<=
1
:
# if normalized
boxes
[[
0
,
2
]]
*=
w
# scale to pixels
boxes
[[
1
,
3
]]
*=
h
boxes
[[
0
,
2
]]
+=
block_x
...
...
@@ -224,7 +224,7 @@ def plot_study_txt(f='study.txt', x=None): # from utils.plots import *; plot_st
ax
=
ax
.
ravel
()
fig2
,
ax2
=
plt
.
subplots
(
1
,
1
,
figsize
=
(
8
,
4
),
tight_layout
=
True
)
for
f
in
[
'study/study_coco_
yolov5
%
s.txt'
%
x
for
x
in
[
's'
,
'm'
,
'l'
,
'
x'
]]:
for
f
in
[
'study/study_coco_
%
s.txt'
%
x
for
x
in
[
'yolov5s'
,
'yolov5m'
,
'yolov5l'
,
'yolov5
x'
]]:
y
=
np
.
loadtxt
(
f
,
dtype
=
np
.
float32
,
usecols
=
[
0
,
1
,
2
,
3
,
7
,
8
,
9
],
ndmin
=
2
)
.
T
x
=
np
.
arange
(
y
.
shape
[
1
])
if
x
is
None
else
np
.
array
(
x
)
s
=
[
'P'
,
'R'
,
'mAP@.5'
,
'mAP@.5:.95'
,
't_inference (ms/img)'
,
't_NMS (ms/img)'
,
't_total (ms/img)'
]
...
...
@@ -368,7 +368,7 @@ def plot_results(start=0, stop=0, bucket='', id=(), labels=(), save_dir=''):
y
[
y
==
0
]
=
np
.
nan
# don't show zero loss values
# y /= y[0] # normalize
label
=
labels
[
fi
]
if
len
(
labels
)
else
f
.
stem
ax
[
i
]
.
plot
(
x
,
y
,
marker
=
'.'
,
label
=
label
,
linewidth
=
1
,
markersize
=
6
)
ax
[
i
]
.
plot
(
x
,
y
,
marker
=
'.'
,
label
=
label
,
linewidth
=
2
,
markersize
=
8
)
ax
[
i
]
.
set_title
(
s
[
i
])
# if i in [5, 6, 7]: # share train and val loss y axes
# ax[i].get_shared_y_axes().join(ax[i], ax[i - 5])
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论