in src/eval.py [0:0]
def print_bone_length_acc(bone_length_acc_ratio, bone_length_acc_distance, c: Train_Config, bone_lengths):
body_acc_ratio = None
body_acc_distance = None
body_lengths = None
all_ratio = None
all_distance = None
all_lengths = None
joint_groups = get_joint_group_idx(c)
group_bone_lengths = get_empty_joint_acc_dict(c)
for group_name, joints in joint_groups.items():
for j in joints:
group_bone_lengths[group_name].append(bone_lengths[j].item())
for k in bone_length_acc_ratio.keys():
acc_ratio = torch.mean(torch.cat(bone_length_acc_ratio[k], dim=0)).item()
rmse_acc_distance = torch.sqrt(torch.mean(torch.cat(bone_length_acc_distance[k], dim=0) ** 2)).item()
mean_acc_distance = torch.mean(torch.abs(torch.cat(bone_length_acc_distance[k], dim=0))).item()
avg_bone_length = torch.mean(torch.tensor(group_bone_lengths[k])).item()
if all_ratio is None:
all_ratio = torch.cat(bone_length_acc_ratio[k], dim=0)
all_distance = torch.cat(bone_length_acc_distance[k], dim=0)
all_lengths = torch.tensor(group_bone_lengths[k])
else:
all_ratio = torch.cat([all_ratio, *bone_length_acc_ratio[k]], dim=0)
all_distance = torch.cat([all_distance, *bone_length_acc_distance[k]], dim=0)
all_lengths = torch.cat([all_lengths, torch.tensor(group_bone_lengths[k])], dim=0)
if not k.startswith("finger") and k != "thumb" and k != "wrist_local_finger":
if body_acc_ratio is None:
body_acc_ratio = torch.cat(bone_length_acc_ratio[k], dim=0)
body_acc_distance = torch.cat(bone_length_acc_distance[k], dim=0)
body_length = torch.tensor(group_bone_lengths[k])
else:
body_acc_ratio = torch.cat([body_acc_ratio, *bone_length_acc_ratio[k]], dim=0)
body_acc_distance = torch.cat([body_acc_distance, *bone_length_acc_distance[k]], dim=0)
body_length = torch.cat([body_length, torch.tensor(group_bone_lengths[k])], dim=0)
print(f"{k:<20}mean ratio: {acc_ratio:.3f} distance: {rmse_acc_distance:.4f}/{mean_acc_distance:.4f} avg length: {avg_bone_length:.4f}")
body_acc_ratio = torch.mean(body_acc_ratio).item()
rmse_body_acc_distance = torch.sqrt(torch.mean(body_acc_distance ** 2)).item()
mean_body_acc_distance = torch.mean(torch.abs(body_acc_distance)).item()
body_length = torch.mean(body_length).item()
all_acc_ratio = torch.mean(all_ratio).item()
rmse_all_acc_distance = torch.sqrt(torch.mean(all_distance ** 2)).item()
mean_all_acc_distance = torch.mean(torch.abs(all_distance)).item()
all_length = torch.mean(all_lengths).item()
print(f"{'body':<20}mean ratio: {body_acc_ratio:.3f} distance: {rmse_body_acc_distance:.4f}/{mean_body_acc_distance:.4f} avg length: {body_length:.4f}")
print(f"{'all':<20}mean ratio: {all_acc_ratio:.3f} distance: {rmse_all_acc_distance:.4f}/{mean_all_acc_distance:.4f} avg length: {all_length:.4f}")