Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
m0_58841266
e3d_handpose_x
提交
51a48f24
e3d_handpose_x
项目概览
m0_58841266
/
e3d_handpose_x
与 Fork 源项目一致
Fork自
Eric.Lee2021 / e3d_handpose_x
通知
2
Star
1
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
e3d_handpose_x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
51a48f24
编写于
6月 25, 2021
作者:
Eric.Lee2021
🚴🏻
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add optimize_shape
上级
6ea17475
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
97 addition
and
0 deletion
+97
-0
optimize_shape.py
optimize_shape.py
+97
-0
未找到文件。
optimize_shape.py
0 → 100644
浏览文件 @
51a48f24
import
argparse
import
numpy
as
np
from
tqdm
import
tqdm
from
utils
import
func
,
bone
from
utils.LM
import
LM_Solver
def
align_bone_len
(
opt_
,
pre_
):
opt
=
opt_
.
copy
()
pre
=
pre_
.
copy
()
opt_align
=
opt
.
copy
()
for
i
in
range
(
opt
.
shape
[
0
]):
ratio
=
pre
[
i
][
6
]
/
opt
[
i
][
6
]
opt_align
[
i
]
=
ratio
*
opt_align
[
i
]
err
=
np
.
abs
(
opt_align
-
pre
).
mean
(
0
)
return
err
def
main
(
args
):
path
=
args
.
path
for
dataset
in
args
.
dataset
:
# load predictions (N*21*3)
print
(
"load {}'s joint 3D"
.
format
(
dataset
))
pred_j3d
=
np
.
load
(
"{}/{}_pre_joints.npy"
.
format
(
path
,
dataset
),
allow_pickle
=
True
)
opt_shapes
=
[]
opt_bone_lens
=
[]
pre_useful_bone_lens
=
[]
# loop
for
pred
in
tqdm
(
pred_j3d
):
# 0 initialization
pose
,
shape
=
func
.
initiate
(
"zero"
)
pre_useful_bone_len
=
bone
.
caculate_length
(
pred
,
label
=
"useful"
)
pre_useful_bone_lens
.
append
(
pre_useful_bone_len
)
# optimize here!
solver
=
LM_Solver
(
num_Iter
=
500
,
th_beta
=
shape
,
th_pose
=
pose
,
lb_target
=
pre_useful_bone_len
,
weight
=
args
.
weight
)
opt_shape
=
solver
.
LM
()
opt_shapes
.
append
(
opt_shape
)
opt_bone_len
=
solver
.
get_bones
(
opt_shape
)
opt_bone_lens
.
append
(
opt_bone_len
)
# plt.plot(solver.get_result(), 'r')
# plt.show()
# break
opt_shapes
=
np
.
array
(
opt_shapes
).
reshape
(
-
1
,
10
)
opt_bone_lens
=
np
.
array
(
opt_bone_lens
).
reshape
(
-
1
,
15
)
pre_useful_bone_lens
=
np
.
array
(
pre_useful_bone_lens
).
reshape
(
-
1
,
15
)
np
.
save
(
"{}/{}_shapes.npy"
.
format
(
path
,
dataset
,
args
.
weight
),
opt_shapes
)
error
=
align_bone_len
(
opt_bone_lens
,
pre_useful_bone_lens
)
print
(
"dataset:{} weight:{} ERR sum: {}"
.
format
(
dataset
,
args
.
weight
,
error
.
sum
()))
if
__name__
==
'__main__'
:
parser
=
argparse
.
ArgumentParser
(
description
=
'optimize shape params. of mano model '
)
# Dataset setting
parser
.
add_argument
(
'-ds'
,
"--dataset"
,
nargs
=
"+"
,
default
=
[
'rhd'
,
'stb'
,
'do'
,
'eo'
],
type
=
str
,
help
=
"sub datasets, should be listed in: [stb|rhd|do|eo]"
)
parser
.
add_argument
(
'-wt'
,
'--weight'
,
default
=
1e-5
,
type
=
float
,
metavar
=
'weight'
,
help
=
'weight of L2 regularizer '
)
parser
.
add_argument
(
'-p'
,
'--path'
,
default
=
'out_testset'
,
type
=
str
,
metavar
=
'data_root'
,
help
=
'directory'
)
main
(
parser
.
parse_args
())
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录