Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
7e008591
P
PaddleDetection
项目概览
s920243400
/
PaddleDetection
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleDetection
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
7e008591
编写于
6月 30, 2022
作者:
Z
zhiboniu
提交者:
zhiboniu
7月 01, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update ema filter;
refix keypoint transform to orgimage
上级
07f5f782
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
31 addition
and
9 deletion
+31
-9
deploy/lite/include/keypoint_postprocess.h
deploy/lite/include/keypoint_postprocess.h
+2
-1
deploy/lite/src/keypoint_postprocess.cc
deploy/lite/src/keypoint_postprocess.cc
+20
-5
deploy/python/det_keypoint_unite_infer.py
deploy/python/det_keypoint_unite_infer.py
+9
-3
未找到文件。
deploy/lite/include/keypoint_postprocess.h
浏览文件 @
7e008591
...
@@ -33,7 +33,8 @@ void transform_preds(std::vector<float>& coords,
...
@@ -33,7 +33,8 @@ void transform_preds(std::vector<float>& coords,
std
::
vector
<
float
>&
scale
,
std
::
vector
<
float
>&
scale
,
std
::
vector
<
int
>&
output_size
,
std
::
vector
<
int
>&
output_size
,
std
::
vector
<
int
>&
dim
,
std
::
vector
<
int
>&
dim
,
std
::
vector
<
float
>&
target_coords
);
std
::
vector
<
float
>&
target_coords
,
bool
affine
);
void
box_to_center_scale
(
std
::
vector
<
int
>&
box
,
void
box_to_center_scale
(
std
::
vector
<
int
>&
box
,
int
width
,
int
width
,
int
height
,
int
height
,
...
...
deploy/lite/src/keypoint_postprocess.cc
浏览文件 @
7e008591
...
@@ -74,11 +74,26 @@ void transform_preds(std::vector<float>& coords,
...
@@ -74,11 +74,26 @@ void transform_preds(std::vector<float>& coords,
std
::
vector
<
float
>&
scale
,
std
::
vector
<
float
>&
scale
,
std
::
vector
<
int
>&
output_size
,
std
::
vector
<
int
>&
output_size
,
std
::
vector
<
int64_t
>&
dim
,
std
::
vector
<
int64_t
>&
dim
,
std
::
vector
<
float
>&
target_coords
)
{
std
::
vector
<
float
>&
target_coords
,
cv
::
Mat
trans
(
2
,
3
,
CV_64FC1
);
bool
affine
=
false
)
{
get_affine_transform
(
center
,
scale
,
0
,
output_size
,
trans
,
1
);
if
(
affine
)
{
for
(
int
p
=
0
;
p
<
dim
[
1
];
++
p
)
{
cv
::
Mat
trans
(
2
,
3
,
CV_64FC1
);
affine_tranform
(
coords
[
p
*
2
],
coords
[
p
*
2
+
1
],
trans
,
target_coords
,
p
);
get_affine_transform
(
center
,
scale
,
0
,
output_size
,
trans
,
1
);
for
(
int
p
=
0
;
p
<
dim
[
1
];
++
p
)
{
affine_tranform
(
coords
[
p
*
2
],
coords
[
p
*
2
+
1
],
trans
,
target_coords
,
p
);
}
}
else
{
float
heat_w
=
static_cast
<
float
>
(
output_size
[
0
]);
float
heat_h
=
static_cast
<
float
>
(
output_size
[
1
]);
float
x_scale
=
scale
[
0
]
/
heat_w
;
float
y_scale
=
scale
[
1
]
/
heat_h
;
float
offset_x
=
center
[
0
]
-
scale
[
0
]
/
2.
;
float
offset_y
=
center
[
1
]
-
scale
[
1
]
/
2.
;
for
(
int
i
=
0
;
i
<
dim
[
1
];
i
++
)
{
target_coords
[
i
*
3
+
1
]
=
x_scale
*
coords
[
i
*
2
]
+
offset_x
;
target_coords
[
i
*
3
+
2
]
=
y_scale
*
coords
[
i
*
2
+
1
]
+
offset_y
;
}
}
}
}
}
...
...
deploy/python/det_keypoint_unite_infer.py
浏览文件 @
7e008591
...
@@ -165,7 +165,7 @@ def topdown_unite_predict_video(detector,
...
@@ -165,7 +165,7 @@ def topdown_unite_predict_video(detector,
frame2
,
results
,
topdown_keypoint_detector
,
keypoint_batch_size
,
frame2
,
results
,
topdown_keypoint_detector
,
keypoint_batch_size
,
FLAGS
.
run_benchmark
)
FLAGS
.
run_benchmark
)
if
FLAGS
.
smooth
and
len
(
keypoint_res
[
'keypoint'
][
0
])
==
1
:
if
FLAGS
.
smooth
and
len
(
keypoint_res
[
'keypoint'
][
0
])
==
1
:
current_keypoints
=
np
.
array
(
keypoint_res
[
'keypoint'
][
0
][
0
])
current_keypoints
=
np
.
array
(
keypoint_res
[
'keypoint'
][
0
][
0
])
smooth_keypoints
=
keypoint_smoothing
.
smooth_process
(
smooth_keypoints
=
keypoint_smoothing
.
smooth_process
(
current_keypoints
)
current_keypoints
)
...
@@ -215,7 +215,7 @@ class KeypointSmoothing(object):
...
@@ -215,7 +215,7 @@ class KeypointSmoothing(object):
fc_d
=
0.1
,
fc_d
=
0.1
,
fc_min
=
0.1
,
fc_min
=
0.1
,
beta
=
0.1
,
beta
=
0.1
,
thres_mult
=
0.
2
):
thres_mult
=
0.
3
):
super
(
KeypointSmoothing
,
self
).
__init__
()
super
(
KeypointSmoothing
,
self
).
__init__
()
self
.
image_width
=
width
self
.
image_width
=
width
self
.
image_height
=
height
self
.
image_height
=
height
...
@@ -234,7 +234,7 @@ class KeypointSmoothing(object):
...
@@ -234,7 +234,7 @@ class KeypointSmoothing(object):
if
self
.
filter_type
==
'OneEuro'
:
if
self
.
filter_type
==
'OneEuro'
:
self
.
smooth_func
=
self
.
one_euro_filter
self
.
smooth_func
=
self
.
one_euro_filter
elif
self
.
filter_type
==
'EMA'
:
elif
self
.
filter_type
==
'EMA'
:
self
.
smooth_func
=
self
.
e
xponential_smoothing
self
.
smooth_func
=
self
.
e
ma_filter
else
:
else
:
raise
ValueError
(
'filter type must be one_euro or ema'
)
raise
ValueError
(
'filter type must be one_euro or ema'
)
...
@@ -261,6 +261,7 @@ class KeypointSmoothing(object):
...
@@ -261,6 +261,7 @@ class KeypointSmoothing(object):
else
:
else
:
result
=
self
.
smooth_func
(
current_keypoint
,
self
.
x_prev_hat
[
index
],
result
=
self
.
smooth_func
(
current_keypoint
,
self
.
x_prev_hat
[
index
],
index
)
index
)
return
result
return
result
def
one_euro_filter
(
self
,
x_cur
,
x_pre
,
index
):
def
one_euro_filter
(
self
,
x_cur
,
x_pre
,
index
):
...
@@ -276,6 +277,11 @@ class KeypointSmoothing(object):
...
@@ -276,6 +277,11 @@ class KeypointSmoothing(object):
self
.
x_prev_hat
[
index
]
=
x_cur_hat
self
.
x_prev_hat
[
index
]
=
x_cur_hat
return
x_cur_hat
return
x_cur_hat
def
ema_filter
(
self
,
x_cur
,
x_pre
,
index
):
x_cur_hat
=
self
.
exponential_smoothing
(
x_cur
,
x_pre
)
self
.
x_prev_hat
[
index
]
=
x_cur_hat
return
x_cur_hat
def
smoothing_factor
(
self
,
te
,
fc
):
def
smoothing_factor
(
self
,
te
,
fc
):
r
=
2
*
math
.
pi
*
fc
*
te
r
=
2
*
math
.
pi
*
fc
*
te
return
r
/
(
r
+
1
)
return
r
/
(
r
+
1
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录