Xinyu-Yi / PIP

A real-time system that captures physically correct human motion, joint torques, and ground reaction forces with only 6 inertial measurement units
https://xinyu-yi.github.io/PIP/
GNU General Public License v3.0
312 stars 38 forks source link

Normalization and splicing issues - I get an error after using my own processed data #41

Closed Cursky closed 3 months ago

Cursky commented 3 months ago

Please help the author. I want to know what the normalization in utils does. I get an error here when using my own imu data. I found that my shape is exactly the same as dip imu, but I encounter a problem at this position. I hope someone who has encountered this problem can discuss it with me. error: Traceback (most recent call last): File "d:\pip_package\PIP-main\evaluate.py", line 215, in evaluate(net, paths.dipimu_dir, pose_evaluator=reduced_pose_evaluator, evaluate_pose=False, evaluate_zmp=False, flush_cache=True) File "d:\pip_package\PIP-main\evaluate.py", line 148, in evaluate run_pipeline(net, data_dir, missing_ids) File "d:\pip_package\PIP-main\evaluate.py", line 120, in run_pipeline result_net = net.predict(accs[i], rots[i], init_poses[i]) File "C:\Users\godof\anaconda3\envs\pipenv\lib\site-packages\torch\autograd\grad_mode.py", line 28, in decorate_context return func(*args, **kwargs) File "d:\pip_package\PIP-main\net.py", line 99, in predict x = (normalize_and_concat(glb_acc, glb_rot), lj_init, jvel_init) File "d:\pip_package\PIP-main\utils.py", line 77, in normalize_and_concat acc = torch.cat((glb_acc[:, :5] - glb_acc[:, 5:], glb_acc[:, 5:]), dim=1).bmm(glb_rot[:, -1]) RuntimeError: expected scalar type Double but found Float

def normalize_and_concat(glb_acc, glb_rot): glb_acc = glb_acc.view(-1, 6, 3) glb_rot = glb_rot.view(-1, 6, 3, 3) print('glbacc glbrot shape',glb_acc.shape, glb_rot.shape) print('glbacc - glbacc :',glb_acc[:, :5] - glb_acc[:, 5:]) print('glbacc - glbacc shape:',(glb_acc[:, :5] - glb_acc[:, 5:]).shape) print('cat',torch.cat((glb_acc[:, :5] - glb_acc[:, 5:], glb_acc[:, 5:]), dim=1)) print('cat shape:',torch.cat((glb_acc[:, :5] - glb_acc[:, 5:], glb_acc[:, 5:]), dim=1).shape) print('glb_rot:',glb_rot[:, -1]) print('glb_rotshape',glb_rot[:, -1].shape) acc = torch.cat((glb_acc[:, :5] - glb_acc[:, 5:], glb_acc[:, 5:]), dim=1).bmm(glb_rot[:, -1]) ori = torch.cat((glb_rot[:, 5:].transpose(2, 3).matmul(glb_rot[:, :5]), glb_rot[:, 5:]), dim=1) data = torch.cat((acc.flatten(1), ori.flatten(1)), dim=1) return data

Successful cases: glb_acc shape: torch.Size([5597, 6, 3]) glb_rot shape: torch.Size([5597, 6, 3, 3]) glbacc glbrot shape torch.Size([5597, 6, 3]) torch.Size([5597, 6, 3, 3]) glbacc - glbacc : tensor([[[ 0.1716, -0.0427, 0.0123], [ 0.1127, 0.0363, -0.0605], [ 0.1442, -0.0574, -0.0261], [ 0.2186, -0.0153, 0.0402], [ 0.1563, -0.0633, 0.0527]],

    [[ 0.0451,  0.0027, -0.0364],
     [ 0.0889,  0.0721,  0.0209],
     [ 0.0874,  0.0096, -0.0205],
     [ 0.1864,  0.0529,  0.0749],
     [ 0.0984,  0.0293, -0.0329]],

    [[ 0.0526, -0.0397, -0.0080],
     [ 0.0831,  0.0218, -0.0144],
     [ 0.0546, -0.0104, -0.0155],
     [ 0.2263,  0.0101, -0.0293],
     [ 0.1179,  0.0145, -0.0276]],

    ...,

    [[ 0.9482,  0.2482, -2.6191],
     [-0.9206,  0.0622, -0.3036],
     [-0.0713,  0.1019,  0.2482],
     [-0.0935,  0.0164, -0.2963],
     [-0.4723,  0.1530, -0.4527]],

    [[ 0.7363,  0.4260, -1.3949],
     [-0.7248,  0.3825, -0.2183],
     [ 0.0518, -0.0676, -0.0376],
     [-0.1492, -0.1129,  0.1147],
     [-0.4076,  0.0657, -0.4015]],

    [[ 0.1614,  0.6001, -0.5305],
     [-0.5440,  0.4468, -0.1328],
     [-0.1885, -0.1258, -0.1278],
     [ 0.0595, -0.0830,  0.4220],
     [-0.2837,  0.1068, -0.3381]]])

