mirror of
https://github.com/macaodha/batdetect2.git
synced 2025-06-29 14:41:58 +02:00
updated notebook
This commit is contained in:
parent
0dba8a6784
commit
895c93c022
@ -6,9 +6,16 @@
|
||||
"source": [
|
||||
"# BatDetect2 - Demo\n",
|
||||
"\n",
|
||||
"This notebook illustrates how to use Google Colab to run the bat detection code. Click [here](https://colab.research.google.com/github/macaodha/batdetect2/blob/master/batdetect2_notebook.ipynb) to run it on Colab. \n",
|
||||
"This notebook illustrates to run the BatDetect2 code. You can either run it locally on your own computer or on Google Colab. \n",
|
||||
"\n",
|
||||
"Make sure to enable GPU usage on Colab for this Notebook to make it run faster. "
|
||||
"Click [here](https://colab.research.google.com/github/macaodha/batdetect2/blob/master/batdetect2_notebook.ipynb) to run it on This Colab. Make sure to enable GPU usage on Colab for this Notebook to make it run faster. "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Load the model"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -19,8 +26,8 @@
|
||||
"source": [
|
||||
"# the following lines are only needed in Colab.\n",
|
||||
"# clone the code and change directory\n",
|
||||
"!git clone https://github.com/macaodha/batdetect2\n",
|
||||
"%cd batdetect2"
|
||||
"#!git clone https://github.com/macaodha/batdetect2\n",
|
||||
"#%cd batdetect2"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -70,6 +77,13 @@
|
||||
"model, params = du.load_model(args['model_path'])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Select the audio file and run the model"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
@ -77,7 +91,13 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# choose an audio file\n",
|
||||
"audio_file = 'example_data/audio/20180530_213516-EPTSER-LR_0_0.5.wav'"
|
||||
"audio_file = 'example_data/audio/20180530_213516-EPTSER-LR_0_0.5.wav'\n",
|
||||
"\n",
|
||||
"# the following lines are only needed in Colab\n",
|
||||
"# alternatively you can upload your own file\n",
|
||||
"#from google.colab import files\n",
|
||||
"#uploaded = files.upload()\n",
|
||||
"#audio_file = list(uploaded.keys())[0]"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -102,6 +122,13 @@
|
||||
"results = du.process_file(audio_file, model, params, args)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Print the results"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
@ -148,6 +175,13 @@
|
||||
" print('{}\\t{}\\t{}\\t{}'.format(ann['start_time'], ann['class_prob'], ann['low_freq'], ann['class']))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Visualise the detections"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
@ -209,47 +243,6 @@
|
||||
"plt.title(os.path.basename(audio_file))\n",
|
||||
"plt.show()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Run on audio files stored in your Google Drive\n",
|
||||
"## WIP"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# mount your Google Drive in Colab\n",
|
||||
"# this will open a new browser window, ask you to give permission, \n",
|
||||
"# and then give you an access code you can paste here\n",
|
||||
"#from google.colab import drive\n",
|
||||
"#drive.mount('/content/drive')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"We will assume that you have some audio files in directory called `sample_bat_audio` in your Google Drive. "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# load the audio files from Google Drive\n",
|
||||
"#root_dir = \"drive/My Drive/\"\n",
|
||||
"#audio_dir = root_dir + 'sample_bat_audio/'\n",
|
||||
"#files = glob.glob(audio_dir + '*.wav')\n",
|
||||
"#print('Found {} audio files.'.format(len(files)))"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
Loading…
Reference in New Issue
Block a user