Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
dbbc6b5c
Unverified
提交
dbbc6b5c
authored
8月 29, 2021
作者:
Glenn Jocher
提交者:
GitHub
8月 29, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Re-order `plots.py` to class-first (#4595)
上级
e5e5ebc7
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
26 行增加
和
24 行删除
+26
-24
plots.py
utils/plots.py
+26
-24
没有找到文件。
utils/plots.py
浏览文件 @
dbbc6b5c
...
...
@@ -45,30 +45,8 @@ class Colors:
colors
=
Colors
()
# create instance for 'from utils.plots import colors'
def
hist2d
(
x
,
y
,
n
=
100
):
# 2d histogram used in labels.png and evolve.png
xedges
,
yedges
=
np
.
linspace
(
x
.
min
(),
x
.
max
(),
n
),
np
.
linspace
(
y
.
min
(),
y
.
max
(),
n
)
hist
,
xedges
,
yedges
=
np
.
histogram2d
(
x
,
y
,
(
xedges
,
yedges
))
xidx
=
np
.
clip
(
np
.
digitize
(
x
,
xedges
)
-
1
,
0
,
hist
.
shape
[
0
]
-
1
)
yidx
=
np
.
clip
(
np
.
digitize
(
y
,
yedges
)
-
1
,
0
,
hist
.
shape
[
1
]
-
1
)
return
np
.
log
(
hist
[
xidx
,
yidx
])
def
butter_lowpass_filtfilt
(
data
,
cutoff
=
1500
,
fs
=
50000
,
order
=
5
):
from
scipy.signal
import
butter
,
filtfilt
# https://stackoverflow.com/questions/28536191/how-to-filter-smooth-with-scipy-numpy
def
butter_lowpass
(
cutoff
,
fs
,
order
):
nyq
=
0.5
*
fs
normal_cutoff
=
cutoff
/
nyq
return
butter
(
order
,
normal_cutoff
,
btype
=
'low'
,
analog
=
False
)
b
,
a
=
butter_lowpass
(
cutoff
,
fs
,
order
=
order
)
return
filtfilt
(
b
,
a
,
data
)
# forward-backward filter
class
Annotator
:
# YOLOv5
PIL Annotator clas
s
# YOLOv5
Annotator for train/val mosaics and jpgs and detect/hub inference annotation
s
def
__init__
(
self
,
im
,
line_width
=
None
,
font_size
=
None
,
font
=
'Arial.ttf'
,
pil
=
True
):
assert
im
.
data
.
contiguous
,
'Image not contiguous. Apply np.ascontiguousarray(im) to plot_on_box() input image.'
self
.
pil
=
pil
...
...
@@ -79,9 +57,11 @@ class Annotator:
f
=
font_size
or
max
(
round
(
s
*
0.035
),
12
)
try
:
self
.
font
=
ImageFont
.
truetype
(
font
,
size
=
f
)
except
:
# download TTF
except
Exception
as
e
:
# download TTF if missing
print
(
f
'WARNING: Annotator font {font} not found: {e}'
)
url
=
"https://github.com/ultralytics/yolov5/releases/download/v1.0/"
+
font
torch
.
hub
.
download_url_to_file
(
url
,
font
)
print
(
f
'Annotator font successfully downloaded from {url} to {font}'
)
self
.
font
=
ImageFont
.
truetype
(
font
,
size
=
f
)
self
.
fh
=
self
.
font
.
getsize
(
'a'
)[
1
]
-
3
# font height
else
:
# use cv2
...
...
@@ -122,6 +102,28 @@ class Annotator:
return
np
.
asarray
(
self
.
im
)
def
hist2d
(
x
,
y
,
n
=
100
):
# 2d histogram used in labels.png and evolve.png
xedges
,
yedges
=
np
.
linspace
(
x
.
min
(),
x
.
max
(),
n
),
np
.
linspace
(
y
.
min
(),
y
.
max
(),
n
)
hist
,
xedges
,
yedges
=
np
.
histogram2d
(
x
,
y
,
(
xedges
,
yedges
))
xidx
=
np
.
clip
(
np
.
digitize
(
x
,
xedges
)
-
1
,
0
,
hist
.
shape
[
0
]
-
1
)
yidx
=
np
.
clip
(
np
.
digitize
(
y
,
yedges
)
-
1
,
0
,
hist
.
shape
[
1
]
-
1
)
return
np
.
log
(
hist
[
xidx
,
yidx
])
def
butter_lowpass_filtfilt
(
data
,
cutoff
=
1500
,
fs
=
50000
,
order
=
5
):
from
scipy.signal
import
butter
,
filtfilt
# https://stackoverflow.com/questions/28536191/how-to-filter-smooth-with-scipy-numpy
def
butter_lowpass
(
cutoff
,
fs
,
order
):
nyq
=
0.5
*
fs
normal_cutoff
=
cutoff
/
nyq
return
butter
(
order
,
normal_cutoff
,
btype
=
'low'
,
analog
=
False
)
b
,
a
=
butter_lowpass
(
cutoff
,
fs
,
order
=
order
)
return
filtfilt
(
b
,
a
,
data
)
# forward-backward filter
def
output_to_target
(
output
):
# Convert model output to target format [batch_id, class_id, x, y, w, h, conf]
targets
=
[]
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论