Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
685d6013
Unverified
提交
685d6013
authored
12月 19, 2020
作者:
Glenn Jocher
提交者:
GitHub
12月 19, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Increase plot_labels() speed (#1736)
上级
49abc722
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
10 行增加
和
18 行删除
+10
-18
train.py
train.py
+1
-1
plots.py
utils/plots.py
+9
-17
没有找到文件。
train.py
浏览文件 @
685d6013
...
...
@@ -205,7 +205,7 @@ def train(hyp, opt, device, tb_writer=None, wandb=None):
# cf = torch.bincount(c.long(), minlength=nc) + 1. # frequency
# model._initialize_biases(cf.to(device))
if
plots
:
Thread
(
target
=
plot_labels
,
args
=
(
labels
,
save_dir
,
loggers
),
daemon
=
True
)
.
start
(
)
plot_labels
(
labels
,
save_dir
,
loggers
)
if
tb_writer
:
tb_writer
.
add_histogram
(
'classes'
,
c
,
0
)
...
...
utils/plots.py
浏览文件 @
685d6013
...
...
@@ -11,6 +11,8 @@ import cv2
import
matplotlib
import
matplotlib.pyplot
as
plt
import
numpy
as
np
import
pandas
as
pd
import
seaborn
as
sns
import
torch
import
yaml
from
PIL
import
Image
,
ImageDraw
...
...
@@ -253,34 +255,24 @@ def plot_study_txt(path='', x=None): # from utils.plots import *; plot_study_tx
def
plot_labels
(
labels
,
save_dir
=
Path
(
''
),
loggers
=
None
):
# plot dataset labels
print
(
'Plotting labels... '
)
c
,
b
=
labels
[:,
0
],
labels
[:,
1
:]
.
transpose
()
# classes, boxes
nc
=
int
(
c
.
max
()
+
1
)
# number of classes
colors
=
color_list
()
x
=
pd
.
DataFrame
(
b
.
transpose
(),
columns
=
[
'x'
,
'y'
,
'width'
,
'height'
])
# seaborn correlogram
try
:
import
seaborn
as
sns
import
pandas
as
pd
x
=
pd
.
DataFrame
(
b
.
transpose
(),
columns
=
[
'x'
,
'y'
,
'width'
,
'height'
])
sns
.
pairplot
(
x
,
corner
=
True
,
diag_kind
=
'hist'
,
kind
=
'scatter'
,
markers
=
'o'
,
plot_kws
=
dict
(
s
=
3
,
edgecolor
=
None
,
linewidth
=
1
,
alpha
=
0.02
),
diag_kws
=
dict
(
bins
=
50
))
plt
.
savefig
(
save_dir
/
'labels_correlogram.jpg'
,
dpi
=
200
)
plt
.
close
()
except
Exception
as
e
:
pass
sns
.
pairplot
(
x
,
corner
=
True
,
diag_kind
=
'auto'
,
kind
=
'hist'
,
diag_kws
=
dict
(
bins
=
50
),
plot_kws
=
dict
(
pmax
=
0.9
))
plt
.
savefig
(
save_dir
/
'labels_correlogram.jpg'
,
dpi
=
200
)
plt
.
close
()
# matplotlib labels
matplotlib
.
use
(
'svg'
)
# faster
ax
=
plt
.
subplots
(
2
,
2
,
figsize
=
(
8
,
8
),
tight_layout
=
True
)[
1
]
.
ravel
()
ax
[
0
]
.
hist
(
c
,
bins
=
np
.
linspace
(
0
,
nc
,
nc
+
1
)
-
0.5
,
rwidth
=
0.8
)
ax
[
0
]
.
set_xlabel
(
'classes'
)
ax
[
2
]
.
scatter
(
b
[
0
],
b
[
1
],
c
=
hist2d
(
b
[
0
],
b
[
1
],
90
),
cmap
=
'jet'
)
ax
[
2
]
.
set_xlabel
(
'x'
)
ax
[
2
]
.
set_ylabel
(
'y'
)
ax
[
3
]
.
scatter
(
b
[
2
],
b
[
3
],
c
=
hist2d
(
b
[
2
],
b
[
3
],
90
),
cmap
=
'jet'
)
ax
[
3
]
.
set_xlabel
(
'width'
)
ax
[
3
]
.
set_ylabel
(
'height'
)
sns
.
histplot
(
x
,
x
=
'x'
,
y
=
'y'
,
ax
=
ax
[
2
],
bins
=
50
,
pmax
=
0.9
)
sns
.
histplot
(
x
,
x
=
'width'
,
y
=
'height'
,
ax
=
ax
[
3
],
bins
=
50
,
pmax
=
0.9
)
# rectangles
labels
[:,
1
:
3
]
=
0.5
# center
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论