Delete HouseLayout3D.py
Browse files- HouseLayout3D.py +0 -87
HouseLayout3D.py
DELETED
|
@@ -1,87 +0,0 @@
|
|
| 1 |
-
import datasets
|
| 2 |
-
import os
|
| 3 |
-
import json
|
| 4 |
-
import glob
|
| 5 |
-
from typing import Dict, Any, Generator, Tuple
|
| 6 |
-
|
| 7 |
-
class HouseLayout3D(datasets.GeneratorBasedBuilder):
|
| 8 |
-
"""The HouseLayout3D Dataset: 3D house layouts with structured annotations."""
|
| 9 |
-
|
| 10 |
-
# 1. DEFINE DATASET CONFIGURATIONS (e.g., splits, versions)
|
| 11 |
-
VERSION = datasets.Version("1.0.0")
|
| 12 |
-
|
| 13 |
-
BUILDER_CONFIGS = [
|
| 14 |
-
datasets.BuilderConfig(
|
| 15 |
-
name="default",
|
| 16 |
-
version=VERSION,
|
| 17 |
-
description="Default configuration for the entire dataset.",
|
| 18 |
-
),
|
| 19 |
-
]
|
| 20 |
-
|
| 21 |
-
# 2. DEFINE THE OUTPUT SCHEMA
|
| 22 |
-
def _info(self) -> datasets.DatasetInfo:
|
| 23 |
-
return datasets.DatasetInfo(
|
| 24 |
-
description=self.VERSION.description,
|
| 25 |
-
features=datasets.Features({
|
| 26 |
-
"scene_id": datasets.Value("string"),
|
| 27 |
-
"structure_obj_path": datasets.Value("string"),
|
| 28 |
-
"poses_json_path": datasets.Value("string"),
|
| 29 |
-
"doors": datasets.Sequence(datasets.Sequence(datasets.Value("float"))),
|
| 30 |
-
"windows": datasets.Sequence(datasets.Sequence(datasets.Value("float"))),
|
| 31 |
-
"stairs_ply_paths": datasets.Sequence(datasets.Value("string")),
|
| 32 |
-
}),
|
| 33 |
-
homepage="https://houselayout3d.github.io/",
|
| 34 |
-
license="MIT license",
|
| 35 |
-
)
|
| 36 |
-
|
| 37 |
-
# 3. LOCATE AND ORGANIZE DATA FILES INTO SPLITS (e.g., train, test)
|
| 38 |
-
def _split_generators(self, dl_manager: datasets.DownloadManager) -> list[datasets.SplitGenerator]:
|
| 39 |
-
data_dir = dl_manager.download_and_extract(self.config.data_dir or "./")
|
| 40 |
-
|
| 41 |
-
split_paths = {
|
| 42 |
-
datasets.Split.TRAIN: os.path.join(data_dir, "splits", "train.txt"),
|
| 43 |
-
datasets.Split.TEST: os.path.join(data_dir, "splits", "test.txt"),
|
| 44 |
-
}
|
| 45 |
-
|
| 46 |
-
return [
|
| 47 |
-
datasets.SplitGenerator(
|
| 48 |
-
name=split_name,
|
| 49 |
-
gen_kwargs={"filepaths": split_path, "data_dir": data_dir},
|
| 50 |
-
)
|
| 51 |
-
for split_name, split_path in split_paths.items() if os.path.exists(split_path)
|
| 52 |
-
]
|
| 53 |
-
|
| 54 |
-
# 4. PARSE THE DATA FILES AND YIELD EXAMPLES
|
| 55 |
-
def _generate_examples(self, filepaths: str, data_dir: str) -> Generator[Tuple[int, Dict[str, Any]], None, None]:
|
| 56 |
-
with open(filepaths, 'r') as f:
|
| 57 |
-
scene_ids = [line.strip() for line in f if line.strip()]
|
| 58 |
-
|
| 59 |
-
for id_, scene_id in enumerate(scene_ids):
|
| 60 |
-
try:
|
| 61 |
-
base_path = os.path.join(data_dir, scene_id)
|
| 62 |
-
structure_obj_path = os.path.join(data_dir, "structures", f"{scene_id}.obj")
|
| 63 |
-
doors_json_path = os.path.join(data_dir, "doors", f"{scene_id}.json")
|
| 64 |
-
windows_json_path = os.path.join(data_dir, "windows", f"{scene_id}.json")
|
| 65 |
-
poses_json_path = os.path.join(data_dir, "poses", f"{scene_id}.json")
|
| 66 |
-
stairs_ply_paths = glob.glob(os.path.join(data_dir, "stairs", scene_id, "*.ply"))
|
| 67 |
-
|
| 68 |
-
with open(doors_json_path, 'r') as f:
|
| 69 |
-
door_data = json.load(f)
|
| 70 |
-
with open(windows_json_path, 'r') as f:
|
| 71 |
-
window_data = json.load(f)
|
| 72 |
-
|
| 73 |
-
doors_corners = [door["corners"] for door in door_data.get("doors", [])]
|
| 74 |
-
windows_corners = [window["corners"] for window in window_data.get("windows", [])]
|
| 75 |
-
|
| 76 |
-
yield id_, {
|
| 77 |
-
"scene_id": scene_id,
|
| 78 |
-
"structure_obj_path": str(structure_obj_path),
|
| 79 |
-
"poses_json_path": str(poses_json_path),
|
| 80 |
-
"doors": doors_corners,
|
| 81 |
-
"windows": windows_corners,
|
| 82 |
-
"stairs_ply_paths": [str(p) for p in stairs_ply_paths],
|
| 83 |
-
}
|
| 84 |
-
|
| 85 |
-
except Exception as e:
|
| 86 |
-
print(f"Skipping scene {scene_id} due to error: {e}")
|
| 87 |
-
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|