Giter Site home page Giter Site logo

birdvoxdetect's Introduction

BirdVoxDetect: detection and classification of flight calls

PyPI MIT license DOI

BirdVoxDetect is a pre-trained deep learning system which detects flight calls from songbirds in audio recordings, and retrieves the corresponding species. It relies on per-channel energy normalization (PCEN) and context-adaptive convolutional neural networks (CA-CNN) for improved robustness to background noise. It is made available both as a Python library and as a command-line tool for Windows, OS X, and GNU/Linux.

Installation

The simplest way to install BirdVoxDetect is by using the pip package management system, which will also install the additional required dependencies if needed.

pip install birdvoxdetect

Note that birdvoxdetect requires:

  • Python (3.6, 3.7, or 3.8)
  • librosa (==0.7.0)
  • tensorflow (>=2.2)
  • scikit-learn (==0.21.2)
  • birdvoxclassify (>=0.3)
  • h5py
  • pandas

Usage

From the command line

To analyze one file:

birdvoxdetect path/to/file.wav

To analyze multiple files:

birdvoxdetect path/to/file1.wav path/to/file2.wav

To analyze one folder:

birdvoxdetect path/to/folder

On Windows:

birdvoxdetect path\to\folder

Optional arguments:

--clip-duration CLIP_DURATION, -d CLIP_DURATION
                      Duration of the exported clips, expressed in seconds
                      (fps). The default value is 1.0, that is, one second.
                      We recommend values of 0.5 or above.
--export-clips, -c    Export detected events as audio clips in WAV format.
--export-confidence, -C
                      Export the time series of model confidence values of
                      events in HDF5 format.
--export-faults, -f   Export list of sensor faults in CSV format.
--export-logger, -l   Export output of Python logger in TXT format.
--output-dir OUTPUT_DIR, -o OUTPUT_DIR
                      Directory to save the output file(s); The default
                      value is the same directory as the input file(s).
--predict-proba, -p   Export output probabilities in JSON format.
--quiet, -q           Print less messages on screen.
--suffix SUFFIX, -s SUFFIX
                      String to append to the output filenames.The default
                      value is the empty string.
--threshold THRESHOLD, -t THRESHOLD
                      Detection threshold, between 10 and 90. The default
                      value is 50. Greater values lead to higher precision
                      at the expense of a lower recall.
--verbose, -v         Print timestamps of detected events.
--version, -V         Print version number.

From Python

Call syntax:

import birdvoxdetect as bvd    
df = bvd.process_file('path/to/file.wav')

df is a Pandas DataFrame with three columns: time, detection confidence, and species.

Below is a typical output from the test suite (file path tests/data/audio/fd79e55d-d3a3-4083-aba1-4f00b545c3d6.wav):

Time (hh:mm:ss),Detection confidence (%),Order,Order confidence (%),Family,Family confidence (%),Species (English name),Species (scientific name),Species (4-letter code),Species confidence (%)
0,00:00:08.78,70.15%,Passeriformes,100.00%,Turdidae,100.00%,Swainson's thrush,Catharus ustulatus,SWTH,99.28%

Contact

Official website

Please visit our website for more information on the BirdVox project: https://wp.nyu.edu/birdvox

The main developer of BirdVoxDetect is Vincent Lostanlen, scientist at CNRS, the French national center for scientific research.

Discussion group

For any questions or announcements related to BirdVoxDetect, please refer to our discussion group: https://groups.google.com/g/birdvox

References

Please cite the following paper when using BirdVoxDetect in your work:

Robust Sound Event Detection in Bioacoustic Sensor Networks
Vincent Lostanlen, Justin Salamon, Andrew Farnsworth, Steve Kelling, and Juan Pablo Bello
PLoS ONE 14(10): e0214168, 2019. DOI: https://doi.org/10.1371/journal.pone.0214168

As of v0.4, species classification in BirdVoxDetect relies on a taxonomical neural network (TaxoNet), which is distributed as part of the BirdVoxClassify package. For more details on TaxoNet, please refer to:

