From 28bb5ed01d8287fab9ab08b5c5d542bb677fc260 Mon Sep 17 00:00:00 2001 From: Illia Oleksiienko <io@ece.au.dk> Date: Tue, 1 Nov 2022 12:38:32 +0000 Subject: [PATCH] Add all track inference --- run/eval_tracking_3d.py | 99 ++++++++++++++++++++++++++++++++--------- run/train_3d.py | 1 + 2 files changed, 80 insertions(+), 20 deletions(-) diff --git a/run/eval_tracking_3d.py b/run/eval_tracking_3d.py index 3275444c00..c7f2beda4b 100644 --- a/run/eval_tracking_3d.py +++ b/run/eval_tracking_3d.py @@ -51,7 +51,10 @@ subsets_path = os.path.join( dataset_tracking_path = "/data/sets/kitti_tracking" datasets = {} -all_track_ids = ["0000"] +all_track_ids = [ + *["000" + str(i) for i in range(0, 10)], + *["00" + str(i) for i in range(10, 20 + 1)], +] for track_id in all_track_ids: datasets[track_id] = LabeledTrackingPointCloudsDatasetIterator( @@ -68,13 +71,14 @@ def save_detection_inference( samples_list=[1], config="xyres_16.proto", eval_suffix="classic", + return_uncertainty=True, ): config = os.path.join(config_roots[model_type], config,) model_path = os.path.join(temp_dir, name) learner = VoxelObjectDetection3DLearner( - model_config_path=config, device=device, checkpoint_after_iter=1000, return_uncertainty=True + model_config_path=config, device=device, checkpoint_after_iter=1000, return_uncertainty=return_uncertainty ) learner.load(model_path) @@ -85,6 +89,8 @@ def save_detection_inference( for track_id in all_track_ids: dataset = datasets[track_id] + + print("Track", track_id) os.makedirs(os.path.join( model_path, "tracking_inference_detections", eval_suffix, "samples_" + str(samples) @@ -110,7 +116,6 @@ def save_detection_inference( f.write(result) - def test_model( model_type, device="cuda:0", @@ -118,25 +123,22 @@ def test_model( samples_list=[1], config="xyres_16.proto", eval_suffix="classic", + mode="save_detection_inference", + return_uncertainty=True, ): - return save_detection_inference( - model_type=model_type, - device=device, - name=name, - samples_list=samples_list, - config=config, - eval_suffix=eval_suffix, - ) - - # config = os.path.join(config_roots[model_type], config,) - # model_path = os.path.join(temp_dir, name) - - # learner = VoxelObjectDetection3DLearner( - # model_config_path=config, device=device, checkpoint_after_iter=1000 - # ) - # learner.load(model_path) - + if mode == "save_detection_inference": + return save_detection_inference( + model_type=model_type, + device=device, + name=name, + samples_list=samples_list, + config=config, + eval_suffix=eval_suffix, + return_uncertainty=return_uncertainty, + ) + else: + raise ValueError("Unknown mode " + str(mode)) def test_pointpillars( @@ -153,6 +155,7 @@ def test_pointpillars( samples_list=samples_list, config=config, eval_suffix=eval_suffix, + return_uncertainty=False, ) @@ -170,6 +173,7 @@ def test_tanet( samples_list=samples_list, config=config, eval_suffix=eval_suffix, + return_uncertainty=False, ) @@ -188,6 +192,7 @@ def test_vnn_pointpillars( eval_suffix=eval_suffix, ) + def test_vnna_pointpillars( device="cuda:0", name="vnna_pointpillars_car", @@ -221,5 +226,59 @@ def test_vnn_tanet( ) +def test_tapp( + device="cuda:0", + name="tapp_car", + samples_list=[1], + config="tapp_16.proto", + eval_suffix="classic", +): + return test_model( + "tanet", + device=device, + name=name, + samples_list=samples_list, + config=config, + eval_suffix=eval_suffix, + return_uncertainty=False, + ) + + +def test_vnn_tapp( + device="cuda:0", + name="vnn_tapp_car", + samples_list=[1, 2, 3, 4], + config="vnn_tapp_16.proto", + eval_suffix="vnn", +): + return test_model( + "tanet", + device=device, + name=name, + samples_list=samples_list, + config=config, + eval_suffix=eval_suffix, + ) + + +def all_save_detection_inference(start=0): + models = [ + ("tapp_car", test_tapp), + ("pointpillars_car", test_pointpillars), + ("tanet_car", test_tanet), + *[("vnn_pointpillars_car_s" + str(i), test_vnn_pointpillars) for i in range(1, 7 + 1)], + *[("vnna_pointpillars_car_s" + str(i), test_vnna_pointpillars) for i in range(1, 4 + 1)], + *[("vnn_tanet_car_s" + str(i), test_vnn_tanet) for i in range(1, 3 + 1)], + *[("vnn_tapp_car_s" + str(i), test_vnn_tapp) for i in range(1, 3 + 1)], + ] + + for i, (model_name, test_func) in enumerate(models): + print(":::", i + 1, "/", len(models)) + + if i < start: + continue + + test_func(name=model_name) + if __name__ == "__main__": fire.Fire() diff --git a/run/train_3d.py b/run/train_3d.py index 4be41991e3..313baddee5 100644 --- a/run/train_3d.py +++ b/run/train_3d.py @@ -314,6 +314,7 @@ def test_vnn_pointpillars( eval_suffix=eval_suffix, ) + def test_vnna_pointpillars( device="cuda:0", name="vnna_pointpillars_car", -- GitLab