From b4ab59511e3c3f46f39ae86d4dd185fc57f9044d Mon Sep 17 00:00:00 2001 From: macaodha Date: Wed, 14 Dec 2022 19:08:05 +0000 Subject: [PATCH] tweaks --- README.md | 3 ++- batdetect2_notebook.ipynb | 3 +-- config.py | 6 ------ run_batdetect.py | 6 +----- scripts/gen_spec_image.py | 4 ++-- scripts/gen_spec_video.py | 1 - 6 files changed, 6 insertions(+), 17 deletions(-) delete mode 100644 config.py diff --git a/README.md b/README.md index 64c7b4a..a67551a 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,8 @@ e.g. There are also optional arguments, e.g. you can request that the model outputs features (i.e. estimated call parameters) such as duration, max_frequency, etc. by setting the flag `--spec_features`. These will be saved as `*_spec_features.csv` files: `python run_batdetect.py example_data/audio/ example_data/anns/ 0.3 --spec_features` -You can also specify which model to use by setting the `--model_path` argument. If not specified, it will default to using a model trained on UK data. +You can also specify which model to use by setting the `--model_path` argument. If not specified, it will default to using a model trained on UK data e.g. +`python run_batdetect.py example_data/audio/ example_data/anns/ 0.3 --model_path models/Net2DFast_UK_same.pth.tar` ### Training the model on your own data diff --git a/batdetect2_notebook.ipynb b/batdetect2_notebook.ipynb index ad7eb1c..37580ec 100644 --- a/batdetect2_notebook.ipynb +++ b/batdetect2_notebook.ipynb @@ -43,7 +43,6 @@ "import glob\n", "import matplotlib.pyplot as plt\n", "\n", - "import config\n", "import bat_detect.utils.detector_utils as du\n", "import bat_detect.utils.audio_utils as au\n", "import bat_detect.utils.plot_utils as viz" @@ -59,7 +58,7 @@ "args = du.get_default_bd_args()\n", "args['detection_threshold'] = 0.3\n", "args['time_expansion_factor'] = 1\n", - "args['model_path'] = os.path.join('models', os.path.basename(config.MODEL_PATH))" + "args['model_path'] = 'models/Net2DFast_UK_same.pth.tar'" ] }, { diff --git a/config.py b/config.py deleted file mode 100644 index 101b8ec..0000000 --- a/config.py +++ /dev/null @@ -1,6 +0,0 @@ - -""" -Configuration parameters -""" - -MODEL_PATH = 'mdoels/Net2DFast_UK_same.pth.tar' diff --git a/run_batdetect.py b/run_batdetect.py index 570a5eb..9655d45 100644 --- a/run_batdetect.py +++ b/run_batdetect.py @@ -1,6 +1,5 @@ import os import argparse -import config import bat_detect.utils.detector_utils as du @@ -57,7 +56,7 @@ if __name__ == "__main__": help='Minimize output printing') parser.add_argument('--save_preds_if_empty', action='store_true', default=False, dest='save_preds_if_empty', help='Save empty annotation file if no detections made.') - parser.add_argument('--model_path', type=str, default='', + parser.add_argument('--model_path', type=str, default='models/Net2DFast_UK_same.pth.tar', help='Path to trained BatDetect2 model') args = vars(parser.parse_args()) @@ -65,7 +64,4 @@ if __name__ == "__main__": args['chunk_size'] = 2 # if files greater than this amount (seconds) they will be broken down into small chunks args['ann_dir'] = os.path.join(args['ann_dir'], '') - if args['model_path'] == '': - args['model_path'] = os.path.join('models', os.path.basename(config.MODEL_PATH)) - main(args) diff --git a/scripts/gen_spec_image.py b/scripts/gen_spec_image.py index 182f5bf..11f76de 100644 --- a/scripts/gen_spec_image.py +++ b/scripts/gen_spec_image.py @@ -47,7 +47,7 @@ if __name__ == "__main__": help='Start time for cropped file') parser.add_argument('--stop_time', type=float, default=0.5, help='End time for cropped file') - parser.add_argument('--time_exp', type=int, default=1, + parser.add_argument('--time_expansion_factor', type=int, default=1, help='Time expansion factor') args_cmd = vars(parser.parse_args()) @@ -56,7 +56,7 @@ if __name__ == "__main__": bd_args = du.get_default_bd_args() model, params_bd = du.load_model(args_cmd['model_path']) bd_args['detection_threshold'] = args_cmd['detection_threshold'] - bd_args['time_expansion_factor'] = args_cmd['time_exp'] + bd_args['time_expansion_factor'] = args_cmd['time_expansion_factor'] # load the annotation if it exists gt_present = False diff --git a/scripts/gen_spec_video.py b/scripts/gen_spec_video.py index 25e7319..cccfcf8 100644 --- a/scripts/gen_spec_video.py +++ b/scripts/gen_spec_video.py @@ -21,7 +21,6 @@ import bat_detect.detector.parameters as parameters import bat_detect.utils.audio_utils as au import bat_detect.utils.plot_utils as viz import bat_detect.utils.detector_utils as du -import config if __name__ == "__main__":