Skip to content

Commit 15ec5c3

Browse files
committed
Fix models_dir tless
1 parent 5150179 commit 15ec5c3

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

happypose/toolbox/datasets/bop_scene_dataset.py

+19-2
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,20 @@ class BOPDataset(SceneDataset):
185185
186186
# TODO: Document whats happening with the per-view annotations.
187187
# TODO: Remove per-view annotations, recommend using WebDataset for performance ?
188+
189+
Args:
190+
----
191+
ds_dir (Path): path to the BOP dataset directory
192+
label_format (str): format of the object label, e.g. "ycbv-{label}"
193+
split (str): split of the dataset to use, e.g. "test",
194+
load_depth (bool): when loading an observation, load also the depth image
195+
use_raw_object_id (bool): if True, object id is {label}, otherwise obj_{label} (e.g. "000021" vs "obj_000021")
196+
allow_cache (bool): _description_,
197+
per_view_annotations (bool): _description_,
198+
models_dir (str): name of the object directory in bop dataset directory (e.g. "models", "models_eval", "models_cad"...)
199+
Returns:
200+
-------
201+
List[SceneData]: _description_
188202
"""
189203

190204
def __init__(
@@ -196,9 +210,10 @@ def __init__(
196210
use_raw_object_id: bool = False,
197211
allow_cache: bool = False,
198212
per_view_annotations: bool = False,
213+
models_dir: str = "models"
199214
):
200-
self.ds_dir = ds_dir
201215
assert ds_dir.exists(), "Dataset does not exists."
216+
self.ds_dir = ds_dir
202217

203218
self.split = split
204219
self.base_dir = ds_dir / split
@@ -231,7 +246,9 @@ def __init__(
231246
load_depth=load_depth,
232247
load_segmentation=True,
233248
)
234-
models_infos = json.loads((ds_dir / "models" / "models_info.json").read_text())
249+
models_path = ds_dir / models_dir
250+
assert models_path.exists(), f"models_dir={models_dir} might not be the correct object model dir name"
251+
models_infos = json.loads((models_path / "models_info.json").read_text())
235252
self.all_labels = [f"obj_{int(obj_id):06d}" for obj_id in models_infos.keys()]
236253

237254
def _load_scene_observation(

happypose/toolbox/datasets/datasets_cfg.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def make_scene_dataset(
9191
ds = keep_bop19(ds)
9292
elif ds_name == "tless.bop19":
9393
ds_dir = BOP_DS_DIR / "tless"
94-
ds = BOPDataset(ds_dir, split="test_primesense", label_format="tless-{label}")
94+
ds = BOPDataset(ds_dir, split="test_primesense", label_format="tless-{label}", models_dir="models_cad")
9595
ds = keep_bop19(ds)
9696
elif ds_name == "tudl.bop19":
9797
ds_dir = BOP_DS_DIR / "tudl"

0 commit comments

Comments
 (0)