glbacc - glbacc shape: torch.Size([5597, 5, 3]) cat tensor([[[ 0.1716, -0.0427, 0.0123], [ 0.1127, 0.0363, -0.0605], [ 0.1442, -0.0574, -0.0261], [ 0.2186, -0.0153, 0.0402], [ 0.1563, -0.0633, 0.0527], [ -0.0466, -0.0131, -0.0218]],

    [[     0.0451,      0.0027,     -0.0364],
     [     0.0889,      0.0721,      0.0209],
     [     0.0874,      0.0096,     -0.0205],
     [     0.1864,      0.0529,      0.0749],
     [     0.0984,      0.0293,     -0.0329],
     [    -0.0028,     -0.0850,     -0.0120]],

    [[     0.0526,     -0.0397,     -0.0080],
     [     0.0831,      0.0218,     -0.0144],
     [     0.0546,     -0.0104,     -0.0155],
     [     0.2263,      0.0101,     -0.0293],
     [     0.1179,      0.0145,     -0.0276],
     [    -0.0175,     -0.0470,      0.0032]],

    ...,

    [[     0.9482,      0.2482,     -2.6191],
     [    -0.9206,      0.0622,     -0.3036],
     [    -0.0713,      0.1019,      0.2482],
     [    -0.0935,      0.0164,     -0.2963],
     [    -0.4723,      0.1530,     -0.4527],
     [     0.2319,     -0.0807,     -0.0280]],

    [[     0.7363,      0.4260,     -1.3949],
     [    -0.7248,      0.3825,     -0.2183],
     [     0.0518,     -0.0676,     -0.0376],
     [    -0.1492,     -0.1129,      0.1147],
     [    -0.4076,      0.0657,     -0.4015],
     [     0.3251,      0.1145,      0.0016]],

    [[     0.1614,      0.6001,     -0.5305],
     [    -0.5440,      0.4468,     -0.1328],
     [    -0.1885,     -0.1258,     -0.1278],
     [     0.0595,     -0.0830,      0.4220],
     [    -0.2837,      0.1068,     -0.3381],
     [     0.3010,      0.1503,     -0.0863]]])

cat shape: torch.Size([5597, 6, 3]) glb_rot: tensor([[[ 0.9999, -0.0115, 0.0024], [ 0.0115, 0.9999, 0.0090], [-0.0025, -0.0089, 1.0000]],

    [[ 0.9999, -0.0114,  0.0024],
     [ 0.0114,  0.9999,  0.0090],
     [-0.0025, -0.0090,  1.0000]],

    [[ 0.9999, -0.0114,  0.0024],
     [ 0.0114,  0.9999,  0.0092],
     [-0.0025, -0.0092,  1.0000]],

    ...,

    [[ 0.9989,  0.0246,  0.0401],
     [-0.0263,  0.9988,  0.0404],
     [-0.0391, -0.0415,  0.9984]],

    [[ 0.9988,  0.0248,  0.0412],
     [-0.0264,  0.9988,  0.0404],
     [-0.0402, -0.0414,  0.9983]],

    [[ 0.9988,  0.0244,  0.0420],
     [-0.0261,  0.9989,  0.0402],
     [-0.0409, -0.0412,  0.9983]]])

