Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
ec81c7b5
提交
ec81c7b5
authored
6月 16, 2020
作者:
Glenn Jocher
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
check_anchors() bug fix #90
上级
e1e33992
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
7 行增加
和
7 行删除
+7
-7
train.py
train.py
+1
-1
utils.py
utils/utils.py
+6
-6
没有找到文件。
train.py
浏览文件 @
ec81c7b5
...
...
@@ -199,7 +199,7 @@ def train(hyp):
tb_writer
.
add_histogram
(
'classes'
,
c
,
0
)
# Check anchors
check_
best_possible_recall
(
dataset
,
anchors
=
model
.
model
[
-
1
]
.
anchor_grid
,
thr
=
hyp
[
'anchor_t'
],
imgsz
=
imgsz
)
check_
anchors
(
dataset
,
anchors
=
model
.
model
[
-
1
]
.
anchor_grid
,
thr
=
hyp
[
'anchor_t'
],
imgsz
=
imgsz
)
# Exponential moving average
ema
=
torch_utils
.
ModelEMA
(
model
)
...
...
utils/utils.py
浏览文件 @
ec81c7b5
...
...
@@ -52,8 +52,9 @@ def check_img_size(img_size, s=32):
return
make_divisible
(
img_size
,
s
)
# nearest gs-multiple
def
check_
best_possible_recall
(
dataset
,
anchors
,
thr
=
4.0
,
imgsz
=
640
):
def
check_
anchors
(
dataset
,
model
,
thr
=
4.0
,
imgsz
=
640
):
# Check best possible recall of dataset with current anchors
anchors
=
model
.
module
.
model
[
-
1
]
.
anchor_grid
if
hasattr
(
model
,
'module'
)
else
model
.
model
[
-
1
]
.
anchor_grid
shapes
=
imgsz
*
dataset
.
shapes
/
dataset
.
shapes
.
max
(
1
,
keepdims
=
True
)
wh
=
torch
.
tensor
(
np
.
concatenate
([
l
[:,
3
:
5
]
*
s
for
s
,
l
in
zip
(
shapes
,
dataset
.
labels
)]))
.
float
()
# wh
ratio
=
wh
[:,
None
]
/
anchors
.
view
(
-
1
,
2
)
.
cpu
()[
None
]
# ratio
...
...
@@ -62,7 +63,6 @@ def check_best_possible_recall(dataset, anchors, thr=4.0, imgsz=640):
mr
=
(
m
<
thr
)
.
float
()
.
mean
()
# match ratio
print
((
'AutoAnchor labels:'
+
'
%10
s'
*
6
)
%
(
'n'
,
'mean'
,
'min'
,
'max'
,
'matching'
,
'recall'
))
print
((
' '
+
'
%10.4
g'
*
6
)
%
(
wh
.
shape
[
0
],
wh
.
mean
(),
wh
.
min
(),
wh
.
max
(),
mr
,
bpr
))
assert
bpr
>
0.9
,
'Best possible recall
%.3
g (BPR) below 0.9 threshold. Training cancelled. '
\
'Compute new anchors with utils.utils.kmeans_anchors() and update model before training.'
%
bpr
...
...
@@ -512,10 +512,10 @@ def build_targets(p, targets, model):
def
non_max_suppression
(
prediction
,
conf_thres
=
0.1
,
iou_thres
=
0.6
,
fast
=
False
,
classes
=
None
,
agnostic
=
False
):
"""
Performs Non-Maximum Suppression on inference results
Returns
detections with shape
:
nx6 (x1, y1, x2, y2, conf, cls)
"""
Performs Non-Maximum Suppression (NMS) on inference results
Returns:
detections with shape:
nx6 (x1, y1, x2, y2, conf, cls)
"""
if
prediction
.
dtype
is
torch
.
float16
:
prediction
=
prediction
.
float
()
# to FP32
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论