(
self,
data_dir: str = "./data/raw/rio/rio",
save_dir: str = "./data/processed/rio",
modes: tuple = ("train", "validation", "test"),
n_jobs: int = -1,
git_repo: str = "./data/raw/rio/3RScan",
label_db: str = "configs/scannet_preprocessing/label_database.yaml",
)
| 17 | |
| 18 | class RioPreprocessing(BasePreprocessing): |
| 19 | def __init__( |
| 20 | self, |
| 21 | data_dir: str = "./data/raw/rio/rio", |
| 22 | save_dir: str = "./data/processed/rio", |
| 23 | modes: tuple = ("train", "validation", "test"), |
| 24 | n_jobs: int = -1, |
| 25 | git_repo: str = "./data/raw/rio/3RScan", |
| 26 | label_db: str = "configs/scannet_preprocessing/label_database.yaml", |
| 27 | ): |
| 28 | super().__init__(data_dir, save_dir, modes, n_jobs) |
| 29 | |
| 30 | git_repo = Path(git_repo) |
| 31 | self.files = {} |
| 32 | for mode in self.modes: |
| 33 | mode = "val" if mode == "validation" else mode |
| 34 | trainval_split_dir = git_repo / "splits" |
| 35 | with open(Path(trainval_split_dir) / (mode + ".txt")) as f: |
| 36 | # -1 because the last one is always empty |
| 37 | split_file = f.read().split("\n")[:-1] |
| 38 | |
| 39 | filepaths = [] |
| 40 | for folder in split_file: |
| 41 | filepaths.append(self.data_dir / folder / "mesh.refined.obj") |
| 42 | mode = "validation" if mode == "val" else mode |
| 43 | self.files[mode] = natsorted(filepaths) |
| 44 | |
| 45 | self.rio_to_scannet_label = {} |
| 46 | with open(git_repo / "data" / "mapping.tsv") as f: |
| 47 | reader = csv.reader(f, delimiter="\t") |
| 48 | columns = next(reader) |
| 49 | raw_category = columns.index("Label") |
| 50 | nyu40class = columns.index("NYU40 Mapping") |
| 51 | for row in reader: |
| 52 | self.rio_to_scannet_label[row[raw_category]] = row[nyu40class] |
| 53 | |
| 54 | self.label_db = self._load_yaml(Path(label_db)) |
| 55 | |
| 56 | def process_file(self, filepath, mode): |
| 57 | """process_file. |
nothing calls this directly
no test coverage detected