From e6a8e994dc4d5189db064de518ea0adcfd34eda7 Mon Sep 17 00:00:00 2001 From: MedericFourmy Date: Mon, 14 Oct 2024 15:24:25 +0000 Subject: [PATCH 1/5] add choice between model_type pbr and synth+real --- happypose_examples/config/cosypose_params.yaml | 6 +++--- .../config/cosypose_params_multiview.yaml | 6 +++--- happypose_examples/launch/common.launch.py | 7 ++++++- .../launch/multi_view_demo.launch.py | 8 +++++++- .../launch/single_view_demo.launch.py | 8 +++++++- .../happypose_ros/happypose_ros_parameters.yaml | 14 ++++++++------ happypose_ros/happypose_ros/inference_pipeline.py | 1 + happypose_ros/test/test_initialization_params.py | 14 +++++++++----- happypose_ros/test/test_multi_view.yaml | 1 + happypose_ros/test/test_single_view.yaml | 1 + 10 files changed, 46 insertions(+), 20 deletions(-) diff --git a/happypose_examples/config/cosypose_params.yaml b/happypose_examples/config/cosypose_params.yaml index 1c6777f..b4015ae 100644 --- a/happypose_examples/config/cosypose_params.yaml +++ b/happypose_examples/config/cosypose_params.yaml @@ -9,16 +9,16 @@ # Specifies which pose estimator to use in the pipeline pose_estimator_type: "cosypose" cosypose: - # Name of a dataset used during training + # Name of BOP dataset, used to load specific weights and object models dataset_name: $(var dataset_name) + # What type of NN model to use, type of training data used, 'pbr'|'synth+real' + model_type: $(var model_type) # Object renderer parameters renderer: # Specifies which renderer to use in the pipeline renderer_type: "panda3d" # Number of CPU cores to use during rendering n_workers: 8 - # Render objects on a GPU - gpu_renderer: false # Parameters expected on the runtime inference: # 2D image detection parameters diff --git a/happypose_examples/config/cosypose_params_multiview.yaml b/happypose_examples/config/cosypose_params_multiview.yaml index af1bf25..ff24b0e 100644 --- a/happypose_examples/config/cosypose_params_multiview.yaml +++ b/happypose_examples/config/cosypose_params_multiview.yaml @@ -15,16 +15,16 @@ # Specifies which pose estimator to use in the pipeline pose_estimator_type: "cosypose" cosypose: - # Name of a dataset used during training + # Name of BOP dataset, used to load specific weights and object models dataset_name: $(var dataset_name) + # What type of NN model to use, type of training data used, 'pbr'|'synth+real' + model_type: $(var model_type) # Object renderer parameters renderer: # Specifies which renderer to use in the pipeline renderer_type: "panda3d" # Number of CPU cores to use during rendering n_workers: 8 - # Render objects on a GPU - gpu_renderer: false # Parameters expected on the runtime inference: # 2D image detection parameters diff --git a/happypose_examples/launch/common.launch.py b/happypose_examples/launch/common.launch.py index 3bc9bb2..d1c7f4a 100644 --- a/happypose_examples/launch/common.launch.py +++ b/happypose_examples/launch/common.launch.py @@ -68,7 +68,12 @@ def generate_launch_description(): DeclareLaunchArgument( "dataset_name", default_value="ycbv", - description="Which dataset to use for inference.", + description="Name of BOP dataset, used to load specific weights and object models.", + ), + DeclareLaunchArgument( + "model_type", + default_value="pbr", + description="What type of NN model to use, type of training data used, 'pbr'|'synth+real'.", ), DeclareLaunchArgument( "device", diff --git a/happypose_examples/launch/multi_view_demo.launch.py b/happypose_examples/launch/multi_view_demo.launch.py index c990650..3850014 100644 --- a/happypose_examples/launch/multi_view_demo.launch.py +++ b/happypose_examples/launch/multi_view_demo.launch.py @@ -82,6 +82,7 @@ def launch_setup( ), launch_arguments={ "dataset_name": LaunchConfiguration("dataset_name"), + "model_type": LaunchConfiguration("model_type"), "device": LaunchConfiguration("device"), "use_rviz": LaunchConfiguration("use_rviz"), "rviz_config_path": rviz_config_path, @@ -97,7 +98,12 @@ def generate_launch_description(): DeclareLaunchArgument( "dataset_name", default_value="ycbv", - description="Which dataset to use for inference.", + description="Name of BOP dataset, used to load specific weights and object models.", + ), + DeclareLaunchArgument( + "model_type", + default_value="pbr", + description="What type of NN model to use, type of training data used, 'pbr'|'synth+real'.", ), DeclareLaunchArgument( "device", diff --git a/happypose_examples/launch/single_view_demo.launch.py b/happypose_examples/launch/single_view_demo.launch.py index 81059bc..3f80e47 100644 --- a/happypose_examples/launch/single_view_demo.launch.py +++ b/happypose_examples/launch/single_view_demo.launch.py @@ -59,6 +59,7 @@ def launch_setup( ), launch_arguments={ "dataset_name": LaunchConfiguration("dataset_name"), + "model_type": LaunchConfiguration("model_type"), "device": LaunchConfiguration("device"), "use_rviz": LaunchConfiguration("use_rviz"), }.items(), @@ -72,7 +73,12 @@ def generate_launch_description(): DeclareLaunchArgument( "dataset_name", default_value="ycbv", - description="Which dataset to use for inference.", + description="Name of BOP dataset, used to load specific weights and object models.", + ), + DeclareLaunchArgument( + "model_type", + default_value="pbr", + description="What type of NN model to use, type of training data used, 'pbr'|'synth+real'.", ), DeclareLaunchArgument( "device", diff --git a/happypose_ros/happypose_ros/happypose_ros_parameters.yaml b/happypose_ros/happypose_ros/happypose_ros_parameters.yaml index d93ba60..f4edd12 100644 --- a/happypose_ros/happypose_ros/happypose_ros_parameters.yaml +++ b/happypose_ros/happypose_ros/happypose_ros_parameters.yaml @@ -44,10 +44,17 @@ happypose_ros: dataset_name: type: string default_value: "" - description: "Name of a dataset used during training." + description: "Name of BOP dataset, used to load specific weights and object models." validation: one_of<>: [["hope", "tless", "ycbv"]] read_only: true + model_type: + type: string + default_value: "pbr" + description: "What type of NN model to use, type of training data used, 'pbr'|'synth+real' " + validation: + one_of<>: [["pbr", "synth+real"]] + read_only: true renderer: renderer_type: type: string @@ -63,11 +70,6 @@ happypose_ros: validation: gt_eq<>: 1 read_only: true - gpu_renderer: - type: bool - default_value: true - description: "Render objects on a GPU." - read_only: true inference: detector: detection_th: diff --git a/happypose_ros/happypose_ros/inference_pipeline.py b/happypose_ros/happypose_ros/inference_pipeline.py index 8098ee6..b9699cf 100644 --- a/happypose_ros/happypose_ros/inference_pipeline.py +++ b/happypose_ros/happypose_ros/inference_pipeline.py @@ -39,6 +39,7 @@ def __init__(self, params: dict) -> None: # Currently only cosypose is supported self._wrapper = CosyPoseWrapper( dataset_name=self._params["cosypose"]["dataset_name"], + model_type=self._params["cosypose"]["model_type"], **self._params["cosypose"]["renderer"], ) diff --git a/happypose_ros/test/test_initialization_params.py b/happypose_ros/test/test_initialization_params.py index de90a9f..fedd5c9 100644 --- a/happypose_ros/test/test_initialization_params.py +++ b/happypose_ros/test/test_initialization_params.py @@ -38,7 +38,7 @@ def happypose_params(request: pytest.FixtureRequest) -> dict: @pytest.fixture() -def minial_overwrites() -> List[Parameter]: +def minimal_overwrites() -> List[Parameter]: """Crete set minimal set of ROS parameters needed for the ROS node to start correctly. :return: Default, minimal parameters for the ROS node to start. @@ -46,6 +46,7 @@ def minial_overwrites() -> List[Parameter]: """ return [ Parameter("cosypose.dataset_name", Parameter.Type.STRING, "ycbv"), + Parameter("cosypose.model_type", Parameter.Type.STRING, "pbr"), Parameter("camera_names", Parameter.Type.STRING_ARRAY, ["cam_1"]), Parameter("cameras.cam_1.leading", Parameter.Type.BOOL, True), Parameter("cameras.cam_1.publish_tf", Parameter.Type.BOOL, False), @@ -58,6 +59,7 @@ def test_no_leading(happypose_params: dict) -> None: **happypose_params, parameter_overrides=[ Parameter("cosypose.dataset_name", Parameter.Type.STRING, "ycbv"), + Parameter("cosypose.model_type", Parameter.Type.STRING, "pbr"), Parameter( "camera_names", Parameter.Type.STRING_ARRAY, ["cam_1", "cam_2"] ), @@ -69,11 +71,11 @@ def test_no_leading(happypose_params: dict) -> None: @mock.patch("multiprocessing.context.SpawnContext.Process") -def test_minimal(happypose_params: dict, minial_overwrites: List[Parameter]) -> None: +def test_minimal(happypose_params: dict, minimal_overwrites: List[Parameter]) -> None: # Check if node starts correctly with minimal number of required parameters happypose_node = HappyPoseNode( **happypose_params, - parameter_overrides=minial_overwrites, + parameter_overrides=minimal_overwrites, ) happypose_node.destroy_node() @@ -84,6 +86,7 @@ def test_multiple_leading(happypose_params: dict) -> None: **happypose_params, parameter_overrides=[ Parameter("cosypose.dataset_name", Parameter.Type.STRING, "ycbv"), + Parameter("cosypose.model_type", Parameter.Type.STRING, "pbr"), Parameter( "camera_names", Parameter.Type.STRING_ARRAY, ["cam_1", "cam_2"] ), @@ -103,6 +106,7 @@ def test_leading_publish_tf(happypose_params: dict) -> None: **happypose_params, parameter_overrides=[ Parameter("cosypose.dataset_name", Parameter.Type.STRING, "ycbv"), + Parameter("cosypose.model_type", Parameter.Type.STRING, "synth+real"), Parameter("camera_names", Parameter.Type.STRING_ARRAY, ["cam_1"]), Parameter("cameras.cam_1.leading", Parameter.Type.BOOL, True), Parameter("cameras.cam_1.publish_tf", Parameter.Type.BOOL, True), @@ -114,13 +118,13 @@ def test_leading_publish_tf(happypose_params: dict) -> None: def test_device_unknown( - happypose_params: dict, minial_overwrites: List[Parameter] + happypose_params: dict, minimal_overwrites: List[Parameter] ) -> None: with pytest.raises(ParameterException) as excinfo: HappyPoseNode( **happypose_params, parameter_overrides=[ - *minial_overwrites, + *minimal_overwrites, # CUDA -1 is an invalid device Parameter("device", Parameter.Type.STRING, "cuda:-1"), ], diff --git a/happypose_ros/test/test_multi_view.yaml b/happypose_ros/test/test_multi_view.yaml index 0e343a7..e18c000 100644 --- a/happypose_ros/test/test_multi_view.yaml +++ b/happypose_ros/test/test_multi_view.yaml @@ -4,6 +4,7 @@ pose_estimator_type: "cosypose" cosypose: dataset_name: "ycbv" + model_type: "pbr" # reduce memory footprint during tests by reducing number of workers renderer: n_workers: 1 diff --git a/happypose_ros/test/test_single_view.yaml b/happypose_ros/test/test_single_view.yaml index ab5dbf7..e8c2092 100644 --- a/happypose_ros/test/test_single_view.yaml +++ b/happypose_ros/test/test_single_view.yaml @@ -6,6 +6,7 @@ visualization.publish_markers: true cosypose: dataset_name: "ycbv" + model_type: "pbr" # reduce memory footprint during tests by reducing number of workers renderer: n_workers: 1 From 35d8315a8de339e89d0b591355bc7b6ee15fda0a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 14 Oct 2024 15:32:23 +0000 Subject: [PATCH 2/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- happypose_examples/config/cosypose_params.yaml | 2 +- happypose_examples/config/cosypose_params_multiview.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/happypose_examples/config/cosypose_params.yaml b/happypose_examples/config/cosypose_params.yaml index b4015ae..471fa18 100644 --- a/happypose_examples/config/cosypose_params.yaml +++ b/happypose_examples/config/cosypose_params.yaml @@ -11,7 +11,7 @@ cosypose: # Name of BOP dataset, used to load specific weights and object models dataset_name: $(var dataset_name) - # What type of NN model to use, type of training data used, 'pbr'|'synth+real' + # What type of NN model to use, type of training data used, 'pbr'|'synth+real' model_type: $(var model_type) # Object renderer parameters renderer: diff --git a/happypose_examples/config/cosypose_params_multiview.yaml b/happypose_examples/config/cosypose_params_multiview.yaml index ff24b0e..f7595c0 100644 --- a/happypose_examples/config/cosypose_params_multiview.yaml +++ b/happypose_examples/config/cosypose_params_multiview.yaml @@ -17,7 +17,7 @@ cosypose: # Name of BOP dataset, used to load specific weights and object models dataset_name: $(var dataset_name) - # What type of NN model to use, type of training data used, 'pbr'|'synth+real' + # What type of NN model to use, type of training data used, 'pbr'|'synth+real' model_type: $(var model_type) # Object renderer parameters renderer: From 3f7ffaf3c75f3ce4d6eb244c15db73ceb803ea2b Mon Sep 17 00:00:00 2001 From: Mederic Fourmy Date: Wed, 16 Oct 2024 13:06:58 +0200 Subject: [PATCH 3/5] Update happypose_ros/happypose_ros/happypose_ros_parameters.yaml Co-authored-by: Krzysztof Wojciechowski <49921081+Kotochleb@users.noreply.github.com> --- happypose_ros/happypose_ros/happypose_ros_parameters.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/happypose_ros/happypose_ros/happypose_ros_parameters.yaml b/happypose_ros/happypose_ros/happypose_ros_parameters.yaml index f4edd12..ef0a755 100644 --- a/happypose_ros/happypose_ros/happypose_ros_parameters.yaml +++ b/happypose_ros/happypose_ros/happypose_ros_parameters.yaml @@ -51,7 +51,8 @@ happypose_ros: model_type: type: string default_value: "pbr" - description: "What type of NN model to use, type of training data used, 'pbr'|'synth+real' " +description: "Type of neural network model to use. Available: 'pbr'|'synth+real'" +``` validation: one_of<>: [["pbr", "synth+real"]] read_only: true From b16425974bed7d345b07995b25968651b8822149 Mon Sep 17 00:00:00 2001 From: Krzysztof Wojciechowski Date: Wed, 16 Oct 2024 13:22:03 +0200 Subject: [PATCH 4/5] address PR comments --- happypose_examples/config/cosypose_params.yaml | 2 +- happypose_examples/config/cosypose_params_multiview.yaml | 2 +- happypose_examples/launch/common.launch.py | 2 +- happypose_examples/launch/single_view_demo.launch.py | 2 +- happypose_ros/test/test_initialization_params.py | 1 - 5 files changed, 4 insertions(+), 5 deletions(-) diff --git a/happypose_examples/config/cosypose_params.yaml b/happypose_examples/config/cosypose_params.yaml index 471fa18..9d76ec8 100644 --- a/happypose_examples/config/cosypose_params.yaml +++ b/happypose_examples/config/cosypose_params.yaml @@ -11,7 +11,7 @@ cosypose: # Name of BOP dataset, used to load specific weights and object models dataset_name: $(var dataset_name) - # What type of NN model to use, type of training data used, 'pbr'|'synth+real' + # Type of neural network model to use. Available 'pbr'|'synth+real' model_type: $(var model_type) # Object renderer parameters renderer: diff --git a/happypose_examples/config/cosypose_params_multiview.yaml b/happypose_examples/config/cosypose_params_multiview.yaml index f7595c0..3161793 100644 --- a/happypose_examples/config/cosypose_params_multiview.yaml +++ b/happypose_examples/config/cosypose_params_multiview.yaml @@ -17,7 +17,7 @@ cosypose: # Name of BOP dataset, used to load specific weights and object models dataset_name: $(var dataset_name) - # What type of NN model to use, type of training data used, 'pbr'|'synth+real' + # Type of neural network model to use. Available 'pbr'|'synth+real' model_type: $(var model_type) # Object renderer parameters renderer: diff --git a/happypose_examples/launch/common.launch.py b/happypose_examples/launch/common.launch.py index d1c7f4a..16d568c 100644 --- a/happypose_examples/launch/common.launch.py +++ b/happypose_examples/launch/common.launch.py @@ -73,7 +73,7 @@ def generate_launch_description(): DeclareLaunchArgument( "model_type", default_value="pbr", - description="What type of NN model to use, type of training data used, 'pbr'|'synth+real'.", + description="Type of neural network model to use. Available: 'pbr'|'synth+real'.", ), DeclareLaunchArgument( "device", diff --git a/happypose_examples/launch/single_view_demo.launch.py b/happypose_examples/launch/single_view_demo.launch.py index 3f80e47..d6ca144 100644 --- a/happypose_examples/launch/single_view_demo.launch.py +++ b/happypose_examples/launch/single_view_demo.launch.py @@ -78,7 +78,7 @@ def generate_launch_description(): DeclareLaunchArgument( "model_type", default_value="pbr", - description="What type of NN model to use, type of training data used, 'pbr'|'synth+real'.", + description="Type of neural network model to use. Available: 'pbr'|'synth+real'.", ), DeclareLaunchArgument( "device", diff --git a/happypose_ros/test/test_initialization_params.py b/happypose_ros/test/test_initialization_params.py index fedd5c9..32afe0a 100644 --- a/happypose_ros/test/test_initialization_params.py +++ b/happypose_ros/test/test_initialization_params.py @@ -106,7 +106,6 @@ def test_leading_publish_tf(happypose_params: dict) -> None: **happypose_params, parameter_overrides=[ Parameter("cosypose.dataset_name", Parameter.Type.STRING, "ycbv"), - Parameter("cosypose.model_type", Parameter.Type.STRING, "synth+real"), Parameter("camera_names", Parameter.Type.STRING_ARRAY, ["cam_1"]), Parameter("cameras.cam_1.leading", Parameter.Type.BOOL, True), Parameter("cameras.cam_1.publish_tf", Parameter.Type.BOOL, True), From 8e41f9a83fb1b3e563bbfe3e4dfbb8b9f4ca93bf Mon Sep 17 00:00:00 2001 From: Krzysztof Wojciechowski Date: Wed, 16 Oct 2024 13:27:51 +0200 Subject: [PATCH 5/5] fix yaml typo --- happypose_ros/happypose_ros/happypose_ros_parameters.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/happypose_ros/happypose_ros/happypose_ros_parameters.yaml b/happypose_ros/happypose_ros/happypose_ros_parameters.yaml index ef0a755..418b715 100644 --- a/happypose_ros/happypose_ros/happypose_ros_parameters.yaml +++ b/happypose_ros/happypose_ros/happypose_ros_parameters.yaml @@ -51,8 +51,7 @@ happypose_ros: model_type: type: string default_value: "pbr" -description: "Type of neural network model to use. Available: 'pbr'|'synth+real'" -``` + description: "Type of neural network model to use. Available: 'pbr'|'synth+real'" validation: one_of<>: [["pbr", "synth+real"]] read_only: true