glb_rotshape torch.Size([5597, 3, 3]

Error running case: glb_acc shape: torch.Size([4000, 6, 3]) glb_rot shape: torch.Size([4000, 6, 3, 3]) glbacc glbrot shape torch.Size([4000, 6, 3]) torch.Size([4000, 6, 3, 3]) glbacc - glbacc : tensor([[[-0.8113, -1.5080, -2.9102], [ 0.3013, 2.4700, 0.4967], [ 2.5531, 1.2118, -1.6512], [ 0.8056, 0.4869, -1.0739], [-1.2351, 0.1362, -0.9225]],

    [[-0.4142, -0.7121, -2.5099],
     [ 0.6741,  1.8716,  0.1667],
     [ 3.5745, -7.2551, -0.3108],
     [ 0.8687,  0.2648, -1.4660],
     [-0.6438,  0.0224, -1.2398]],

    [[ 0.2339,  0.3039, -2.1092],
     [ 1.1377,  1.0144, -0.3018],
     [ 4.2299, -7.6808, -0.7257],
     [ 1.1987, -0.1750, -1.7501],
     [ 0.0336, -0.2857, -1.5032]],

    ...,

    [[ 0.3849, -0.1924, -0.3000],
     [-0.1186, -0.1689, -0.0822],
     [ 1.9585,  0.4444, -0.9265],
     [-0.2422,  0.0690, -0.0509],
     [-0.4442, -0.0770, -0.1350]],

    [[ 0.3890, -0.2392, -0.2715],
     [-0.1004, -0.2012, -0.0609],
     [ 1.9511,  0.4077, -0.9228],
     [-0.2956,  0.0188, -0.0341],
     [-0.4545, -0.0864, -0.1329]],

    [[ 0.4612, -0.3363, -0.2720],
     [-0.0937, -0.2433, -0.0508],
     [ 1.9237,  0.3782, -0.9084],
     [-0.3581, -0.0267, -0.0400],
     [-0.4699, -0.1043, -0.1424]]], dtype=torch.float64)

glbacc - glbacc shape: torch.Size([4000, 5, 3]) cat tensor([[[-0.8113, -1.5080, -2.9102], [ 0.3013, 2.4700, 0.4967], [ 2.5531, 1.2118, -1.6512], [ 0.8056, 0.4869, -1.0739], [-1.2351, 0.1362, -0.9225], [ 0.3097, 0.8494, 0.7879]],

    [[-0.4142, -0.7121, -2.5099],
     [ 0.6741,  1.8716,  0.1667],
     [ 3.5745, -7.2551, -0.3108],
     [ 0.8687,  0.2648, -1.4660],
     [-0.6438,  0.0224, -1.2398],
     [-0.2330,  1.0350,  1.3512]],

    [[ 0.2339,  0.3039, -2.1092],
     [ 1.1377,  1.0144, -0.3018],
     [ 4.2299, -7.6808, -0.7257],
     [ 1.1987, -0.1750, -1.7501],
     [ 0.0336, -0.2857, -1.5032],
     [-0.8781,  1.4081,  1.7327]],

    ...,

    [[ 0.3849, -0.1924, -0.3000],
     [-0.1186, -0.1689, -0.0822],
     [ 1.9585,  0.4444, -0.9265],
     [-0.2422,  0.0690, -0.0509],
     [-0.4442, -0.0770, -0.1350],
     [ 0.1767,  0.1254,  0.0382]],

    [[ 0.3890, -0.2392, -0.2715],
     [-0.1004, -0.2012, -0.0609],
     [ 1.9511,  0.4077, -0.9228],
     [-0.2956,  0.0188, -0.0341],
     [-0.4545, -0.0864, -0.1329],
     [ 0.1832,  0.1625,  0.0348]],

    [[ 0.4612, -0.3363, -0.2720],
     [-0.0937, -0.2433, -0.0508],
     [ 1.9237,  0.3782, -0.9084],
     [-0.3581, -0.0267, -0.0400],
     [-0.4699, -0.1043, -0.1424],
     [ 0.2021,  0.1941,  0.0292]]], dtype=torch.float64)

cat shape: torch.Size([4000, 6, 3]) glb_rot: tensor([[[ 0.1554, -0.1249, 0.9799], [ 0.9853, 0.0903, -0.1448], [-0.0704, 0.9881, 0.1371]],

    [[ 0.1621, -0.1242,  0.9789],
     [ 0.9840,  0.0940, -0.1510],
     [-0.0733,  0.9878,  0.1374]],

    [[ 0.1681, -0.1233,  0.9780],
     [ 0.9829,  0.0970, -0.1567],
     [-0.0756,  0.9876,  0.1375]],

    ...,

    [[ 0.6478, -0.0334,  0.7611],
     [ 0.7605,  0.0875, -0.6434],
     [-0.0451,  0.9956,  0.0821]],

    [[ 0.6478, -0.0331,  0.7611],
     [ 0.7605,  0.0871, -0.6435],
     [-0.0450,  0.9956,  0.0816]],

    [[ 0.6478, -0.0344,  0.7610],
     [ 0.7605,  0.0881, -0.6433],
     [-0.0449,  0.9955,  0.0832]]])

glb_rotshape torch.Size([4000, 3, 3]) 0%| | 0/1 [00:00<?, ?it/s] Traceback (most recent call last): File "d:\pip_package\PIP-main\evaluate.py", line 215, in evaluate(net, paths.dipimu_dir, pose_evaluator=reduced_pose_evaluator, evaluate_pose=False, evaluate_zmp=False, flush_cache=True) File "d:\pip_package\PIP-main\evaluate.py", line 148, in evaluate run_pipeline(net, data_dir, missing_ids) File "d:\pip_package\PIP-main\evaluate.py", line 120, in run_pipeline result_net = net.predict(accs[i], rots[i], init_poses[i]) File "C:\Users\godof\anaconda3\envs\pipenv\lib\site-packages\torch\autograd\grad_mode.py", line 28, in decorate_context return func(*args, **kwargs) File "d:\pip_package\PIP-main\net.py", line 99, in predict x = (normalize_and_concat(glb_acc, glb_rot), lj_init, jvel_init) File "d:\pip_package\PIP-main\utils.py", line 77, in normalize_and_concat acc = torch.cat((glb_acc[:, :5] - glb_acc[:, 5:], glb_acc[:, 5:]), dim=1).bmm(glb_rot[:, -1]) RuntimeError: expected scalar type Double but found Float

Cursky commented 3 months ago

def normalize_and_concat(glb_acc, glb_rot): glb_acc = glb_acc.view(-1, 6, 3) glb_rot = glb_rot.view(-1, 6, 3, 3) print('glbacc glbrot shape',glb_acc.shape, glb_rot.shape) print('glbacc - glbacc :',glb_acc[:, :5] - glb_acc[:, 5:]) print('glbacc - glbacc shape:',(glb_acc[:, :5] - glb_acc[:, 5:]).shape) print('cat',torch.cat((glb_acc[:, :5] - glb_acc[:, 5:], glb_acc[:, 5:]), dim=1)) print('cat shape:',torch.cat((glb_acc[:, :5] - glb_acc[:, 5:], glb_acc[:, 5:]), dim=1).shape) print('glb_rot:',glb_rot[:, -1]) print('glb_rotshape',glb_rot[:, -1].shape) acc = torch.cat((glb_acc[:, :5] - glb_acc[:, 5:], glb_acc[:, 5:]), dim=1).bmm(glb_rot[:, -1]) ori = torch.cat((glb_rot[:, 5:].transpose(2, 3).matmul(glb_rot[:, :5]), glb_rot[:, 5:]), dim=1) data = torch.cat((acc.flatten(1), ori.flatten(1)), dim=1) return data

Cursky commented 3 months ago

just: glb_acc = glb_acc.float() # 转换为float glb_rot = glb_rot.float() # 转换为float can fix this error