From cbacd8f4b0fce7473b743dbf4ae57da32e0e8121 Mon Sep 17 00:00:00 2001 From: Guilhem Saurel Date: Wed, 6 Sep 2023 14:31:03 +0200 Subject: [PATCH 1/3] silence pre-commit for now --- .pre-commit-config.yaml | 62 ++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cb0b55ea..6c0dec02 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,38 +1,38 @@ exclude: 'cosypose|megapose6d' repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 - hooks: - - id: check-added-large-files - - id: check-ast - - id: check-executables-have-shebangs - - id: check-json - - id: check-merge-conflict - - id: check-symlinks - - id: check-toml - - id: check-yaml - - id: debug-statements - - id: destroyed-symlinks - - id: detect-private-key - - id: end-of-file-fixer - - id: fix-byte-order-marker - - id: mixed-line-ending - - id: trailing-whitespace -- repo: https://github.com/PyCQA/isort - rev: 5.12.0 - hooks: - - id: isort -- repo: https://github.com/psf/black - rev: 23.3.0 - hooks: - - id: black +#- repo: https://github.com/pre-commit/pre-commit-hooks + #rev: v4.4.0 + #hooks: + #- id: check-added-large-files + #- id: check-ast + #- id: check-executables-have-shebangs + #- id: check-json + #- id: check-merge-conflict + #- id: check-symlinks + #- id: check-toml + #- id: check-yaml + #- id: debug-statements + #- id: destroyed-symlinks + #- id: detect-private-key + #- id: end-of-file-fixer + #- id: fix-byte-order-marker + #- id: mixed-line-ending + #- id: trailing-whitespace +#- repo: https://github.com/PyCQA/isort + #rev: 5.12.0 + #hooks: + #- id: isort +#- repo: https://github.com/psf/black + #rev: 23.3.0 + #hooks: + #- id: black - repo: https://github.com/pappasam/toml-sort rev: v0.23.1 hooks: - id: toml-sort-fix exclude: 'poetry.lock' -- repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.267 - hooks: - - id: ruff - args: [--fix, --exit-non-zero-on-fix] +#- repo: https://github.com/charliermarsh/ruff-pre-commit + #rev: v0.0.267 + #hooks: + #- id: ruff + #args: [--fix, --exit-non-zero-on-fix] From 5a020667655421591b0d0d81bfd024f9f1512bf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Martinez?= Date: Thu, 7 Sep 2023 14:02:04 +0200 Subject: [PATCH 2/3] few fixes, run_inference return predictions --- .../scripts/run_inference_on_example.py | 24 +++++++++++++------ .../cosypose/cosypose/simulator/base_scene.py | 2 +- .../cosypose/utils/cosypose_wrapper.py | 4 ++-- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/happypose/pose_estimators/cosypose/cosypose/scripts/run_inference_on_example.py b/happypose/pose_estimators/cosypose/cosypose/scripts/run_inference_on_example.py index 641b5be9..9654c1c1 100644 --- a/happypose/pose_estimators/cosypose/cosypose/scripts/run_inference_on_example.py +++ b/happypose/pose_estimators/cosypose/cosypose/scripts/run_inference_on_example.py @@ -169,12 +169,21 @@ def run_inference( example_dir: Path, model_name: str, dataset_to_use: str, + example_name: str, + render: bool = True, ) -> None: - observation = load_observation_tensor(example_dir) - CosyPose = CosyPoseWrapper(dataset_name=dataset_to_use, n_workers=8) - predictions = CosyPose.inference(observation) - renderings = rendering(predictions, example_dir) - save_predictions(example_dir, renderings) + try: + observation = load_observation_tensor(example_dir) + CosyPose = CosyPoseWrapper(dataset_name=dataset_to_use, n_workers=8) + predictions = CosyPose.inference(observation) + if render: + renderings = rendering(predictions, example_dir, example_name) + save_predictions(example_dir, renderings) + + return predictions.poses, predictions.infos + except AttributeError as err: + print("found nothing") + return [],[] if __name__ == "__main__": @@ -182,10 +191,11 @@ def run_inference( parser = argparse.ArgumentParser() parser.add_argument("example_name") parser.add_argument("--model", type=str, default="megapose-1.0-RGB-multi-hypothesis") - parser.add_argument("--dataset", type=str, default="ycbv") + parser.add_argument("--dataset", type=str, default="tless") #parser.add_argument("--vis-detections", action="store_true") parser.add_argument("--run-inference", action="store_true", default=True) #parser.add_argument("--vis-outputs", action="store_true") + parser.add_argument("--render", action="store_true", default=False) args = parser.parse_args() data_dir = os.getenv("MEGAPOSE_DATA_DIR") @@ -197,7 +207,7 @@ def run_inference( # make_detections_visualization(example_dir) if args.run_inference: - run_inference(example_dir, args.model, dataset_to_use) + run_inference(example_dir, args.model, dataset_to_use, args.example_name, args.render) #if args.vis_outputs: # make_output_visualization(example_dir) \ No newline at end of file diff --git a/happypose/pose_estimators/cosypose/cosypose/simulator/base_scene.py b/happypose/pose_estimators/cosypose/cosypose/simulator/base_scene.py index c77f0df8..a91f35a8 100644 --- a/happypose/pose_estimators/cosypose/cosypose/simulator/base_scene.py +++ b/happypose/pose_estimators/cosypose/cosypose/simulator/base_scene.py @@ -12,7 +12,7 @@ class BaseScene: _connected = False _simulation_step = 1/240. - def connect(self, gpu_renderer=True, gui=False): + def connect(self, gpu_renderer=False, gui=False): assert not self._connected, 'Already connected' if gui: self._client_id = pb.connect(pb.GUI, '--width=640 --height=480') diff --git a/happypose/pose_estimators/cosypose/cosypose/utils/cosypose_wrapper.py b/happypose/pose_estimators/cosypose/cosypose/utils/cosypose_wrapper.py index e4db0285..434dd140 100644 --- a/happypose/pose_estimators/cosypose/cosypose/utils/cosypose_wrapper.py +++ b/happypose/pose_estimators/cosypose/cosypose/utils/cosypose_wrapper.py @@ -110,7 +110,7 @@ def load_pose_models(coarse_run_id, refiner_run_id, n_workers): #renderer = BulletBatchRenderer(object_set=cfg.urdf_ds_name, n_workers=n_workers, gpu_renderer=gpu_renderer) # - object_dataset = make_object_dataset("ycbv") + object_dataset = make_object_dataset("tless.cad") mesh_db = MeshDataBase.from_object_ds(object_dataset) renderer = Panda3dBatchRenderer(object_dataset, n_workers=n_workers, preload_cache=False) mesh_db_batched = mesh_db.batched().to(device) @@ -189,4 +189,4 @@ def inference(self, observation, coarse_guess=None): n_coarse_iterations=0, n_refiner_iterations=4) print("inference successfully.") # result: this_batch_detections, final_preds - return final_preds.cpu() \ No newline at end of file + return final_preds.cpu() From 50375973f824ed273d3dc3c1a07d6ddcec8f9cdc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 7 Sep 2023 12:02:44 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../pose_estimators/megapose/pyproject.toml | 37 ++++++++----------- pyproject.toml | 8 ++-- 2 files changed, 19 insertions(+), 26 deletions(-) diff --git a/happypose/pose_estimators/megapose/pyproject.toml b/happypose/pose_estimators/megapose/pyproject.toml index a0278d2e..6c7aba42 100644 --- a/happypose/pose_estimators/megapose/pyproject.toml +++ b/happypose/pose_estimators/megapose/pyproject.toml @@ -27,12 +27,12 @@ requires = ["setuptools>=45", "wheel"] extend-exclude = "deprecated|.ipynb|deps|local_data" line-length = 100 -# See the `setuptools_scm` documentation for the description of the schemes used below. -# https://pypi.org/project/setuptools-scm/ -# NOTE: If these values are updated, they need to be also updated in `srl/__init__.py`. -# [tool.setuptools_scm] -# local_scheme = "dirty-tag" -# version_scheme = "no-guess-dev" +[tool.coverage.report] +# NOTE: Single-quoted strings are required in TOML for regular expressions +exclude_lines = [ + "pragma: no cover", # Need to re-enable the standard no cover match + '^\s*pass\s*$' # Skip any pass lines +] [tool.isort] # Multi line output mode 3 is used to conform with Black. See @@ -44,27 +44,16 @@ import_heading_thirdparty = "Third Party" known_first_party = ['megapose'] multi_line_output = 3 profile = "black" -skip = ['local_data', 'build', 'deps'] - -[tool.pytest.ini_options] -norecursedirs = [".git", ".venv", "deprecated", "dist"] -python_files = ["*_test.py"] - -[tool.coverage.report] -# NOTE: Single-quoted strings are required in TOML for regular expressions -exclude_lines = [ - "pragma: no cover", # Need to re-enable the standard no cover match - '^\s*pass\s*$', # Skip any pass lines -] +skip = ['build', 'deps', 'local_data'] [tool.mypy] disallow_untyped_defs = true exclude = [ - "venv", - "local_data", + "deprecated/", "deps/", + "local_data", "slurm/", - "deprecated/", + "venv" ] no_implicit_optional = true show_error_codes = true @@ -75,5 +64,9 @@ ignore_missing_imports = true module = [ "importlib.metadata", "setuptools", - "setuptools_scm", + "setuptools_scm" ] + +[tool.pytest.ini_options] +norecursedirs = [".git", ".venv", "deprecated", "dist"] +python_files = ["*_test.py"] diff --git a/pyproject.toml b/pyproject.toml index 492251af..be802ed3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,8 +26,9 @@ version = "0.1.0" [tool.poetry.dependencies] addict = "^2.4.0" bokeh = "^3.1.1" -#bop-toolkit-lib = {path = "bop_toolkit"} +# bop-toolkit-lib = {path = "bop_toolkit"} imageio = "^2.31.1" +ipython = "^8.12.0" joblib = "^1.2.0" omegaconf = "^2.3.0" # cosypose = {path = "happypose/pose_estimators/cosypose"} TODO: pep517 @@ -36,6 +37,7 @@ opencv-contrib-python = "^4.7.0.72" opencv-python = "^4.7.0.72" panda3d = "=1.10.13" pin = "^2.6.17" +pybind11 = "^2.10.4" pybullet = "^3.2.5" pypng = "^0.20220715.0" python = ">=3.8,<3.11" @@ -45,6 +47,7 @@ scikit-image = "^0.21.0" scikit-learn = "^1.2.2" scipy = "^1.10.1" seaborn = "^0.12.2" +selenium = "^4.10.0" simplejson = "^3.19.1" torch = {source = "cpu", version = "<2"} torchvision = {source = "cpu", version = "<0.15.2"} @@ -53,9 +56,6 @@ transforms3d = "^0.4.1" trimesh = "^3.22.1" webdataset = "^0.2.48" wget = "^3.2" -selenium = "^4.10.0" -ipython = "^8.12.0" -pybind11 = "^2.10.4" [tool.poetry.group.dev] optional = true