From b20fa8bb7582986365d5925b9185f8ad14bc63eb Mon Sep 17 00:00:00 2001 From: hofee Date: Thu, 13 Mar 2025 14:48:15 +0800 Subject: [PATCH] update strong pointnet++ --- app_sim.py | 9 ++++++++ configs/local/inference_config.yaml | 8 +++---- configs/local/simulation_config.yaml | 14 ++++++++++++ modules/pointnet++_encoder.py | 32 ++++++++++++++++++++++++++-- runners/inferencer.py | 3 +-- runners/simulator.py | 23 ++++++++++++++++++++ 6 files changed, 81 insertions(+), 8 deletions(-) create mode 100644 app_sim.py create mode 100644 configs/local/simulation_config.yaml create mode 100644 runners/simulator.py diff --git a/app_sim.py b/app_sim.py new file mode 100644 index 0000000..0b2dee9 --- /dev/null +++ b/app_sim.py @@ -0,0 +1,9 @@ +from PytorchBoot.application import PytorchBootApplication +from runners.simulator import Simulator + +@PytorchBootApplication("sim") +class SimulateApp: + @staticmethod + def start(): + Simulator("configs/server/server_split_dataset_config.yaml").run() + \ No newline at end of file diff --git a/configs/local/inference_config.yaml b/configs/local/inference_config.yaml index 384e912..811a8ae 100644 --- a/configs/local/inference_config.yaml +++ b/configs/local/inference_config.yaml @@ -6,16 +6,16 @@ runner: cuda_visible_devices: "0,1,2,3,4,5,6,7" experiment: - name: train_ab_global_only_dense + name: train_ab_global_only_p++_wp root_dir: "experiments" - epoch: 441 # -1 stands for last epoch + epoch: 922 # -1 stands for last epoch test: dataset_list: - OmniObject3d_test blender_script_path: "/media/hofee/data/project/python/nbv_reconstruction/blender/data_renderer.py" - output_dir: "/media/hofee/data/data/p++_dense" + output_dir: "/media/hofee/data/data/p++_wp" pipeline: nbv_reconstruction_pipeline voxel_size: 0.003 min_new_area: 1.0 @@ -62,7 +62,7 @@ pipeline: module: pointnet++_encoder: in_dim: 3 - params_name: dense + params_name: light pointnet_encoder: in_dim: 3 diff --git a/configs/local/simulation_config.yaml b/configs/local/simulation_config.yaml new file mode 100644 index 0000000..8cfb2e8 --- /dev/null +++ b/configs/local/simulation_config.yaml @@ -0,0 +1,14 @@ + +runner: + general: + seed: 0 + device: cuda + cuda_visible_devices: "0,1,2,3,4,5,6,7" + + experiment: + name: simulation_debug + root_dir: "experiments" + +simulation: + robot: + displaytable: \ No newline at end of file diff --git a/modules/pointnet++_encoder.py b/modules/pointnet++_encoder.py index c597fb5..861dce6 100644 --- a/modules/pointnet++_encoder.py +++ b/modules/pointnet++_encoder.py @@ -33,6 +33,30 @@ ClsMSG_CFG_Light = { 'DP_RATIO': 0.5, } +ClsMSG_CFG_Light_2048 = { + 'NPOINTS': [512, 256, 128, None], + 'RADIUS': [[0.02, 0.04], [0.04, 0.08], [0.08, 0.16], [None, None]], + 'NSAMPLE': [[16, 32], [16, 32], [16, 32], [None, None]], + 'MLPS': [[[16, 16, 32], [32, 32, 64]], + [[64, 64, 128], [64, 96, 128]], + [[128, 196, 256], [128, 196, 256]], + [[256, 256, 1024], [256, 512, 1024]]], + 'DP_RATIO': 0.5, +} + +ClsMSG_CFG_Strong = { + 'NPOINTS': [512, 256, 128, 64, None], + 'RADIUS': [[0.02, 0.04], [0.04, 0.08], [0.08, 0.16],[0.16, 0.32], [None, None]], + 'NSAMPLE': [[16, 32], [16, 32], [16, 32], [16, 32], [None, None]], + 'MLPS': [[[16, 16, 32], [32, 32, 64]], + [[64, 64, 128], [64, 96, 128]], + [[128, 196, 256], [128, 196, 256]], + [[256, 256, 512], [256, 512, 512]], + [[512, 512, 2048], [512, 1024, 2048]] + ], + 'DP_RATIO': 0.5, +} + ClsMSG_CFG_Lighter = { 'NPOINTS': [512, 256, 128, 64, None], 'RADIUS': [[0.01], [0.02], [0.04], [0.08], [None]], @@ -53,6 +77,10 @@ def select_params(name): return ClsMSG_CFG_Lighter elif name == 'dense': return ClsMSG_CFG_Dense + elif name == 'light_2048': + return ClsMSG_CFG_Light_2048 + elif name == 'strong': + return ClsMSG_CFG_Strong else: raise NotImplementedError @@ -114,8 +142,8 @@ if __name__ == '__main__': seed = 100 torch.manual_seed(seed) torch.cuda.manual_seed(seed) - net = PointNet2Encoder(config={"in_dim": 3, "params_name": "light"}).cuda() - pts = torch.randn(2, 1024, 3).cuda() + net = PointNet2Encoder(config={"in_dim": 3, "params_name": "strong"}).cuda() + pts = torch.randn(2, 2444, 3).cuda() print(torch.mean(pts, dim=1)) pre = net.encode_points(pts) print(pre.shape) diff --git a/runners/inferencer.py b/runners/inferencer.py index 68bf1f8..4c64bd4 100644 --- a/runners/inferencer.py +++ b/runners/inferencer.py @@ -137,7 +137,7 @@ class Inferencer(Runner): pred_cr_seq = [last_pred_cr] success = 0 last_pts_num = PtsUtil.voxel_downsample_point_cloud(data["first_scanned_pts"][0], voxel_threshold).shape[0] - import time + #import time while len(pred_cr_seq) < max_iter and retry < max_retry and success < max_success: Log.green(f"iter: {len(pred_cr_seq)}, retry: {retry}/{max_retry}, success: {success}/{max_success}") combined_scanned_pts = np.vstack(scanned_view_pts) @@ -229,7 +229,6 @@ class Inferencer(Runner): Log.success(f"delta pts num < {self.min_new_pts_num}:, {pts_num}, {last_pts_num}") last_pts_num = pts_num - break input_data["scanned_n_to_world_pose_9d"] = input_data["scanned_n_to_world_pose_9d"][0].cpu().numpy().tolist() diff --git a/runners/simulator.py b/runners/simulator.py new file mode 100644 index 0000000..ee1198b --- /dev/null +++ b/runners/simulator.py @@ -0,0 +1,23 @@ +from PytorchBoot.runners.runner import Runner +import PytorchBoot.stereotype as stereotype + +@stereotype.runner("simulator") +class Simulator(Runner): + def __init__(self, config_path): + super().__init__(config_path) + self.config_path = config_path + + def run(self): + print() + + def prepare_env(self): + pass + + def create_env(self): + pass + + def create_experiment(self, backup_name=None): + return super().create_experiment(backup_name) + + def load_experiment(self, backup_name=None): + super().load_experiment(backup_name) \ No newline at end of file