vr-hmr / debug_tensors.py
zirobtc's picture
Upload folder using huggingface_hub
7e120dd
import torch
import numpy as np
from pathlib import Path
import sys
# Add Genmo to Path
repo_root = str(Path(__file__).resolve().parents[0])
if repo_root not in sys.path:
sys.path.insert(0, repo_root)
ROOT = "./processed_dataset"
pt_files = sorted(list(Path(ROOT).glob("genmo_features/*.pt")))
def debug_print():
if len(pt_files) == 0:
return
file_path = pt_files[0]
data = torch.load(file_path, map_location="cpu")
print("----- CONFIGURATION DUMP -----")
print(f"Data Keys: {data.keys()}")
T_w2c = data["T_w2c"]
tr_w = data["smpl_params_w"]["transl"]
tr_c = data["smpl_params_c"]["transl"]
go_w = data["smpl_params_w"]["global_orient"]
go_c = data["smpl_params_c"]["global_orient"]
world_offset = data.get("world_offset", None)
print(f"World Offset Applied: {world_offset}")
# Check Kabsch Error manually
from third_party.GVHMR.hmr4d.utils.smplx_utils import make_smplx
from scipy.spatial.transform import Rotation as R
smplx = make_smplx("supermotion").eval().cpu()
print(f"\nT_w2c Shape: {T_w2c.shape}")
print(f"T_w2c Frame 0:\n{T_w2c[0]}")
# Calculate global SMPL from T_w2c ^ -1 @ incam:
inv_T = torch.inverse(T_w2c[0])
tr_c_homo = torch.cat([tr_c[0], torch.tensor([1.0])])
expected_tr_w = (inv_T @ tr_c_homo)[:3]
print(f"tr_w = {tr_w[0]}")
print(f"Expecttr_w = {expected_tr_w}")
if __name__ == "__main__":
debug_print()