Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
c09964c2
Unverified
提交
c09964c2
authored
2月 19, 2021
作者:
Glenn Jocher
提交者:
GitHub
2月 19, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update inference default to multi_label=False (#2252)
* Update inference default to multi_label=False * bug fix * Update plots.py * Update plots.py
上级
ab2da5ed
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
11 行增加
和
10 行删除
+11
-10
common.py
models/common.py
+1
-1
test.py
test.py
+4
-4
general.py
utils/general.py
+5
-4
plots.py
utils/plots.py
+1
-1
没有找到文件。
models/common.py
浏览文件 @
c09964c2
...
...
@@ -7,7 +7,7 @@ import numpy as np
import
requests
import
torch
import
torch.nn
as
nn
from
PIL
import
Image
,
ImageDraw
from
PIL
import
Image
from
utils.datasets
import
letterbox
from
utils.general
import
non_max_suppression
,
make_divisible
,
scale_coords
,
xyxy2xywh
...
...
test.py
浏览文件 @
c09964c2
...
...
@@ -106,7 +106,7 @@ def test(data,
with
torch
.
no_grad
():
# Run model
t
=
time_synchronized
()
inf_
out
,
train_out
=
model
(
img
,
augment
=
augment
)
# inference and training outputs
out
,
train_out
=
model
(
img
,
augment
=
augment
)
# inference and training outputs
t0
+=
time_synchronized
()
-
t
# Compute loss
...
...
@@ -117,11 +117,11 @@ def test(data,
targets
[:,
2
:]
*=
torch
.
Tensor
([
width
,
height
,
width
,
height
])
.
to
(
device
)
# to pixels
lb
=
[
targets
[
targets
[:,
0
]
==
i
,
1
:]
for
i
in
range
(
nb
)]
if
save_hybrid
else
[]
# for autolabelling
t
=
time_synchronized
()
out
put
=
non_max_suppression
(
inf_out
,
conf_thres
=
conf_thres
,
iou_thres
=
iou_thres
,
labels
=
lb
)
out
=
non_max_suppression
(
out
,
conf_thres
=
conf_thres
,
iou_thres
=
iou_thres
,
labels
=
lb
,
multi_label
=
True
)
t1
+=
time_synchronized
()
-
t
# Statistics per image
for
si
,
pred
in
enumerate
(
out
put
):
for
si
,
pred
in
enumerate
(
out
):
labels
=
targets
[
targets
[:,
0
]
==
si
,
1
:]
nl
=
len
(
labels
)
tcls
=
labels
[:,
0
]
.
tolist
()
if
nl
else
[]
# target class
...
...
@@ -209,7 +209,7 @@ def test(data,
f
=
save_dir
/
f
'test_batch{batch_i}_labels.jpg'
# labels
Thread
(
target
=
plot_images
,
args
=
(
img
,
targets
,
paths
,
f
,
names
),
daemon
=
True
)
.
start
()
f
=
save_dir
/
f
'test_batch{batch_i}_pred.jpg'
# predictions
Thread
(
target
=
plot_images
,
args
=
(
img
,
output_to_target
(
out
put
),
paths
,
f
,
names
),
daemon
=
True
)
.
start
()
Thread
(
target
=
plot_images
,
args
=
(
img
,
output_to_target
(
out
),
paths
,
f
,
names
),
daemon
=
True
)
.
start
()
# Compute statistics
stats
=
[
np
.
concatenate
(
x
,
0
)
for
x
in
zip
(
*
stats
)]
# to numpy
...
...
utils/general.py
浏览文件 @
c09964c2
...
...
@@ -390,11 +390,12 @@ def wh_iou(wh1, wh2):
return
inter
/
(
wh1
.
prod
(
2
)
+
wh2
.
prod
(
2
)
-
inter
)
# iou = inter / (area1 + area2 - inter)
def
non_max_suppression
(
prediction
,
conf_thres
=
0.25
,
iou_thres
=
0.45
,
classes
=
None
,
agnostic
=
False
,
labels
=
()):
"""Performs Non-Maximum Suppression (NMS) on inference results
def
non_max_suppression
(
prediction
,
conf_thres
=
0.25
,
iou_thres
=
0.45
,
classes
=
None
,
agnostic
=
False
,
multi_label
=
False
,
labels
=
()):
"""Runs Non-Maximum Suppression (NMS) on inference results
Returns:
detections with shape: nx6 (x1, y1, x2, y2, conf, cls)
list of detections, on (n,6) tensor per image [xyxy, conf, cls]
"""
nc
=
prediction
.
shape
[
2
]
-
5
# number of classes
...
...
@@ -406,7 +407,7 @@ def non_max_suppression(prediction, conf_thres=0.25, iou_thres=0.45, classes=Non
max_nms
=
30000
# maximum number of boxes into torchvision.ops.nms()
time_limit
=
10.0
# seconds to quit after
redundant
=
True
# require redundant detections
multi_label
=
nc
>
1
# multiple labels per box (adds 0.5ms/img)
multi_label
&
=
nc
>
1
# multiple labels per box (adds 0.5ms/img)
merge
=
False
# use merge-NMS
t
=
time
.
time
()
...
...
utils/plots.py
浏览文件 @
c09964c2
...
...
@@ -54,7 +54,7 @@ def butter_lowpass_filtfilt(data, cutoff=1500, fs=50000, order=5):
return
filtfilt
(
b
,
a
,
data
)
# forward-backward filter
def
plot_one_box
(
x
,
img
,
color
=
None
,
label
=
None
,
line_thickness
=
None
):
def
plot_one_box
(
x
,
img
,
color
=
None
,
label
=
None
,
line_thickness
=
3
):
# Plots one bounding box on image img
tl
=
line_thickness
or
round
(
0.002
*
(
img
.
shape
[
0
]
+
img
.
shape
[
1
])
/
2
)
+
1
# line/font thickness
color
=
color
or
[
random
.
randint
(
0
,
255
)
for
_
in
range
(
3
)]
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论