Skip to content

Commit a887626

Browse files
Release 230 (#802)
* Release 2.3.0 * . * . * spectrogram gets generated for query sample * . * . * model saving * . * . * decode error_log.txt manually because of some weird chars * . --------- Co-authored-by: Max Mauermann <max-mauermann@web.de> Co-authored-by: max-mauermann <40059289+max-mauermann@users.noreply.github.com>
1 parent 9ec4301 commit a887626

19 files changed

Lines changed: 114 additions & 71 deletions

File tree

birdnet_analyzer/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
import os
22
import warnings
33

4-
from absl import logging
5-
64
from birdnet_analyzer.analyze import analyze
75
from birdnet_analyzer.embeddings import embeddings
86
from birdnet_analyzer.search import search
97
from birdnet_analyzer.segments import segments
108
from birdnet_analyzer.species import species
119
from birdnet_analyzer.train import train
1210

13-
__version__ = "2.2.0"
11+
__version__ = "2.3.0"
1412
__all__ = ["analyze", "embeddings", "search", "segments", "species", "train"]
1513
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"
14+
os.environ["WRAPT_DISABLE_EXTENSIONS"] = "true"
1615

17-
logging.set_verbosity(logging.ERROR)
1816
warnings.filterwarnings("ignore")

birdnet_analyzer/analyze/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,10 @@ def _set_params(
227227

228228
if cfg.USE_PERCH:
229229
cfg.MODEL_PATH = cfg.PERCH_V2_MODEL_PATH
230-
cfg.LABELS_FILE = cfg.PERCH_LABELS_FILE
230+
cfg.LABELS_FILE = cfg.perch_labels_file()
231231
cfg.SAMPLE_RATE = cfg.PERCH_SAMPLE_RATE
232232
cfg.SIG_LENGTH = cfg.PERCH_SIG_LENGTH
233-
cfg.LABELS = read_lines(cfg.PERCH_LABELS_FILE)
233+
cfg.LABELS = read_lines(cfg.LABELS_FILE)
234234
cfg.LABELS = cfg.LABELS[1:] # it's a csv with header
235235
else:
236236
cfg.MODEL_PATH = cfg.BIRDNET_MODEL_PATH

birdnet_analyzer/config.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,3 +258,11 @@ def get_config():
258258
def set_config(c: dict):
259259
for k, v in c.items():
260260
globals()[k] = v
261+
262+
263+
#####################
264+
# Convenience funcs #
265+
#####################
266+
267+
def perch_labels_file():
268+
return os.path.join(PERCH_V2_MODEL_PATH, "assets", "labels.csv")

birdnet_analyzer/gui/search.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def on_db_selection_click():
259259
[],
260260
{},
261261
gr.Button(visible=True),
262-
gr.Textbox(value=None, visible=False),
262+
gr.Textbox(value=None, visible=True),
263263
)
264264

265265
return None, None, None, None, [], {}, gr.Button(visible=False), gr.Textbox(visible=False)
@@ -313,6 +313,7 @@ def update_query_spectrogram(audiofilepath, db_selection, crop_mode, crop_overla
313313
outputs=[query_spectrogram, results_state, export_state],
314314
preprocess=False,
315315
)
316+
316317
query_sample_tb.change(
317318
update_query_spectrogram,
318319
inputs=[query_sample_tb, db_selection_tb, crop_mode, crop_overlap],

birdnet_analyzer/gui/utils.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import io
44
import multiprocessing
55
import os
6+
import platform
67
import sys
78
import warnings
89
from collections.abc import Callable
@@ -300,9 +301,10 @@ def on_theme_change(value):
300301

301302
def on_tab_select(value: gr.SelectData):
302303
if value.selected and os.path.exists(cfg.ERROR_LOG_FILE):
303-
with open(cfg.ERROR_LOG_FILE, encoding="utf-8") as f:
304-
lines = f.readlines()
304+
with open(cfg.ERROR_LOG_FILE, mode="rb") as f:
305+
lines = [line.decode("utf-8", errors="ignore") for line in f]
305306
last_100_lines = lines[-100:]
307+
306308
return "".join(last_100_lines)
307309

308310
return ""
@@ -614,8 +616,13 @@ def species_lists(opened=True) -> dict[_SPECIES_KEYS, gr.components.Component]:
614616
A dict with the created elements.
615617
"""
616618
with gr.Accordion(loc.localize("species-list-accordion-label"), open=opened), gr.Row():
619+
values = [_CUSTOM_SPECIES, _PREDICT_SPECIES, _CUSTOM_CLASSIFIER, _ALL_SPECIES, _USE_PERCH]
620+
621+
if platform.system() == "Darwin":
622+
values.pop() # TODO: Remove when tf 2.21+ is available on macOS
623+
617624
species_list_radio = gr.Radio(
618-
[_CUSTOM_SPECIES, _PREDICT_SPECIES, _CUSTOM_CLASSIFIER, _ALL_SPECIES, _USE_PERCH],
625+
values,
619626
value=_ALL_SPECIES,
620627
label=loc.localize("species-list-radio-label"),
621628
info=loc.localize("species-list-radio-info"),
@@ -689,13 +696,21 @@ def download_plot(plot, filename=""):
689696
)
690697

691698
if res:
692-
if res.endswith(".webp"):
699+
if isinstance(res, list | tuple):
700+
res = res[0]
701+
702+
file_ext = res.split(".", 1)[-1].upper()
703+
704+
if file_ext == "WEBP":
693705
with open(res, "wb") as f:
694706
f.write(imgdata)
695707
else:
696-
output_format = res.rsplit(".", 1)[-1].upper()
708+
if file_ext not in ["PNG", "JPEG"]:
709+
file_ext = "PNG"
710+
res += ".png"
711+
697712
img = Image.open(io.BytesIO(imgdata))
698-
img.save(res, output_format if output_format in ["PNG", "JPEG"] else "PNG")
713+
img.save(res, file_ext)
699714

700715

701716
def _get_network_shortcuts():

birdnet_analyzer/lang/de.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@
258258
"species-list-radio-option-custom-classifier": "Benutzerdefinierter Klassifikator",
259259
"species-list-radio-option-custom-list": "Benutzerdefinierte Artenliste",
260260
"species-list-radio-option-predict-list": "Arten nach Standort",
261-
"species-list-radio-option-use-perch": "Perch v2",
261+
"species-list-radio-option-use-perch": "Perch v2 (preview)",
262262
"species-tab-filename-textbox-label": "Name der Datei, wenn nicht angegeben, wird 'species_list.txt' verwendet.",
263263
"species-tab-finish-info": "Artenliste gespeichert unter",
264264
"species-tab-select-output-directory-button-label": "Wählen Sie das Ausgabeverzeichnis",

birdnet_analyzer/lang/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@
258258
"species-list-radio-option-custom-classifier": "Custom classifier",
259259
"species-list-radio-option-custom-list": "Custom species list",
260260
"species-list-radio-option-predict-list": "Species by location",
261-
"species-list-radio-option-use-perch": "Perch v2",
261+
"species-list-radio-option-use-perch": "Perch v2 (preview)",
262262
"species-tab-filename-textbox-label": "Name of the file, if not specified 'species_list.txt' will be used.",
263263
"species-tab-finish-info": "Species list saved at",
264264
"species-tab-select-output-directory-button-label": "Select output directory",

birdnet_analyzer/lang/fi.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@
258258
"species-list-radio-option-custom-classifier": "Mukautettu luokittelija",
259259
"species-list-radio-option-custom-list": "Mukautettu lajilista",
260260
"species-list-radio-option-predict-list": "Lajit sijainnin mukaan",
261-
"species-list-radio-option-use-perch": "Perch v2",
261+
"species-list-radio-option-use-perch": "Perch v2 (preview)",
262262
"species-tab-filename-textbox-label": "Tiedoston nimi, jos ei määritetty, käytetään nimeä 'species_list.txt'.",
263263
"species-tab-finish-info": "Lajilista tallennettu kohteeseen",
264264
"species-tab-select-output-directory-button-label": "Valitse tulostehakemisto",

birdnet_analyzer/lang/fr.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@
258258
"species-list-radio-option-custom-classifier": "Classificateur personnalisé",
259259
"species-list-radio-option-custom-list": "Liste des espèces personnalisées",
260260
"species-list-radio-option-predict-list": "Espèces par lieu",
261-
"species-list-radio-option-use-perch": "Perch v2",
261+
"species-list-radio-option-use-perch": "Perch v2 (preview)",
262262
"species-tab-filename-textbox-label": "Nom du fichier, si non spécifié « species_list.txt » sera utilisé.",
263263
"species-tab-finish-info": "La liste des espèces est sauvegardé à l’adresse:",
264264
"species-tab-select-output-directory-button-label": "Sélectionner un dossier de sortie",

birdnet_analyzer/lang/id.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@
258258
"species-list-radio-option-custom-classifier": "Klasifikator kustom",
259259
"species-list-radio-option-custom-list": "Daftar spesies kustom",
260260
"species-list-radio-option-predict-list": "Spesies berdasarkan lokasi",
261-
"species-list-radio-option-use-perch": "Perch v2",
261+
"species-list-radio-option-use-perch": "Perch v2 (preview)",
262262
"species-tab-filename-textbox-label": "Nama file, jika tidak ditentukan 'daftar_spesies.txt' akan digunakan.",
263263
"species-tab-finish-info": "Daftar spesies disimpan di",
264264
"species-tab-select-output-directory-button-label": "Pilih output direktori",

0 commit comments

Comments
 (0)