Skip to content

Commit f881fd7

Browse files
committed
Merge branch 'main' into segments-collection-mode
2 parents c891141 + ad98398 commit f881fd7

28 files changed

Lines changed: 4048 additions & 65 deletions

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ jobs:
2222
python-version: ["3.11"]
2323
steps:
2424
- uses: actions/checkout@v4
25+
with:
26+
submodules: true
2527
- name: Set up Python ${{ matrix.python-version }}
2628
uses: actions/setup-python@v5
2729
with:

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "tests/data"]
2+
path = tests/data
3+
url = https://github.com/birdnet-team/birdnet-test-data.git

CONTRIBUTING.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
### Testdata (optional)
2+
3+
This project uses a submodule for its testdata.
4+
5+
If you want to run the tests locally you need to initialize the submodule:
6+
7+
```bash
8+
git submodule update --init --recursive
9+
```
10+
11+
Or checkout the submodule during cloning:
12+
13+
```bash
14+
git clone --recurse-submodules https://github.com/birdnet-team/BirdNET-Analyzer.git
15+
```
16+
17+
If the testdata has changed and you want to update the repo to use the new current testdata follow these steps:
18+
19+
```bash
20+
cd tests/data
21+
git pull origin main
22+
cd ..
23+
git add data
24+
git commit -m "Update testdata"
25+
git push
26+
```
27+
28+
This will set up the repo to use the current ref of the submodule.
29+
30+
**Note**: If you wan to add data you do so by either checking out the submodule as a regular repo and just add-commit-push from there or use the subdirectory containing the submodule like a regular git repository (don't forget to manually update the ref in the main repo)

birdnet_analyzer/analyze/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,10 @@ def _set_params(
219219
if custom_classifier.endswith(".tflite"):
220220
cfg.LABELS_FILE = custom_classifier.replace(".tflite", "_Labels.txt") # same for labels file
221221

222-
if not os.path.isfile(cfg.LABELS_FILE):
222+
if not os.path.isfile(cfg.LABELS_FILE): # if the label file is not found, an old birdnet model might be used
223223
cfg.LABELS_FILE = custom_classifier.replace("Model_FP32.tflite", "Labels.txt")
224224

225-
if not custom_classifier.endswith("Model_FP32.tflite") or not os.path.isfile(cfg.LABELS_FILE):
225+
if not os.path.isfile(cfg.LABELS_FILE): # if the label file is still not found, dont use labels
226226
cfg.LABELS_FILE = None
227227
cfg.LABELS = None
228228
else:

birdnet_analyzer/analyze/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ def generate_csv(timestamps: list[str], result: dict[str, list], afile_path: str
208208
columns_map = {}
209209

210210
if cfg.ADDITIONAL_COLUMNS:
211-
for col in cfg.ADDITIONAL_COLUMNS:
212-
if col in POSSIBLE_ADDITIONAL_COLUMNS_MAP:
211+
for col in POSSIBLE_ADDITIONAL_COLUMNS_MAP:
212+
if col in cfg.ADDITIONAL_COLUMNS:
213213
columns_map[col] = POSSIBLE_ADDITIONAL_COLUMNS_MAP[col]()
214214

215215
if columns_map:

birdnet_analyzer/embeddings/utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ def analyze_file(item, db: sqlite_usearch_impl.SQLiteUsearchDB):
5050

5151
# Insert into database
5252
db.insert_embedding(embeddings, embeddings_source)
53-
db.commit()
54-
53+
db.commit()
5554
except Exception as ex:
5655
# Write error log
5756
print(f"Error: Cannot analyze audio file {fpath}.", flush=True)

birdnet_analyzer/gui/embeddings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,15 @@ def select_directory_to_state_and_tb(state_key):
212212
minimum=1,
213213
interactive=True,
214214
)
215+
215216
threads_number = gr.Number(
216217
precision=1,
217218
label=loc.localize("embedding-settings-threads-number-label"),
218219
value=4,
219220
info=loc.localize("embedding-settings-threads-number-info"),
220221
minimum=1,
221222
interactive=True,
223+
visible=False, # Threads are currently not used as its not compatible with
222224
)
223225

224226
with gr.Row():

birdnet_analyzer/gui/multi_file.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"Model file": "model",
2323
}
2424

25+
2526
@gu.gui_runtime_error_handler
2627
def run_batch_analysis(
2728
output_path,
@@ -64,7 +65,7 @@ def run_batch_analysis(
6465
if fmin is None or fmax is None or fmin < cfg.SIG_FMIN or fmax > cfg.SIG_FMAX or fmin > fmax:
6566
raise gr.Error(f"{loc.localize('validation-no-valid-frequency')} [{cfg.SIG_FMIN}, {cfg.SIG_FMAX}]")
6667

67-
return run_analysis(
68+
results = run_analysis(
6869
None,
6970
output_path,
7071
use_top_n,
@@ -96,6 +97,8 @@ def run_batch_analysis(
9697
progress,
9798
)
9899

100+
return [path for path, successful in results if not successful]
101+
99102

100103
def build_multi_analysis_tab():
101104
with gr.Tab(loc.localize("multi-tab-title")):
@@ -219,7 +222,6 @@ def select_directory_wrapper(): # Nishant - Function modified for For Folder se
219222
result_grid = gr.Matrix(
220223
headers=[
221224
loc.localize("multi-tab-result-dataframe-column-file-header"),
222-
loc.localize("multi-tab-result-dataframe-column-execution-header"),
223225
],
224226
)
225227

birdnet_analyzer/gui/utils.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import multiprocessing
55
import os
66
import sys
7+
import warnings
78
from collections.abc import Callable
89
from contextlib import suppress
910
from pathlib import Path
@@ -16,6 +17,7 @@
1617
from birdnet_analyzer import utils
1718
from birdnet_analyzer.gui import settings
1819

20+
warnings.filterwarnings("ignore")
1921
loc.load_local_state()
2022

2123
SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__))
@@ -605,10 +607,10 @@ def on_custom_classifier_selection_click():
605607
if not os.path.isfile(labels):
606608
labels = file.replace("Model_FP32.tflite", "Labels.txt")
607609

608-
if not file.endswith("Model_FP32.tflite") or not os.path.isfile(labels):
609-
gr.Warning(loc.localize("species-list-custom-classifier-no-labelfile-warning"))
610+
if not os.path.isfile(labels):
611+
gr.Warning(loc.localize("species-list-custom-classifier-no-labelfile-warning"))
610612

611-
return file, gr.File(value=[file], visible=True)
613+
return file, gr.File(value=[file], visible=True)
612614

613615
return file, gr.File(value=[file, labels], visible=True)
614616

birdnet_analyzer/lang/de.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,7 @@
152152
"multi-tab-output-selection-button-label": "Ausgabeverzeichnis auswählen",
153153
"multi-tab-output-textbox-label": "Ausgabeverzeichnis",
154154
"multi-tab-output-textbox-placeholder": "Wenn nicht ausgewählt, wird das Eingabeverzeichnis verwendet.",
155-
"multi-tab-result-dataframe-column-execution-header": "Ausführung",
156-
"multi-tab-result-dataframe-column-file-header": "Datei",
155+
"multi-tab-result-dataframe-column-file-header": "Ungültige Audiodateien",
157156
"multi-tab-samples-dataframe-column-duration-header": "Länge",
158157
"multi-tab-samples-dataframe-column-subpath-header": "Unterpfad",
159158
"multi-tab-samples-dataframe-no-files-found": "Keine Dateien gefunden",

0 commit comments

Comments
 (0)