Download scripts/generate_appendix_b.py from KCBtheone/splatatlas-core: direct link, hf CLI and curl.
- Browser
- Download file 6.36 kB
-
https://huggingface.co/datasets/KCBtheone/splatatlas-core/resolve/main/scripts/generate_appendix_b.py
- Command line
-
hf download hf://datasets/KCBtheone/splatatlas-core/scripts/generate_appendix_b.py
-
curl -L -o generate_appendix_b.py https://huggingface.co/datasets/KCBtheone/splatatlas-core/resolve/main/scripts/generate_appendix_b.py
6.36 kB
| import pandas as pd | |
| import os | |
| import json | |
| import glob | |
| # 1. 基础配置 | |
| repro_csv = "outputs/phase5a/task_vapre_splatatlas_repro.csv" | |
| output_submission = "outputs/phase5a/appendix_B_scene_inventory_submission_ready.csv" | |
| output_audit = "outputs/phase5a/appendix_B_scene_inventory_audit.csv" | |
| if not os.path.exists(repro_csv): | |
| print(f"Error: 找不到基础文件 {repro_csv}") | |
| exit(1) | |
| df_repro = pd.read_csv(repro_csv) | |
| valid_scenes = sorted(df_repro['scene'].unique().tolist()) | |
| # 2. 知识库映射字典 | |
| dataset_map = {} | |
| resolution_map = {} | |
| type_map = {} | |
| display_name_map = {} | |
| # Mip-NeRF 360 Indoor | |
| for s in ["bonsai", "counter", "kitchen", "room"]: | |
| dataset_map[s] = "Mip-NeRF 360" | |
| resolution_map[s] = "2" | |
| type_map[s] = "real-world indoor" | |
| display_name_map[s] = s.capitalize() | |
| # Mip-NeRF 360 Outdoor | |
| for s in ["bicycle", "flowers", "garden", "stump", "treehill"]: | |
| dataset_map[s] = "Mip-NeRF 360" | |
| resolution_map[s] = "4" | |
| type_map[s] = "real-world outdoor" | |
| display_name_map[s] = s.capitalize() | |
| # Tanks & Temples | |
| tnt_indoor = ["auditorium", "ballroom", "courtroom", "museum", "palace", "temple"] | |
| tnt_outdoor = ["barn", "caterpillar", "truck", "playground", "lighthouse", "train"] | |
| for s in tnt_indoor + tnt_outdoor: | |
| dataset_map[s] = "Tanks&Temples" | |
| resolution_map[s] = "2" | |
| type_map[s] = "real-world indoor" if s in tnt_indoor else "real-world outdoor" | |
| display_name_map[s] = s.capitalize() | |
| # NeRF-Synthetic | |
| for s in ["chair", "drums", "ficus", "hotdog", "lego", "materials", "mic", "ship"]: | |
| dataset_map[s] = "NeRF-Synthetic" | |
| resolution_map[s] = "1" | |
| type_map[s] = "synthetic object" | |
| display_name_map[s] = s.capitalize() | |
| # Deep Blending | |
| for s in ["playroom", "drjohnson"]: | |
| dataset_map[s] = "Deep Blending" | |
| resolution_map[s] = "1" | |
| type_map[s] = "real-world indoor" | |
| display_name_map[s] = "Playroom" if s == "playroom" else "DrJohnson" | |
| # 3. 提取引擎 | |
| inventory = [] | |
| for s in valid_scenes: | |
| ds = dataset_map.get(s, "UNKNOWN") | |
| res = resolution_map.get(s, "NEEDS_MANUAL_CHECK") | |
| stype = type_map.get(s, "UNKNOWN") | |
| dname = display_name_map.get(s, s) | |
| train_views = "NEEDS_MANUAL_CHECK" | |
| test_views = "NEEDS_MANUAL_CHECK" | |
| evidence = "inferred_from_dataset_convention" | |
| notes = "" | |
| # 尝试从 NeRF-Synthetic 目录读取 view 数量 | |
| if ds == "NeRF-Synthetic": | |
| # 考虑到可能的大小写目录名 | |
| for scene_dir in [s, s.capitalize()]: | |
| train_json = f"/root/autodl-tmp/dataset/nerf_synthetic_off/nerf_synthetic/{scene_dir}/transforms_train.json" | |
| test_json = f"/root/autodl-tmp/dataset/nerf_synthetic_off/nerf_synthetic/{scene_dir}/transforms_test.json" | |
| if os.path.exists(train_json) and os.path.exists(test_json): | |
| try: | |
| with open(train_json, 'r') as f: | |
| train_data = json.load(f) | |
| train_views = str(len(train_data['frames'])) | |
| with open(test_json, 'r') as f: | |
| test_data = json.load(f) | |
| test_views = str(len(test_data['frames'])) | |
| evidence = f"parsed_from_transforms_json" | |
| break | |
| except Exception: | |
| pass | |
| # 若未能解析,则统一归为需手工确认 | |
| inventory.append({ | |
| "SceneKey": s, | |
| "DisplayName": dname, | |
| "Dataset": ds, | |
| "TrainViews": train_views, | |
| "TestViews": test_views, | |
| "Resolution": res, | |
| "SceneType": stype, | |
| "SourceEvidence": evidence, | |
| "Notes": notes | |
| }) | |
| df_inv = pd.DataFrame(inventory) | |
| # 4. 导出表格 | |
| os.makedirs("outputs/phase5a", exist_ok=True) | |
| # 投稿版 | |
| sub_cols = ["SceneKey", "DisplayName", "Dataset", "TrainViews", "TestViews", "Resolution", "SceneType"] | |
| df_inv[sub_cols].to_csv(output_submission, index=False) | |
| # 审计版 | |
| audit_cols = ["SceneKey", "DisplayName", "Dataset", "TrainViews", "TestViews", "Resolution", "SceneType", "SourceEvidence", "Notes"] | |
| df_inv[audit_cols].to_csv(output_audit, index=False) | |
| print(f"========================================================") | |
| print(f"Submission 级表格已保存至: {output_submission}") | |
| print(f"Audit 级审计表已保存至: {output_audit}") | |
| print(f"========================================================\n") | |
| # 5. Markdown 预览 | |
| print("=== Appendix B: Scene Inventory (Preview) ===") | |
| print(df_inv[sub_cols].to_markdown(index=False)) | |
| # 6. Sanity Checks | |
| print("\n========================================================") | |
| print("SANITY CHECKS") | |
| print("========================================================") | |
| print(f"1. Scene 总数是否正好 31: {len(df_inv) == 31} ({len(df_inv)})") | |
| c2 = all(s in df_repro['scene'].unique().tolist() for s in df_inv['SceneKey']) | |
| print(f"2. SceneKey 是否和 repro CSV 完全一致: {c2}") | |
| allowed_datasets = ["Tanks&Temples", "Deep Blending", "Mip-NeRF 360", "NeRF-Synthetic"] | |
| c3 = df_inv['Dataset'].isin(allowed_datasets).all() | |
| print(f"3. Dataset 是否全部属于四类之一: {c3}") | |
| print(f"4. 四个 Dataset 的 scene count 分布:") | |
| for k, v in df_inv['Dataset'].value_counts().items(): | |
| print(f" - {k}: {v}") | |
| c5 = df_inv['Resolution'].notnull().all() and not (df_inv['Resolution'] == "NEEDS_MANUAL_CHECK").any() | |
| print(f"5. Resolution 是否全部非空且无 NEEDS_MANUAL_CHECK: {c5}") | |
| missing_train = (df_inv['TrainViews'] == "NEEDS_MANUAL_CHECK").sum() | |
| missing_test = (df_inv['TestViews'] == "NEEDS_MANUAL_CHECK").sum() | |
| print(f"6. TrainViews 缺失数量 (NEEDS_MANUAL_CHECK): {missing_train}") | |
| print(f"7. TestViews 缺失数量 (NEEDS_MANUAL_CHECK): {missing_test}") | |
| inferred_count = (df_inv['SourceEvidence'] == 'inferred_from_dataset_convention').sum() | |
| print(f"8. 字段为 inferred_from_dataset_convention 的数量: {inferred_count}") | |
| # 风险检测 | |
| capitalization_risks = ["lego", "drjohnson", "playroom"] | |
| print("\n9. 大小写风险检查 (SceneKey vs DisplayName):") | |
| for r in capitalization_risks: | |
| row = df_inv[df_inv['SceneKey'] == r] | |
| if not row.empty: | |
| print(f" - {r} -> {row.iloc[0]['DisplayName']}") | |
| print("\n10. 需要手动补全 View 数量的场景:") | |
| manual_views = df_inv[df_inv['TrainViews'] == 'NEEDS_MANUAL_CHECK']['SceneKey'].tolist() | |
| print(f" - {', '.join(manual_views)}") | |