Skip to content

Commit

Permalink
Merge pull request #59 from TheoMF/pack
Browse files Browse the repository at this point in the history
run_inference return predictions
  • Loading branch information
nim65s authored Sep 7, 2023
2 parents 4eeb210 + 5037597 commit 27471bd
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 67 deletions.
62 changes: 31 additions & 31 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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]
Original file line number Diff line number Diff line change
Expand Up @@ -169,23 +169,33 @@ 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__":
set_logging_level("info")
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")
Expand All @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
return final_preds.cpu()
37 changes: 15 additions & 22 deletions happypose/pose_estimators/megapose/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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"]
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -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"}
Expand All @@ -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
Expand Down

0 comments on commit 27471bd

Please sign in to comment.