| import os |
| import shutil |
| from pathlib import Path |
| import subprocess |
|
|
|
|
| |
| scene_path = Path("/data/SamVGGT/datasets/processed_scannet_eval/scene0707_00") |
|
|
| scene_id = scene_path.name |
|
|
|
|
|
|
| |
| gt_seg_dir = scene_path / "gt_seg" |
| gt_pose_dir = scene_path / "gt_cam" |
| gt_depth_dir = scene_path / "gt_depth" |
| gt_seg_dir.mkdir(exist_ok=True) |
| gt_pose_dir.mkdir(exist_ok=True) |
| gt_depth_dir.mkdir(exist_ok=True) |
|
|
| |
| image_dir = scene_path / "images" |
| image_files = [f for f in image_dir.iterdir() if f.suffix == ".jpg"] |
| target_image_files = [f"{int(f.stem)}.png" for f in image_files] |
|
|
| script_path = 'datasets/processed_scannet/convert_scannet_label_image.py' |
|
|
| input_dir = f'datasets/processed_scannet/scans_test/{scene_id}/label-filt' |
| output_dir = f'datasets/processed_scannet_eval//{scene_id}/gt_seg' |
| label_map_file = '/data/SamVGGT/datasets/processed_scannet/scannetv2-labels.combined.tsv' |
|
|
| |
| os.makedirs(output_dir, exist_ok=True) |
|
|
| cmd = [ |
| 'python', |
| script_path, |
| '--input_file', input_dir, |
| '--label_map_file', label_map_file, |
| '--output_file', output_dir, |
| '--target_images' |
| ] + target_image_files |
|
|
| print(f'Running: {" ".join(cmd)}') |
| subprocess.run(cmd, check=True) |
|
|
| for img_path in image_files: |
| prefix = img_path.stem |
|
|
| |
| semantic_base = Path("/data/SamVGGT/datasets/processed_scannet/scans_test") / scene_id / "label-filt" |
| lable_file = semantic_base / f"{int(prefix)}.png" |
|
|
|
|
| |
| depth_file = Path("/data/SamVGGT/datasets/processed_scannet/scans_test") / scene_id / "depth" / f"{prefix}.png" |
| if depth_file.exists(): |
| shutil.copy2(str(depth_file), gt_depth_dir / depth_file.name) |
| else: |
| print(f"[缺失] {depth_file}") |
|
|
| |
| pose_file = Path("/data/SamVGGT/datasets/processed_scannet/scans_test") / scene_id / "cam" / f"{prefix}.npz" |
| if pose_file.exists(): |
| shutil.copy2(str(pose_file), gt_pose_dir / pose_file.name) |
| else: |
| print(f"[缺失] {pose_file}") |
|
|
| print(f"Completed scene_id: {scene_id}") |