Chirping up the Right Tree: Incorporating Biological Taxonomies into Deep Bioacoustic Classifiers
Jason Cramer, Vincent Lostanlen, Andrew Farnsworth, Justin Salamon, and Juan Pablo Bello
In IEEE International Conference on Acoustics, Speech, and Signal Processing (ICASSP), Barcelona, Spain, May 2020.

birdvoxdetect's People

Contributors

dependabot[bot] avatar justinsalamon avatar lostanlen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

birdvoxdetect's Issues

adjustable birdvoxactivate threshold

from @HaroldMills over email:

I wanted to say a little more about the BVD sensor fault detection. I think it might be a good idea to expose the sensor fault detection threshold as a BVD configuration parameter, to allow user adjustment. I am using BVD to process some low-amplitude recordings, for which your sensor fault detector always produces a fault probability of one.

confidence should max at 99, not 100

having two-digit confidence levels would be preferable for char length of export_clips

as is, the numerical max (raw = 0) is 103
bringing it to 100 corresponds to a raw value of ~50-80x float32's tiny

>>> - np.log(np.finfo(np.float32).tiny*80) - np.log(np.finfo(np.float32).eps)
98.89690283572786

in comparison, float32's eps brings us at 31

>>> - np.log(np.finfo(np.float32).eps) - np.log(np.finfo(np.float32).eps)
31.88477

in practice, the observed values seem to be either ~eps or =0, hence big swings between 31 and 103. In the future, it might be worth to multiply everything by 3 so that this 31.88 becomes 96

but this is an orthogonal question to the char length

librosa.util.exceptions.ParameterError: Invalid shape for monophonic audio: ndim=2, shape=(5221248, 2)

I think the error just means I need to convert stereo to mono. That seems to resolve it.

C:\wc\record-nfc\.venv\lib\site-packages\librosa\util\decorators.py:9: NumbaDeprecationWarning: An import was requested from a module that has moved location.
Import requested from: 'numba.decorators', please update to use 'numba.core.decorators' or pin to Numba version 0.48.0. This alias will not be present in Numba version 0.50.0.
  from numba.decorators import jit as optional_jit
C:\wc\record-nfc\.venv\lib\site-packages\librosa\util\decorators.py:9: NumbaDeprecationWarning: An import was requested from a module that has moved location.
Import of 'jit' requested from: 'numba.decorators', please update to use 'numba.core.decorators' or pin to Numba version 0.48.0. This alias will not be present in Numba version 0.50.0.
  from numba.decorators import jit as optional_jit
birdvoxdetect: Threshold = 40.0
birdvoxdetect: Duration of exported clips = 2.00 seconds.
birdvoxdetect: Processing: D:\birdrecordings\2020-05-07-NFC-recordings\200507-224636.WAV
Traceback (most recent call last):
  File "C:\Program Files\Python37\Lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Program Files\Python37\Lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\wc\record-nfc\.venv\lib\site-packages\birdvoxdetect\__main__.py", line 7, in <module>
    main()
  File "C:\wc\record-nfc\.venv\lib\site-packages\birdvoxdetect\cli.py", line 200, in main
    logger_level=logger_level)
  File "C:\wc\record-nfc\.venv\lib\site-packages\birdvoxdetect\cli.py", line 89, in run
    logger_level=logger_level)
  File "C:\wc\record-nfc\.venv\lib\site-packages\birdvoxdetect\core.py", line 529, in process_file
    chunk_pcen = compute_pcen(chunk_audio, sr)
  File "C:\wc\record-nfc\.venv\lib\site-packages\birdvoxdetect\core.py", line 746, in compute_pcen
    librosa.util.valid_audio(audio, mono=True)
  File "C:\wc\record-nfc\.venv\lib\site-packages\librosa\util\utils.py", line 164, in valid_audio
    'ndim={:d}, shape={}'.format(y.ndim, y.shape))
