support CMU Mocap
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -13,3 +13,4 @@ smplpytorch/native/models/*.pkl
|
|||||||
|
|
||||||
exp/
|
exp/
|
||||||
output/
|
output/
|
||||||
|
make_gif.py
|
||||||
0
01_01_params.pkl
Normal file
0
01_01_params.pkl
Normal file
@ -43,6 +43,7 @@ The SMPL human body layer for Pytorch is from the [smplpytorch](https://github.c
|
|||||||
currently supported datasets:
|
currently supported datasets:
|
||||||
|
|
||||||
- [HumanAct12](https://ericguo5513.github.io/action-to-motion/)
|
- [HumanAct12](https://ericguo5513.github.io/action-to-motion/)
|
||||||
|
- [CMU Mocap](https://ericguo5513.github.io/action-to-motion/)
|
||||||
- [UTD-MHAD](https://personal.utdallas.edu/~kehtar/UTD-MHAD.html)
|
- [UTD-MHAD](https://personal.utdallas.edu/~kehtar/UTD-MHAD.html)
|
||||||
|
|
||||||
- Set the **DATASET.PATH** in the corresponding configuration file to the location of dataset.
|
- Set the **DATASET.PATH** in the corresponding configuration file to the location of dataset.
|
||||||
|
|||||||
89
fit/configs/CMU_Mocap.json
Normal file
89
fit/configs/CMU_Mocap.json
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
{
|
||||||
|
"MODEL": {
|
||||||
|
"GENDER": "neutral"
|
||||||
|
},
|
||||||
|
"TRAIN": {
|
||||||
|
"LEARNING_RATE": 2e-2,
|
||||||
|
"MAX_EPOCH": 1000,
|
||||||
|
"WRITE": 1,
|
||||||
|
"OPTIMIZE_SCALE":1,
|
||||||
|
"OPTIMIZE_SHAPE":0
|
||||||
|
},
|
||||||
|
"USE_GPU": 1,
|
||||||
|
"DATASET": {
|
||||||
|
"NAME": "UTD-MHAD",
|
||||||
|
"PATH": "../Action2Motion/CMU Mocap/mocap/mocap_3djoints/",
|
||||||
|
"TARGET_PATH": "",
|
||||||
|
"DATA_MAP": [
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
[
|
||||||
|
9,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
[
|
||||||
|
12,
|
||||||
|
2
|
||||||
|
],
|
||||||
|
[
|
||||||
|
13,
|
||||||
|
4
|
||||||
|
],
|
||||||
|
[
|
||||||
|
18,
|
||||||
|
6
|
||||||
|
],
|
||||||
|
[
|
||||||
|
20,
|
||||||
|
7
|
||||||
|
],
|
||||||
|
[
|
||||||
|
14,
|
||||||
|
8
|
||||||
|
],
|
||||||
|
[
|
||||||
|
19,
|
||||||
|
10
|
||||||
|
],
|
||||||
|
[
|
||||||
|
21,
|
||||||
|
11
|
||||||
|
],
|
||||||
|
[
|
||||||
|
1,
|
||||||
|
12
|
||||||
|
],
|
||||||
|
[
|
||||||
|
4,
|
||||||
|
13
|
||||||
|
],
|
||||||
|
[
|
||||||
|
7,
|
||||||
|
14
|
||||||
|
],
|
||||||
|
[
|
||||||
|
10,
|
||||||
|
15
|
||||||
|
],
|
||||||
|
[
|
||||||
|
2,
|
||||||
|
16
|
||||||
|
],
|
||||||
|
[
|
||||||
|
5,
|
||||||
|
17
|
||||||
|
],
|
||||||
|
[
|
||||||
|
8,
|
||||||
|
18
|
||||||
|
],
|
||||||
|
[
|
||||||
|
11,
|
||||||
|
19
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"DEBUG": 0
|
||||||
|
}
|
||||||
83
fit/configs/Human3.6M.json
Normal file
83
fit/configs/Human3.6M.json
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
{
|
||||||
|
"MODEL": {
|
||||||
|
"GENDER": "neutral"
|
||||||
|
},
|
||||||
|
"TRAIN": {
|
||||||
|
"LEARNING_RATE": 2e-2,
|
||||||
|
"MAX_EPOCH": 1000,
|
||||||
|
"WRITE": 1
|
||||||
|
},
|
||||||
|
"USE_GPU": 1,
|
||||||
|
"DATASET": {
|
||||||
|
"NAME": "UTD-MHAD",
|
||||||
|
"PATH": "../UTD-MHAD/Skeleton/Skeleton/",
|
||||||
|
"TARGET_PATH": "",
|
||||||
|
"DATA_MAP": [
|
||||||
|
[
|
||||||
|
12,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
3
|
||||||
|
],
|
||||||
|
[
|
||||||
|
16,
|
||||||
|
4
|
||||||
|
],
|
||||||
|
[
|
||||||
|
18,
|
||||||
|
5
|
||||||
|
],
|
||||||
|
[
|
||||||
|
20,
|
||||||
|
6
|
||||||
|
],
|
||||||
|
[
|
||||||
|
22,
|
||||||
|
7
|
||||||
|
],
|
||||||
|
[
|
||||||
|
17,
|
||||||
|
8
|
||||||
|
],
|
||||||
|
[
|
||||||
|
19,
|
||||||
|
9
|
||||||
|
],
|
||||||
|
[
|
||||||
|
21,
|
||||||
|
10
|
||||||
|
],
|
||||||
|
[
|
||||||
|
23,
|
||||||
|
11
|
||||||
|
],
|
||||||
|
[
|
||||||
|
1,
|
||||||
|
12
|
||||||
|
],
|
||||||
|
[
|
||||||
|
4,
|
||||||
|
13
|
||||||
|
],
|
||||||
|
[
|
||||||
|
7,
|
||||||
|
14
|
||||||
|
],
|
||||||
|
[
|
||||||
|
2,
|
||||||
|
16
|
||||||
|
],
|
||||||
|
[
|
||||||
|
5,
|
||||||
|
17
|
||||||
|
],
|
||||||
|
[
|
||||||
|
8,
|
||||||
|
18
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"DEBUG": 0
|
||||||
|
}
|
||||||
@ -5,7 +5,9 @@
|
|||||||
"TRAIN": {
|
"TRAIN": {
|
||||||
"LEARNING_RATE": 2e-2,
|
"LEARNING_RATE": 2e-2,
|
||||||
"MAX_EPOCH": 1000,
|
"MAX_EPOCH": 1000,
|
||||||
"WRITE": 1
|
"WRITE": 1,
|
||||||
|
"OPTIMIZE_SCALE":0,
|
||||||
|
"OPTIMIZE_SHAPE":1
|
||||||
},
|
},
|
||||||
"USE_GPU": 1,
|
"USE_GPU": 1,
|
||||||
"DATASET": {
|
"DATASET": {
|
||||||
|
|||||||
@ -5,7 +5,9 @@
|
|||||||
"TRAIN": {
|
"TRAIN": {
|
||||||
"LEARNING_RATE": 2e-2,
|
"LEARNING_RATE": 2e-2,
|
||||||
"MAX_EPOCH": 1000,
|
"MAX_EPOCH": 1000,
|
||||||
"WRITE": 1
|
"WRITE": 1,
|
||||||
|
"OPTIMIZE_SCALE":0,
|
||||||
|
"OPTIMIZE_SHAPE":1
|
||||||
},
|
},
|
||||||
"USE_GPU": 1,
|
"USE_GPU": 1,
|
||||||
"DATASET": {
|
"DATASET": {
|
||||||
|
|||||||
1094
fit/tools/label.py
1094
fit/tools/label.py
File diff suppressed because it is too large
Load Diff
@ -14,3 +14,6 @@ def load(name, path):
|
|||||||
return new_arr
|
return new_arr
|
||||||
elif name == 'HumanAct12':
|
elif name == 'HumanAct12':
|
||||||
return np.load(path,allow_pickle=True)
|
return np.load(path,allow_pickle=True)
|
||||||
|
elif name == "CMU_Mocap":
|
||||||
|
return np.load(path,allow_pickle=True)
|
||||||
|
|
||||||
|
|||||||
@ -33,17 +33,17 @@ def save_pic(res, smpl_layer, file, logger, dataset_name,target):
|
|||||||
savepath=os.path.join(fit_path+"/frame_{}".format(i)),
|
savepath=os.path.join(fit_path+"/frame_{}".format(i)),
|
||||||
batch_idx=i,
|
batch_idx=i,
|
||||||
show=False,
|
show=False,
|
||||||
only_joint=False)
|
|
||||||
display_model(
|
|
||||||
{'verts': verts.cpu().detach(),
|
|
||||||
'joints': target.cpu().detach()},
|
|
||||||
model_faces=smpl_layer.th_faces,
|
|
||||||
with_joints=True,
|
|
||||||
kintree_table=smpl_layer.kintree_table,
|
|
||||||
savepath=os.path.join(gt_path+"/frame_{}".format(i)),
|
|
||||||
batch_idx=i,
|
|
||||||
show=False,
|
|
||||||
only_joint=True)
|
only_joint=True)
|
||||||
|
# display_model(
|
||||||
|
# {'verts': verts.cpu().detach(),
|
||||||
|
# 'joints': target.cpu().detach()},
|
||||||
|
# model_faces=smpl_layer.th_faces,
|
||||||
|
# with_joints=True,
|
||||||
|
# kintree_table=smpl_layer.kintree_table,
|
||||||
|
# savepath=os.path.join(gt_path+"/frame_{}".format(i)),
|
||||||
|
# batch_idx=i,
|
||||||
|
# show=False,
|
||||||
|
# only_joint=True)
|
||||||
logger.info('Pictures saved')
|
logger.info('Pictures saved')
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -42,10 +42,10 @@ def init(smpl_layer, target, device, cfg):
|
|||||||
params["scale"] = params["scale"].to(device)
|
params["scale"] = params["scale"].to(device)
|
||||||
|
|
||||||
params["pose_params"].requires_grad = True
|
params["pose_params"].requires_grad = True
|
||||||
params["shape_params"].requires_grad = True
|
params["shape_params"].requires_grad = bool(cfg.TRAIN.OPTIMIZE_SHAPE)
|
||||||
params["scale"].requires_grad = False
|
params["scale"].requires_grad = bool(cfg.TRAIN.OPTIMIZE_SCALE)
|
||||||
|
|
||||||
optimizer = optim.Adam([params["pose_params"], params["shape_params"]],
|
optimizer = optim.Adam([params["pose_params"], params["shape_params"], params["scale"]],
|
||||||
lr=cfg.TRAIN.LEARNING_RATE)
|
lr=cfg.TRAIN.LEARNING_RATE)
|
||||||
|
|
||||||
index={}
|
index={}
|
||||||
@ -73,8 +73,9 @@ def train(smpl_layer, target,
|
|||||||
|
|
||||||
early_stop = Early_Stop()
|
early_stop = Early_Stop()
|
||||||
for epoch in tqdm(range(cfg.TRAIN.MAX_EPOCH)):
|
for epoch in tqdm(range(cfg.TRAIN.MAX_EPOCH)):
|
||||||
|
# for epoch in range(cfg.TRAIN.MAX_EPOCH):
|
||||||
verts, Jtr = smpl_layer(pose_params, th_betas=shape_params)
|
verts, Jtr = smpl_layer(pose_params, th_betas=shape_params)
|
||||||
loss = F.smooth_l1_loss(Jtr.index_select(1, index["smpl_index"]) * 100,
|
loss = F.smooth_l1_loss(Jtr.index_select(1, index["smpl_index"]) * 100 * scale,
|
||||||
target.index_select(1, index["dataset_index"]) * 100)
|
target.index_select(1, index["dataset_index"]) * 100)
|
||||||
optimizer.zero_grad()
|
optimizer.zero_grad()
|
||||||
loss.backward()
|
loss.backward()
|
||||||
@ -88,8 +89,8 @@ def train(smpl_layer, target,
|
|||||||
break
|
break
|
||||||
|
|
||||||
if epoch % cfg.TRAIN.WRITE == 0:
|
if epoch % cfg.TRAIN.WRITE == 0:
|
||||||
# logger.info("Epoch {}, lossPerBatch={:.6f}, EarlyStopSatis: {}".format(
|
# logger.info("Epoch {}, lossPerBatch={:.6f}, scale={:.4f} EarlyStopSatis: {}".format(
|
||||||
# epoch, float(loss), early_stop.satis_num))
|
# epoch, float(loss),float(scale), early_stop.satis_num))
|
||||||
writer.add_scalar('loss', float(loss), epoch)
|
writer.add_scalar('loss', float(loss), epoch)
|
||||||
writer.add_scalar('learning_rate', float(
|
writer.add_scalar('learning_rate', float(
|
||||||
optimizer.state_dict()['param_groups'][0]['lr']), epoch)
|
optimizer.state_dict()['param_groups'][0]['lr']), epoch)
|
||||||
|
|||||||
@ -1,23 +1,17 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
rotate = {
|
||||||
|
'HumanAct12': [1., -1., -1.],
|
||||||
|
'CMU_Mocap': [0.05, 0.05, 0.05],
|
||||||
|
'UTD_MHAD': [-1., 1., -1.]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def transform(name, arr: np.ndarray):
|
def transform(name, arr: np.ndarray):
|
||||||
if name == 'HumanAct12':
|
|
||||||
rotate = [1., -1., -1.]
|
|
||||||
for i in range(arr.shape[0]):
|
for i in range(arr.shape[0]):
|
||||||
origin = arr[i][0].copy()
|
origin = arr[i][0].copy()
|
||||||
for j in range(arr.shape[1]):
|
for j in range(arr.shape[1]):
|
||||||
arr[i][j] -= origin
|
arr[i][j] -= origin
|
||||||
for k in range(3):
|
for k in range(3):
|
||||||
arr[i][j][k] *= rotate[k]
|
arr[i][j][k] *= rotate[name][k]
|
||||||
arr[i][0] = [0.0, 0.0, 0.0]
|
|
||||||
elif name == 'UTD_MHAD':
|
|
||||||
rotate = [-1., 1.,-1.]
|
|
||||||
for i in range(arr.shape[0]):
|
|
||||||
origin = arr[i][3].copy()
|
|
||||||
for j in range(arr.shape[1]):
|
|
||||||
arr[i][j] -= origin
|
|
||||||
for k in range(3):
|
|
||||||
arr[i][j][k] *= rotate[k]
|
|
||||||
arr[i][3] = [0.0, 0.0, 0.0]
|
|
||||||
return arr
|
return arr
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import imageio, os
|
import imageio, os
|
||||||
images = []
|
images = []
|
||||||
filenames = sorted(fn for fn in os.listdir('./fit/output/HumanAct12/picture/fit/P01G01R01F0001T0064A0101') )
|
filenames = sorted(fn for fn in os.listdir('./fit/output/CMU_Mocap/picture/fit/01_01') )
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
images.append(imageio.imread('./fit/output/HumanAct12/picture/fit/P01G01R01F0001T0064A0101/'+filename))
|
images.append(imageio.imread('./fit/output/CMU_Mocap/picture/fit/01_01/'+filename))
|
||||||
imageio.mimsave('./assets/fit.gif', images, duration=0.25)
|
imageio.mimsave('fit.gif', images, duration=0.2)
|
||||||
Reference in New Issue
Block a user