Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
ed85038c
Unverified
提交
ed85038c
authored
10月 25, 2020
作者:
Glenn Jocher
提交者:
GitHub
10月 25, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Precision-Recall Curve feature update (#1206)
* Precision-Recall Curve feature update * sentinel value update
上级
7fe4a6bc
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
10 行增加
和
8 行删除
+10
-8
general.py
utils/general.py
+10
-8
没有找到文件。
utils/general.py
浏览文件 @
ed85038c
...
...
@@ -293,9 +293,10 @@ def ap_per_class(tp, conf, pred_cls, target_cls, plot=False, fname='precision-re
p
[
ci
]
=
np
.
interp
(
-
pr_score
,
-
conf
[
i
],
precision
[:,
0
])
# p at pr_score
# AP from recall-precision curve
py
.
append
(
np
.
interp
(
px
,
recall
[:,
0
],
precision
[:,
0
]))
# precision at mAP@0.5
for
j
in
range
(
tp
.
shape
[
1
]):
ap
[
ci
,
j
]
=
compute_ap
(
recall
[:,
j
],
precision
[:,
j
])
ap
[
ci
,
j
],
mpre
,
mrec
=
compute_ap
(
recall
[:,
j
],
precision
[:,
j
])
if
j
==
0
:
py
.
append
(
np
.
interp
(
px
,
mrec
,
mpre
))
# precision at mAP@0.5
# Compute F1 score (harmonic mean of precision and recall)
f1
=
2
*
p
*
r
/
(
p
+
r
+
1e-16
)
...
...
@@ -304,7 +305,7 @@ def ap_per_class(tp, conf, pred_cls, target_cls, plot=False, fname='precision-re
py
=
np
.
stack
(
py
,
axis
=
1
)
fig
,
ax
=
plt
.
subplots
(
1
,
1
,
figsize
=
(
5
,
5
))
ax
.
plot
(
px
,
py
,
linewidth
=
0.5
,
color
=
'grey'
)
# plot(recall, precision)
ax
.
plot
(
px
,
py
.
mean
(
1
),
linewidth
=
2
,
color
=
'blue'
,
label
=
'all classes
'
)
ax
.
plot
(
px
,
py
.
mean
(
1
),
linewidth
=
2
,
color
=
'blue'
,
label
=
'all classes
%.3
f mAP@0.5'
%
ap
[:,
0
]
.
mean
()
)
ax
.
set_xlabel
(
'Recall'
)
ax
.
set_ylabel
(
'Precision'
)
ax
.
set_xlim
(
0
,
1
)
...
...
@@ -327,8 +328,8 @@ def compute_ap(recall, precision):
"""
# Append sentinel values to beginning and end
mrec
=
np
.
concatenate
(([
0.
],
recall
,
[
min
(
recall
[
-
1
]
+
1E-3
,
1.
)
]))
mpre
=
np
.
concatenate
(([
0.
],
precision
,
[
0.
]))
mrec
=
recall
# np.concatenate(([0.], recall, [recall[-1] + 1E-3
]))
mpre
=
precision
#
np.concatenate(([0.], precision, [0.]))
# Compute the precision envelope
mpre
=
np
.
flip
(
np
.
maximum
.
accumulate
(
np
.
flip
(
mpre
)))
...
...
@@ -336,13 +337,13 @@ def compute_ap(recall, precision):
# Integrate area under curve
method
=
'interp'
# methods: 'continuous', 'interp'
if
method
==
'interp'
:
x
=
np
.
linspace
(
0
,
1
,
101
)
# 101-point interp (COCO)
x
=
np
.
linspace
(
0
,
1
,
10
0
1
)
# 101-point interp (COCO)
ap
=
np
.
trapz
(
np
.
interp
(
x
,
mrec
,
mpre
),
x
)
# integrate
else
:
# 'continuous'
i
=
np
.
where
(
mrec
[
1
:]
!=
mrec
[:
-
1
])[
0
]
# points where x axis (recall) changes
ap
=
np
.
sum
((
mrec
[
i
+
1
]
-
mrec
[
i
])
*
mpre
[
i
+
1
])
# area under curve
return
ap
return
ap
,
mpre
,
mrec
def
bbox_iou
(
box1
,
box2
,
x1y1x2y2
=
True
,
GIoU
=
False
,
DIoU
=
False
,
CIoU
=
False
,
eps
=
1e-9
):
...
...
@@ -1259,7 +1260,7 @@ def plot_results_overlay(start=0, stop=0): # from utils.general import *; plot_
def
plot_results
(
start
=
0
,
stop
=
0
,
bucket
=
''
,
id
=
(),
labels
=
(),
save_dir
=
''
):
# from utils.general import *; plot_results()
# from utils.general import *; plot_results(
save_dir='runs/exp0'
)
# Plot training 'results*.txt' as seen in https://github.com/ultralytics/yolov5#reproduce-our-training
fig
,
ax
=
plt
.
subplots
(
2
,
5
,
figsize
=
(
12
,
6
))
ax
=
ax
.
ravel
()
...
...
@@ -1273,6 +1274,7 @@ def plot_results(start=0, stop=0, bucket='', id=(), labels=(), save_dir=''):
os
.
system
(
c
)
else
:
files
=
glob
.
glob
(
str
(
Path
(
save_dir
)
/
'results*.txt'
))
+
glob
.
glob
(
'../../Downloads/results*.txt'
)
assert
len
(
files
),
'No results.txt files found in
%
s, nothing to plot.'
%
os
.
path
.
abspath
(
save_dir
)
for
fi
,
f
in
enumerate
(
files
):
try
:
results
=
np
.
loadtxt
(
f
,
usecols
=
[
2
,
3
,
4
,
8
,
9
,
12
,
13
,
14
,
10
,
11
],
ndmin
=
2
)
.
T
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论