Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT proposal : convert species on the fly #57

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scripts/clear_all_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ echo "Re-creating necessary directories"

sudo -u ${USER} ln -fs $(dirname $my_dir)/exclude_species_list.txt $my_dir
sudo -u ${USER} ln -fs $(dirname $my_dir)/include_species_list.txt $my_dir
sudo -u ${USER} ln -fs $(dirname $my_dir)/convert_species_list.txt $my_dir
sudo -u ${USER} ln -fs $(dirname $my_dir)/homepage/* ${EXTRACTED}
sudo -u ${USER} ln -fs $(dirname $my_dir)/model/labels.txt ${my_dir}
sudo -u ${USER} ln -fs $my_dir ${EXTRACTED}
Expand Down
1 change: 1 addition & 0 deletions scripts/install_services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ create_necessary_dirs() {
[ -L ${EXTRACTED}/spectrogram.png ] || sudo -u ${USER} ln -sf ${RECS_DIR}/StreamData/spectrogram.png ${EXTRACTED}/spectrogram.png

sudo -u ${USER} ln -fs $my_dir/exclude_species_list.txt $my_dir/scripts
sudo -u ${USER} ln -fs $my_dir/convert_species_list.txt $my_dir/scripts
sudo -u ${USER} ln -fs $my_dir/include_species_list.txt $my_dir/scripts
sudo -u ${USER} ln -fs $my_dir/homepage/* ${EXTRACTED}
sudo -u ${USER} ln -fs $my_dir/model/labels.txt ${my_dir}/scripts
Expand Down
12 changes: 10 additions & 2 deletions scripts/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


userDir = os.path.expanduser('~')
INTERPRETER, M_INTERPRETER, INCLUDE_LIST, EXCLUDE_LIST = (None, None, None, None)
INTERPRETER, M_INTERPRETER, INCLUDE_LIST, EXCLUDE_LIST, CONVERT_LIST = (None, None, None, None, None)
PREDICTED_SPECIES_LIST = []
model, priv_thresh, sf_thresh = (None, None, None)

Expand Down Expand Up @@ -307,9 +307,10 @@ def load_global_model():


def run_analysis(file):
global INCLUDE_LIST, EXCLUDE_LIST
global INCLUDE_LIST, EXCLUDE_LIST, CONVERT_LIST
INCLUDE_LIST = loadCustomSpeciesList(os.path.expanduser("~/BirdNET-Pi/include_species_list.txt"))
EXCLUDE_LIST = loadCustomSpeciesList(os.path.expanduser("~/BirdNET-Pi/exclude_species_list.txt"))
CONVERT_LIST = loadCustomSpeciesList(os.path.expanduser("~/BirdNET-Pi/convert_species_list.txt"))

conf = get_settings()

Expand All @@ -327,6 +328,13 @@ def run_analysis(file):
for time_slot, entries in raw_detections.items():
log.info('%s-%s', time_slot, entries[0])
for entry in entries:
# Check if the user has requested to replace a specie by another for bias correction
if len(EXCLUDE_LIST) != 0:
for convert_entry in CONVERT_LIST:
parts = convert_entry.split(';')
if entry[1] == parts[0]:
entry[1] = parts[1]
break
if entry[1] >= conf.getfloat('CONFIDENCE') and ((entry[0] in INCLUDE_LIST or len(INCLUDE_LIST) == 0)
and (entry[0] not in EXCLUDE_LIST or len(EXCLUDE_LIST) == 0)
and (entry[0] in PREDICTED_SPECIES_LIST
Expand Down
Loading