Skip to content

Commit bb183b8

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 15ec5c3 commit bb183b8

File tree

10 files changed

+36
-17
lines changed

10 files changed

+36
-17
lines changed

docs/book/cosypose/evaluate.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ python -m happypose.pose_estimators.cosypose.cosypose.scripts.run_full_cosypose_
1414
```
1515

1616
To evaluate on other datasets, change ["ycbv.bop19"] to e.g. ["tless.bop19"].
17-
To evaluate on a collection of datasets, change "ycbv.bop19" to e.g. ["ycbv.bop19", "lmo.bop19", "tless.bop19"].
17+
To evaluate on a collection of datasets, change "ycbv.bop19" to e.g. ["ycbv.bop19", "lmo.bop19", "tless.bop19"].

happypose/pose_estimators/cosypose/cosypose/config.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
LOCAL_DATA_DIR = Path(
2222
os.environ.get("HAPPYPOSE_DATA_DIR", Path(PROJECT_DIR) / "local_data"),
2323
)
24-
assert LOCAL_DATA_DIR.exists(), "Did you forget to set env variable 'HAPPYPOSE_DATA_DIR'?"
24+
assert (
25+
LOCAL_DATA_DIR.exists()
26+
), "Did you forget to set env variable 'HAPPYPOSE_DATA_DIR'?"
2527
TEST_DATA_DIR = LOCAL_DATA_DIR
2628
DASK_LOGS_DIR = LOCAL_DATA_DIR / "dasklogs"
2729
SYNT_DS_DIR = LOCAL_DATA_DIR / "synt_datasets"

happypose/pose_estimators/cosypose/cosypose/datasets/urdf_dataset.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def __init__(self, urdf_ds_dir):
1212
if len(urdf_paths) == 1:
1313
urdf_path = urdf_paths[0]
1414
# HACK for ycbv
15-
label = 'ycbv-'+obj_dir.name
15+
label = "ycbv-" + obj_dir.name
1616
infos = {
1717
"label": label,
1818
"urdf_path": urdf_path.as_posix(),

happypose/pose_estimators/cosypose/cosypose/evaluation/evaluation.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@
3333
from happypose.pose_estimators.megapose.evaluation.runner_utils import format_results
3434

3535
# Pose estimator
36-
from happypose.toolbox.datasets.datasets_cfg import make_object_dataset, make_scene_dataset, get_obj_ds_info
36+
from happypose.toolbox.datasets.datasets_cfg import (
37+
get_obj_ds_info,
38+
make_object_dataset,
39+
make_scene_dataset,
40+
)
3741
from happypose.toolbox.lib3d.rigid_mesh_database import MeshDataBase
3842
from happypose.toolbox.utils.distributed import get_rank, get_tmp_dir
3943
from happypose.toolbox.utils.logging import get_logger
@@ -44,13 +48,14 @@
4448

4549
logger = get_logger(__name__)
4650

51+
from happypose.pose_estimators.cosypose.cosypose.integrated.detector import Detector
4752
from happypose.pose_estimators.cosypose.cosypose.training.detector_models_cfg import (
4853
check_update_config as check_update_config_detector,
4954
)
5055
from happypose.pose_estimators.cosypose.cosypose.training.detector_models_cfg import (
5156
create_model_detector,
5257
)
53-
from happypose.pose_estimators.cosypose.cosypose.integrated.detector import Detector
58+
5459

5560
def load_detector(run_id, ds_name):
5661
run_dir = EXP_DIR / run_id
@@ -68,7 +73,9 @@ def load_detector(run_id, ds_name):
6873
return model
6974

7075

71-
def load_pose_models_cosypose(object_dataset, coarse_run_id, refiner_run_id, n_workers, renderer_type="panda3d"):
76+
def load_pose_models_cosypose(
77+
object_dataset, coarse_run_id, refiner_run_id, n_workers, renderer_type="panda3d"
78+
):
7279
run_dir = EXP_DIR / coarse_run_id
7380
cfg = yaml.load((run_dir / "config.yaml").read_text(), Loader=yaml.UnsafeLoader)
7481
cfg = check_update_config_pose(cfg)
@@ -161,7 +168,7 @@ def run_eval(
161168

162169
logger.info(f"Running eval on ds_name={cfg.ds_name} with setting={save_key}")
163170
# e.g. "ycbv.bop19" -> "ycbv"
164-
ds_name_short = cfg.ds_name.split('.')[0]
171+
ds_name_short = cfg.ds_name.split(".")[0]
165172

166173
# Load the dataset
167174
ds_kwargs = {"load_depth": False}
@@ -195,15 +202,14 @@ def run_eval(
195202
assert cfg.coarse_run_id is not None
196203
assert cfg.refiner_run_id is not None
197204

198-
199205
object_ds = make_object_dataset(ds_name_short)
200206

201207
coarse_model, refiner_model, mesh_db = load_pose_models_cosypose(
202208
object_ds,
203209
coarse_run_id=cfg.coarse_run_id,
204210
refiner_run_id=cfg.refiner_run_id,
205211
n_workers=cfg.inference.n_workers,
206-
renderer_type=cfg.inference.renderer
212+
renderer_type=cfg.inference.renderer,
207213
)
208214

209215
renderer = refiner_model.renderer

happypose/pose_estimators/cosypose/cosypose/evaluation/prediction_runner.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def run_inference_pipeline(
122122
data_TCO_init=None,
123123
n_coarse_iterations=1,
124124
n_refiner_iterations=4,
125-
detection_th=0.0
125+
detection_th=0.0,
126126
)
127127
time.time() - t
128128

happypose/pose_estimators/cosypose/cosypose/scripts/run_full_cosypose_eval_new.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
from happypose.pose_estimators.cosypose.cosypose.evaluation.evaluation import run_eval
1111

1212
# MegaPose
13-
from happypose.pose_estimators.megapose.bop_config import PBR_DETECTORS, SYNT_REAL_DETECTORS
13+
from happypose.pose_estimators.megapose.bop_config import (
14+
PBR_DETECTORS,
15+
SYNT_REAL_DETECTORS,
16+
)
1417
from happypose.pose_estimators.megapose.config import (
1518
DEBUG_RESULTS_DIR,
1619
RESULTS_DIR,

happypose/pose_estimators/megapose/config.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
LOCAL_DATA_DIR = Path(
3232
os.environ.get("HAPPYPOSE_DATA_DIR", Path(PROJECT_DIR) / "local_data"),
3333
)
34-
assert LOCAL_DATA_DIR.exists(), "Did you forget to set env variable 'HAPPYPOSE_DATA_DIR'?"
34+
assert (
35+
LOCAL_DATA_DIR.exists()
36+
), "Did you forget to set env variable 'HAPPYPOSE_DATA_DIR'?"
3537
BOP_DS_DIR = LOCAL_DATA_DIR / "bop_datasets"
3638
NB_DATA_DIR = LOCAL_DATA_DIR / "notebook_data"
3739
SHAPENET_DIR = LOCAL_DATA_DIR / "shapenetcorev2"

happypose/toolbox/datasets/bop_scene_dataset.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def __init__(
210210
use_raw_object_id: bool = False,
211211
allow_cache: bool = False,
212212
per_view_annotations: bool = False,
213-
models_dir: str = "models"
213+
models_dir: str = "models",
214214
):
215215
assert ds_dir.exists(), "Dataset does not exists."
216216
self.ds_dir = ds_dir
@@ -247,7 +247,9 @@ def __init__(
247247
load_segmentation=True,
248248
)
249249
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"
250+
assert (
251+
models_path.exists()
252+
), f"models_dir={models_dir} might not be the correct object model dir name"
251253
models_infos = json.loads((models_path / "models_info.json").read_text())
252254
self.all_labels = [f"obj_{int(obj_id):06d}" for obj_id in models_infos.keys()]
253255

happypose/toolbox/datasets/datasets_cfg.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,12 @@ 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}", models_dir="models_cad")
94+
ds = BOPDataset(
95+
ds_dir,
96+
split="test_primesense",
97+
label_format="tless-{label}",
98+
models_dir="models_cad",
99+
)
95100
ds = keep_bop19(ds)
96101
elif ds_name == "tudl.bop19":
97102
ds_dir = BOP_DS_DIR / "tudl"

happypose/toolbox/renderer/bullet_scene_renderer.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
import pybullet as pb
55

66
from happypose.pose_estimators.cosypose.cosypose.config import LOCAL_DATA_DIR
7-
87
from happypose.pose_estimators.cosypose.cosypose.datasets.urdf_dataset import (
9-
UrdfDataset,
108
OneUrdfDataset,
9+
UrdfDataset,
1110
)
1211

1312
# TODO: move urdf utilities to happypose toolbox

0 commit comments

Comments
 (0)