script / read_pt.py
Tinghong-Ye22's picture
Add files using upload-large-folder tool
734d13f verified
Raw History Blame Contribute Delete
1.43 kB
import torch
# 1. 你的文件路径
file_path = "/cpfs01/videogen/gvhmr_smpl/part_10/--9DvmkocUk_00010_44_171/hmr4d_results.pt"
# 2. 加载数据
data = torch.load(file_path)
# 3. 指定要检查的四个 key
keys_to_check = ['smpl_params_global', 'smpl_params_incam', 'K_fullimg', 'net_outputs']
print(f"正在检查文件结构...")
print("=" * 50)
# 4. 开始遍历检查
for key in keys_to_check:
if key not in data:
print(f"❌ 找不到: {key}")
continue
val = data[key]
# 情况 A:直接是张量 (例如 K_fullimg)
if isinstance(val, torch.Tensor):
print(f"✅ 【{key}】 (直接是张量) \n └── 形状: {val.shape}")
# 情况 B:是嵌套字典 (例如 smpl_params_global, net_outputs)
elif isinstance(val, dict):
print(f"📦 【{key}】 (嵌套字典) 里面包含:")
for sub_k, sub_v in val.items():
if isinstance(sub_v, torch.Tensor):
print(f" ├── {sub_k}: {sub_v.shape}")
elif isinstance(sub_v, dict):
print(f" ├── {sub_k}: [又是一个字典] 包含 keys -> {list(sub_v.keys())}")
else:
print(f" ├── {sub_k}: [其他类型] {type(sub_v)}")
# 情况 C:其他未知类型
else:
print(f"❓ 【{key}】 (其他类型: {type(val)})")
print("-" * 50)