mirror of
https://github.com/macaodha/batdetect2.git
synced 2025-06-29 22:51:58 +02:00
tweaks
This commit is contained in:
parent
a5c263093f
commit
b4ab59511e
@ -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:
|
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`
|
`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
|
### Training the model on your own data
|
||||||
|
@ -43,7 +43,6 @@
|
|||||||
"import glob\n",
|
"import glob\n",
|
||||||
"import matplotlib.pyplot as plt\n",
|
"import matplotlib.pyplot as plt\n",
|
||||||
"\n",
|
"\n",
|
||||||
"import config\n",
|
|
||||||
"import bat_detect.utils.detector_utils as du\n",
|
"import bat_detect.utils.detector_utils as du\n",
|
||||||
"import bat_detect.utils.audio_utils as au\n",
|
"import bat_detect.utils.audio_utils as au\n",
|
||||||
"import bat_detect.utils.plot_utils as viz"
|
"import bat_detect.utils.plot_utils as viz"
|
||||||
@ -59,7 +58,7 @@
|
|||||||
"args = du.get_default_bd_args()\n",
|
"args = du.get_default_bd_args()\n",
|
||||||
"args['detection_threshold'] = 0.3\n",
|
"args['detection_threshold'] = 0.3\n",
|
||||||
"args['time_expansion_factor'] = 1\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'"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
|
|
||||||
"""
|
|
||||||
Configuration parameters
|
|
||||||
"""
|
|
||||||
|
|
||||||
MODEL_PATH = 'mdoels/Net2DFast_UK_same.pth.tar'
|
|
@ -1,6 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
import argparse
|
import argparse
|
||||||
import config
|
|
||||||
import bat_detect.utils.detector_utils as du
|
import bat_detect.utils.detector_utils as du
|
||||||
|
|
||||||
|
|
||||||
@ -57,7 +56,7 @@ if __name__ == "__main__":
|
|||||||
help='Minimize output printing')
|
help='Minimize output printing')
|
||||||
parser.add_argument('--save_preds_if_empty', action='store_true', default=False, dest='save_preds_if_empty',
|
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.')
|
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')
|
help='Path to trained BatDetect2 model')
|
||||||
args = vars(parser.parse_args())
|
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['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'], '')
|
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)
|
main(args)
|
||||||
|
@ -47,7 +47,7 @@ if __name__ == "__main__":
|
|||||||
help='Start time for cropped file')
|
help='Start time for cropped file')
|
||||||
parser.add_argument('--stop_time', type=float, default=0.5,
|
parser.add_argument('--stop_time', type=float, default=0.5,
|
||||||
help='End time for cropped file')
|
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')
|
help='Time expansion factor')
|
||||||
|
|
||||||
args_cmd = vars(parser.parse_args())
|
args_cmd = vars(parser.parse_args())
|
||||||
@ -56,7 +56,7 @@ if __name__ == "__main__":
|
|||||||
bd_args = du.get_default_bd_args()
|
bd_args = du.get_default_bd_args()
|
||||||
model, params_bd = du.load_model(args_cmd['model_path'])
|
model, params_bd = du.load_model(args_cmd['model_path'])
|
||||||
bd_args['detection_threshold'] = args_cmd['detection_threshold']
|
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
|
# load the annotation if it exists
|
||||||
gt_present = False
|
gt_present = False
|
||||||
|
@ -21,7 +21,6 @@ import bat_detect.detector.parameters as parameters
|
|||||||
import bat_detect.utils.audio_utils as au
|
import bat_detect.utils.audio_utils as au
|
||||||
import bat_detect.utils.plot_utils as viz
|
import bat_detect.utils.plot_utils as viz
|
||||||
import bat_detect.utils.detector_utils as du
|
import bat_detect.utils.detector_utils as du
|
||||||
import config
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user