Download read_pt.py from Tinghong-Ye22/script: direct link, hf CLI and curl.
- Browser
- Download file 1.43 kB
-
https://huggingface.co/Tinghong-Ye22/script/resolve/main/read_pt.py
- Command line
-
hf download hf://Tinghong-Ye22/script/read_pt.py
-
curl -L -o read_pt.py https://huggingface.co/Tinghong-Ye22/script/resolve/main/read_pt.py
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) |