librosa.util.exceptions.ParameterError: Invalid shape for monophonic audio: ndim=2, shape=(5221248, 2)```

librosa.write_wav is deprecated

This function is deprecated in librosa 0.7.0. It will be removed in 0.8. Usage of write_wav should be replaced by soundfile.write.

BVC calls BVD on ill-sized PCEN matrices

version 0.2.0a1
triggered during usability check on BVFN (unit02)

birdvoxdetect: Output directory = /beegfs/vl1019/bvd020a_test
birdvoxdetect: Duration of exported clips = 1.00 seconds.
birdvoxdetect: Processing: /beegfs/vl1019/bvd020a_test/BirdVox-full-night_flac/BirdVox-full-night_flac-audio_unit02.flac
9118/9118 [==============================] - 63s 7ms/sample
9118/9118 [==============================] - 63s 7ms/sample
9118/9118 [==============================] - 63s 7ms/sample
9118/9118 [==============================] - 63s 7ms/sample
9118/9118 [==============================] - 63s 7ms/sample
9118/9118 [==============================] - 63s 7ms/sample
9118/9118 [==============================] - 63s 7ms/sample
9118/9118 [==============================] - 63s 7ms/sample
9118/9118 [==============================] - 63s 7ms/sample
9118/9118 [==============================] - 63s 7ms/sample
9118/9118 [==============================] - 63s 7ms/sample
9118/9118 [==============================] - 63s 7ms/sample
9118/9118 [==============================] - 63s 7ms/sample
9118/9118 [==============================] - 63s 7ms/sample
9118/9118 [==============================] - 63s 7ms/sample
9118/9118 [==============================] - 63s 7ms/sample
9118/9118 [==============================] - 63s 7ms/sample
9118/9118 [==============================] - 63s 7ms/sample
9118/9118 [==============================] - 63s 7ms/sample
9118/9118 [==============================] - 63s 7ms/sample
9118/9118 [==============================] - 63s 7ms/sample
Traceback (most recent call last):
  File "/home/vl1019/miniconda3/envs/bvd02a1/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/vl1019/miniconda3/envs/bvd02a1/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/vl1019/miniconda3/envs/bvd02a1/lib/python3.6/site-packages/birdvoxdetect/__main__.py", line 7, in <module>
    main()
  File "/home/vl1019/miniconda3/envs/bvd02a1/lib/python3.6/site-packages/birdvoxdetect/cli.py", line 200, in main
    logger_level=logger_level)
  File "/home/vl1019/miniconda3/envs/bvd02a1/lib/python3.6/site-packages/birdvoxdetect/cli.py", line 89, in run
    logger_level=logger_level)
  File "/home/vl1019/miniconda3/envs/bvd02a1/lib/python3.6/site-packages/birdvoxdetect/core.py", line 431, in process_file
    th_peak_locs))
  File "/home/vl1019/miniconda3/envs/bvd02a1/lib/python3.6/site-packages/birdvoxdetect/core.py", line 430, in <lambda>
    lambda x: classify_species(classifier, chunk_pcen, x, taxonomy),
  File "/home/vl1019/miniconda3/envs/bvd02a1/lib/python3.6/site-packages/birdvoxdetect/core.py", line 674, in classify_species
    birdvoxclassify.predict(pcen_clip, classifier=classifier),
  File "/home/vl1019/miniconda3/envs/bvd02a1/lib/python3.6/site-packages/birdvoxclassify/core.py", line 489, in predict
    pcen.shape[2]
birdvoxclassify.birdvoxclassify_exceptions.BirdVoxClassifyError: Invalid number of frames in input PCEN. Expected 104 but got 0.
srun: error: c41-01: task 0: Exited with exit code 1
srun: Terminating job step 6866449.0

MP3 support

Requested by Davyd Betchkal

Pasting Justin Salmon's reply here:

Currently BVD and BVC rely on the soundfile python library for audio I/O, which in turn relies on the libsndfile library, which doesn't support mp3 (yet). While there are other python audio libraries that do support mp3 loading, we rely on the functionality of soundfile, in particular seeking to load a segment of an audiofile without having to load all the data into memory, which is important for robust processing of long recordings. My colleagues Vincent and Jason can probably comment on this in greater detail.

That said, we realize that this is an important feature and we would love to support it if we can. We'll try to do some digging around this to see what we can do - perhaps there are alternative builds of libsndfile that do support mp3 that we could leverage, potentially at the cost of a custom installation process for users who require this feature.

Versioning releases

Just noticed how we're versioning/naming releases. Perhaps it's worth adhering to conventions here, which means:

  • Each release version follows semver MAJOR.minor.bug convention, e.g. 0.1.0 instead of 0.1
  • No white space in release names, i.e. 0.1.0.beta or 0.1.0.rc0 instead of 0.1 beta (for pre-releases I prefer using rcX instead of beta because it support multiple pre-releases (rc0, rc1, etc...).
  • Optional: release names start with a v, i.e. v0.1.0 instead of 0.1.0

Examples of following the above suggestions include the releases for librosa and scaper.

Type instability of melspectrogram (librosa #825)

librosa/librosa#825 (closed by librosa/librosa#832), has made STFT's type-stable in terms of float32 vs. float64 precision.
Bumping our requirements to librosa 0.6.3 would spare us in compute_pcen:

    # Gather frequency bins according to the Mel scale.
    # NB: as of librosa v0.6.2, melspectrogram is type-instable and thus
    # returns 64-bit output even with a 32-bit input. Therefore, we need
    # to convert PCEN to single precision eventually. This might not be
    # necessary in the future, if the whole PCEN pipeline is kept type-stable.
    melspec = librosa.feature.melspectrogram(
        y=None,
        S=abs2_stft,
        sr=pcen_settings["sr"],
        n_fft=pcen_settings["n_fft"],
        n_mels=pcen_settings["n_mels"],
        htk=True,
        fmin=pcen_settings["fmin"],
        fmax=pcen_settings["fmax"])

    # Compute PCEN.
    pcen = librosa.pcen(
        melspec,
        sr=pcen_settings["sr"],
        hop_length=pcen_settings["hop_length"],
        gain=pcen_settings["pcen_norm_exponent"],
        bias=pcen_settings["pcen_delta"],
        power=pcen_settings["pcen_power"],
        time_constant=pcen_settings["pcen_time_constant"])

    # Convert to single floating-point precision.
    pcen = pcen.astype('float32')

JSON checklist export

it would be good to export the checklist in a JSON format, so as to include per-species, per-family, and per-order probability predictions

Triaged for v0.4

UK Birds

Hi,

Does this work for UK birds? I'm guessing it's trained for American birds but I can't find anything that confirms that.

Many thanks,
Louis

keras.models.load_model Heisenbug

race condition in: https://github.com/BirdVox/birdvoxdetect/blob/master/birdvoxdetect/core.py#L106

2020-01-26 16:20:39.092832: E tensorflow/stream_executor/cuda/cuda_driver.cc:318] failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected
2020-01-26 16:20:37.134087 Start.
Running BirdVoxDetect on BirdVox-300h.
WAV name: 2015-11-26_09-37-00_unit06.wav.

birdvoxdetect version: 0.2.0b1
h5py version: 2.10.0
librosa version: 0.7.0
numpy version: 1.16.4
pandas version: 0.25.1
resampy version: 0.2.2
scipy version: 1.4.1
soundfile version: 0.10.3
tensorflow version: 1.15.0

Traceback (most recent call last):
  File "/home/vl1019/birdvoxdetect/birdvoxdetect/core.py", line 107, in process_file
    detector_model_path, custom_objects=custom_objects)
  File "/home/vl1019/miniconda3/envs/bvdev/lib/python3.6/site-packages/tensorflow_core/python/keras/saving/save.py", line 143, in load_model
    return hdf5_format.load_model_from_hdf5(filepath, custom_objects, compile)
  File "/home/vl1019/miniconda3/envs/bvdev/lib/python3.6/site-packages/tensorflow_core/python/keras/saving/hdf5_format.py", line 188, in load_model_from_hdf5
    optimizer_weight_values = load_optimizer_weights_from_hdf5_group(f)
  File "/home/vl1019/miniconda3/envs/bvdev/lib/python3.6/site-packages/tensorflow_core/python/keras/saving/hdf5_format.py", line 601, in load_optimizer_weights_from_hdf5_group
    return [weights_group[weight_name] for weight_name in optimizer_weight_names]
  File "/home/vl1019/miniconda3/envs/bvdev/lib/python3.6/site-packages/tensorflow_core/python/keras/saving/hdf5_format.py", line 601, in <listcomp>
    return [weights_group[weight_name] for weight_name in optimizer_weight_names]
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "/home/vl1019/miniconda3/envs/bvdev/lib/python3.6/site-packages/h5py/_hl/group.py", line 264, in __getitem__
    oid = h5o.open(self.id, self._e(name), lapl=self._lapl)
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py/h5o.pyx", line 190, in h5py.h5o.open
KeyError: "Unable to open object (file read failed: time = Sun Jan 26 16:20:39 2020\n, filename = '/home/vl1019/birdvoxdetect/birdvoxdetect/models/birdvoxdetect-v03_trial-12_network_epoch-068.h5', file descriptor = 5, errno = 5, error message = 'Input/output error', buf = 0x563cf06ffd90, total read size = 704, bytes this sub-read = 704, bytes actually read = 18446744073709551615, offset = 5515120)"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "../../../src/011_birdvoxdetect-300h.py", line 61, in <module>
    export_confidence=True)
  File "/home/vl1019/birdvoxdetect/birdvoxdetect/core.py", line 113, in process_file
    raise BirdVoxDetectError(exc_formatted_str)
birdvoxdetect.birdvoxdetect_exceptions.BirdVoxDetectError: Could not open model "/home/vl1019/birdvoxdetect/birdvoxdetect/models/birdvoxdetect-v03_trial-12_network_epoch-068.h5":
Traceback (most recent call last):
  File "/home/vl1019/birdvoxdetect/birdvoxdetect/core.py", line 107, in process_file
    detector_model_path, custom_objects=custom_objects)
  File "/home/vl1019/miniconda3/envs/bvdev/lib/python3.6/site-packages/tensorflow_core/python/keras/saving/save.py", line 143, in load_model
    return hdf5_format.load_model_from_hdf5(filepath, custom_objects, compile)
  File "/home/vl1019/miniconda3/envs/bvdev/lib/python3.6/site-packages/tensorflow_core/python/keras/saving/hdf5_format.py", line 188, in load_model_from_hdf5
    optimizer_weight_values = load_optimizer_weights_from_hdf5_group(f)
  File "/home/vl1019/miniconda3/envs/bvdev/lib/python3.6/site-packages/tensorflow_core/python/keras/saving/hdf5_format.py", line 601, in load_optimizer_weights_from_hdf5_group
    return [weights_group[weight_name] for weight_name in optimizer_weight_names]
  File "/home/vl1019/miniconda3/envs/bvdev/lib/python3.6/site-packages/tensorflow_core/python/keras/saving/hdf5_format.py", line 601, in <listcomp>
    return [weights_group[weight_name] for weight_name in optimizer_weight_names]
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "/home/vl1019/miniconda3/envs/bvdev/lib/python3.6/site-packages/h5py/_hl/group.py", line 264, in __getitem__
    oid = h5o.open(self.id, self._e(name), lapl=self._lapl)
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py/h5o.pyx", line 190, in h5py.h5o.open
KeyError: "Unable to open object (file read failed: time = Sun Jan 26 16:20:39 2020\n, filename = '/home/vl1019/birdvoxdetect/birdvoxdetect/models/birdvoxdetect-v03_trial-12_network_epoch-068.h5', file descriptor = 5, errno = 5, error message = 'Input/output error', buf = 0x563cf06ffd90, total read size = 704, bytes this sub-read = 704, bytes actually read = 18446744073709551615, offset = 5515120)"

checklist bug when no flight calls are present in the first 30 minutes

caused by the hierarchical consistency PR
#73

Pandas drops DataFrame columns during concatenation

/home/vl1019/miniconda3/envs/bvd04/lib/python3.6/site-packages/pandas/core/frame.py:7123: FutureWarning: Sorting because non-concatenation axis is not aligned. A future version
of pandas will change to not sort by default.

To accept the future behavior, pass 'sort=False'.

To retain the current behavior and silence the warning, pass 'sort=True'.

  sort=sort,

triggered during the BV-300h usability test
specifically unit01/20150815004003_checklist.csv

must be fixed before 0.5

Pandas FutureWarning and concatenation bug

sequel of #79

/home/vl1019/miniconda3/envs/bvd04/lib/python3.6/site-packages/pandas/core/frame.py:7123: FutureWarning: Sorting because non-concatenation axis is not aligned. A future version
of pandas will change to not sort by default.

To accept the future behavior, pass 'sort=False'.

To retain the current behavior and silence the warning, pass 'sort=True'.

KeyError: 'Species (4-letter code)' when printing checklist count

Reported by Phil Taylor

I've put this file and other information in the same directory ... a late season (16 November 2020) file with probably no birds ... interestingly the checklist file doesn't output any species classification data ...

Again, the logger file has no data (I'll check tomorrow if I'm doing something wrong there ...

Here is the cmd I'm sending:

"python3 -m birdvoxdetect --predict-proba --export-logger /data/nbwind/audio2020final/StJohn/ForProcessing// -t 10"

Error txt:

birdvoxdetect: Processing: /data/nbwind/audio2020final/StJohn/ForProcessing//STJO_45.1679_-66.1796_2020-11-16-21-25-53.wav
Traceback (most recent call last):
File "/home/phil/.local/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 2891, in get_loc
return self._engine.get_loc(casted_key)
File "pandas/_libs/index.pyx", line 70, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/index.pyx", line 101, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/hashtable_class_helper.pxi", line 1675, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas/_libs/hashtable_class_helper.pxi", line 1683, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'Species (4-letter code)'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.7/dist-packages/birdvoxdetect/main.py", line 7, in
main()
File "/usr/local/lib/python3.7/dist-packages/birdvoxdetect/cli.py", line 260, in main
logger_level=logger_level,
File "/usr/local/lib/python3.7/dist-packages/birdvoxdetect/cli.py", line 96, in run
threshold=threshold,
File "/usr/local/lib/python3.7/dist-packages/birdvoxdetect/core.py", line 994, in process_file
df["Species (4-letter code)"]
File "/home/phil/.local/lib/python3.7/site-packages/pandas/core/frame.py", line 2902, in getitem
indexer = self.columns.get_loc(key)
File "/home/phil/.local/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 2893, in get_loc
raise KeyError(key) from err
KeyError: 'Species (4-letter code)'
[Process completed]
[Exit code: 1]
Phil Taylor
Acadia University, Wolfville, NS.

local variable 'has_sensor_fault' referenced before assignment

Hi,
I succesfully installed birdvoxdetect by running the pip command, but when I try to scan a wav audiofile I get this Python error:

[...]
File "/usr/local/lib/python3.6/dist-packages/birdvoxdetect/core.py", line 497, in process_file
if (n_chunks>1) and has_sensor_fault:
UnboundLocalError: local variable 'has_sensor_fault' referenced before assignment

Here's the complete --verbose output:

birdvoxdetect: Threshold = 50.0
birdvoxdetect: Processing: /home/plaf2000/Documenti/programmi_audio/test/allo_10min_mono.wav
2020-02-06 22:21:48.396617: E tensorflow/stream_executor/cuda/cuda_driver.cc:318] failed call to cuInit: UNKNOWN ERROR (303)
9109/9109 [==============================] - 19s 2ms/sample
Traceback (most recent call last):
File "/usr/local/bin/birdvoxdetect", line 8, in
sys.exit(main())
File "/usr/local/lib/python3.6/dist-packages/birdvoxdetect/cli.py", line 200, in main
logger_level=logger_level)
File "/usr/local/lib/python3.6/dist-packages/birdvoxdetect/cli.py", line 89, in run
logger_level=logger_level)
File "/usr/local/lib/python3.6/dist-packages/birdvoxdetect/core.py", line 497, in process_file
if (n_chunks>1) and has_sensor_fault:
UnboundLocalError: local variable 'has_sensor_fault' referenced before assignment

I see there's also a problem with the GPU's driver (mine is Intel, which I know doesn't work with CUDA).

I apologize for my inexperience and sorry if my English is not perfect.

Thank you!

Error with default detector, option/instructions to change it is missing

I installed birdvoxdetect via pip and have been trying it to process some .wav files, but this always results in error. Full error mesage at the end of this message.

From what I can tell from looking at the code is that the default detector "birdvoxdetect_pcen_cnn" will always result in this error (since it causes has_context is to be False, which causes concat_deque not to be set). Switching the detector does not seem possible using the command line interface. I got the system finally working by changing the detector name in core.py to "birdvoxdetect_pcen_cnn_adaptive-threshold-T1800".

  Traceback (most recent call last):
    File "/usr/local/bin/birdvoxdetect", line 8, in <module>
      sys.exit(main())
    File "/usr/local/lib/python3.5/dist-packages/birdvoxdetect/cli.py", line 193, in main
      logger_level=logger_level)
    File "/usr/local/lib/python3.5/dist-packages/birdvoxdetect/cli.py", line 88, in run
      logger_level=logger_level)
    File "/usr/local/lib/python3.5/dist-packages/birdvoxdetect/core.py", line 240, in process_file
      concat_deque = np.concatenate(deque, axis=1, out=concat_deque)
  UnboundLocalError: local variable 'concat_deque' referenced before assignment
  Exception ignored in: <object repr() failed>
  Traceback (most recent call last):
    File "/usr/local/lib/python3.5/dist-packages/soundfile.py", line 797, in __del__
    File "/usr/local/lib/python3.5/dist-packages/soundfile.py", line 1236, in close
    File "/usr/local/lib/python3.5/dist-packages/soundfile.py", line 1230, in flush
  AttributeError: 'NoneType' object has no attribute 'sf_write_sync'

TypeError: cannot unpack non-iterable NoneType object

Arose in a WAV file by Phil Taylor

 python3 -m birdvoxdetect --predict-proba --export-logger -t 10 CopyOfSTJO_45.1679_-66.1796_2020-09-24-22-46-48.wav -v

Logger:

birdvoxdetect: Processing: /Users/vl238/tmp/CopyOfSTJO_45.1679_-66.1796_2020-09-24-22-46-48.wav
285/285 [==============================] - 35s 123ms/step
285/285 [==============================] - 36s 127ms/step

...

285/285 [==============================] - 33s 116ms/step
285/285 [==============================] - 30s 105ms/step
Traceback (most recent call last):
  File "/Users/vl238/miniconda3/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/Users/vl238/miniconda3/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/vl238/miniconda3/lib/python3.7/site-packages/birdvoxdetect/__main__.py", line 7, in <module>
    main()
  File "/Users/vl238/miniconda3/lib/python3.7/site-packages/birdvoxdetect/cli.py", line 260, in main
    logger_level=logger_level,
  File "/Users/vl238/miniconda3/lib/python3.7/site-packages/birdvoxdetect/cli.py", line 96, in run
    threshold=threshold,
  File "/Users/vl238/miniconda3/lib/python3.7/site-packages/birdvoxdetect/core.py", line 641, in process_file
    classifier, chunk_pcen, th_peak_loc, taxonomy)
TypeError: cannot unpack non-iterable NoneType object

Keyword arguments and their defaults

  • -o output directory. Default: same as input.

  • -w export WAV audio clips of positive detections to a subfolder. Default: false. NB: this needs to be set to true in order to perform species classification downstream. Each WAV clip belongs to a subfolder named inputfile_suffix_clips and is named inputfile_timestamp_confidence.wav. Timestamps are rounded to the nearest millisecond. Confidences range between 00 and 99.

  • -t: threshold between 0 and 99. Default 50. With a value like that we should be able to guarantee at least 75% on recall and 65% precision in v1.0.0 (and possibly more later on). I will map these values to a nonlinear range in the event detection function domain so that values between 20 and 80 are reasonable. It would be best to warn users if they try to go above 90, because that would cause to have a precision under 30%. These values are indicative of the average performance of BirdVoxDetect on the leave-one-sensor-out test set of BirdVox-full-night. It would be good to put a PR curve in the README that gives recommended values of -t for the intended values of precision and recall.

  • -h: export detection curve in HDF5 format.

  • -x suffix. Like in Open-L3.

  • -t hop size in milliseconds. Default: 50. Values should be between 0 and 75 (otherwise we might miss portions of the audio input)

  • -d duration of the exported WAV audio clip in milliseconds. Default: 500.

  • -q quiet. Default: false in command line but true in Python library

ValueError: Output array is the wrong shape

Traceback (most recent call last):
  File "../../../../src/016_birdvoxdetect-full-season-ca.py", line 61, in <module>
    export_confidence=False)
  File "/home/vl1019/miniconda3/envs/bvd021/lib/python3.6/site-packages/birdvoxdetect/core.py", line 547, in process_file
    concat_deque = np.concatenate(deque, axis=1, out=concat_deque)
ValueError: Output array is the wrong shape

TaxoNet

triaged for v0.4
made possible by birdvoxclassify v0.1.1

birdvoxclassify.birdvoxclassify_exceptions.BirdVoxClassifyError: Invalid number of frames in input PCEN. Expected 104 but got 0.

2020-02-12 21:34:56.071495 Start.
Running BirdVoxDetect (with CA) on BirdVox-full-season.
WAV name: 2015-09-16_08-00-00_unit02.wav.

birdvoxdetect version: 0.2.2
h5py version: 2.10.0
librosa version: 0.7.0
numpy version: 1.16.4
pandas version: 0.25.1
resampy version: 0.2.2
scipy version: 1.4.1
soundfile version: 0.10.3
tensorflow version: 1.15.2

Traceback (most recent call last):
  File "../../../../src/016_birdvoxdetect-full-season-ca.py", line 61, in <module>
    export_confidence=False)
  File "/home/vl1019/miniconda3/envs/bvd022/lib/python3.6/site-packages/birdvoxdetect/core.py", line 458, in process_file
    th_peak_locs))
  File "/home/vl1019/miniconda3/envs/bvd022/lib/python3.6/site-packages/birdvoxdetect/core.py", line 457, in <lambda>
    lambda x: classify_species(classifier, chunk_pcen, x, taxonomy),
  File "/home/vl1019/miniconda3/envs/bvd022/lib/python3.6/site-packages/birdvoxdetect/core.py", line 719, in classify_species
    birdvoxclassify.predict(pcen_clip, classifier=classifier),
  File "/home/vl1019/miniconda3/envs/bvd022/lib/python3.6/site-packages/birdvoxclassify/core.py", line 489, in predict
    pcen.shape[2]
birdvoxclassify.birdvoxclassify_exceptions.BirdVoxClassifyError: Invalid number of frames in input PCEN. Expected 104 but got 0.

formatting error in birdvoxactivate

Backtrace:

2020-01-21 12:26:50.556310 Start.
Running BirdVoxDetect on BirdVox-300h.
WAV name: 2015-10-21_00-00-00_unit08.wav.

birdvoxdetect version: 0.2.0a2
h5py version: 2.10.0
librosa version: 0.7.0
numpy version: 1.16.4
pandas version: 0.25.1
resampy version: 0.2.2
scipy version: 1.4.1
soundfile version: 0.9.0
tensorflow version: 1.15.0

Traceback (most recent call last):
  File "../../../src/011_birdvoxdetect-300h.py", line 61, in <module>
    export_confidence=True)
  File "/home/vl1019/miniconda3/envs/bvd02a2/lib/python3.6/site-packages/birdvoxdetect/core.py", line 383, in process_file
    100*sensor_fault_probability))
TypeError: unsupported format string passed to numpy.ndarray.__format__

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.