birdnet-analyzer 2.1.0__py3-none-any.whl → 2.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. birdnet_analyzer/__init__.py +9 -9
  2. birdnet_analyzer/analyze/__init__.py +19 -19
  3. birdnet_analyzer/analyze/__main__.py +3 -3
  4. birdnet_analyzer/analyze/cli.py +30 -30
  5. birdnet_analyzer/analyze/core.py +268 -246
  6. birdnet_analyzer/analyze/utils.py +700 -694
  7. birdnet_analyzer/audio.py +368 -368
  8. birdnet_analyzer/cli.py +732 -732
  9. birdnet_analyzer/config.py +243 -243
  10. birdnet_analyzer/eBird_taxonomy_codes_2024E.json +13045 -13045
  11. birdnet_analyzer/embeddings/__init__.py +3 -3
  12. birdnet_analyzer/embeddings/__main__.py +3 -3
  13. birdnet_analyzer/embeddings/cli.py +12 -12
  14. birdnet_analyzer/embeddings/core.py +70 -70
  15. birdnet_analyzer/embeddings/utils.py +173 -220
  16. birdnet_analyzer/evaluation/__init__.py +189 -189
  17. birdnet_analyzer/evaluation/__main__.py +3 -3
  18. birdnet_analyzer/evaluation/assessment/metrics.py +388 -388
  19. birdnet_analyzer/evaluation/assessment/performance_assessor.py +364 -364
  20. birdnet_analyzer/evaluation/assessment/plotting.py +378 -378
  21. birdnet_analyzer/evaluation/preprocessing/data_processor.py +631 -631
  22. birdnet_analyzer/evaluation/preprocessing/utils.py +98 -98
  23. birdnet_analyzer/gui/__init__.py +19 -19
  24. birdnet_analyzer/gui/__main__.py +3 -3
  25. birdnet_analyzer/gui/analysis.py +179 -179
  26. birdnet_analyzer/gui/assets/arrow_down.svg +4 -4
  27. birdnet_analyzer/gui/assets/arrow_left.svg +4 -4
  28. birdnet_analyzer/gui/assets/arrow_right.svg +4 -4
  29. birdnet_analyzer/gui/assets/arrow_up.svg +4 -4
  30. birdnet_analyzer/gui/assets/gui.css +36 -36
  31. birdnet_analyzer/gui/assets/gui.js +89 -93
  32. birdnet_analyzer/gui/embeddings.py +638 -638
  33. birdnet_analyzer/gui/evaluation.py +801 -801
  34. birdnet_analyzer/gui/localization.py +75 -75
  35. birdnet_analyzer/gui/multi_file.py +265 -265
  36. birdnet_analyzer/gui/review.py +472 -472
  37. birdnet_analyzer/gui/segments.py +191 -191
  38. birdnet_analyzer/gui/settings.py +149 -149
  39. birdnet_analyzer/gui/single_file.py +264 -264
  40. birdnet_analyzer/gui/species.py +95 -95
  41. birdnet_analyzer/gui/train.py +687 -687
  42. birdnet_analyzer/gui/utils.py +803 -797
  43. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_af.txt +6522 -6522
  44. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_ar.txt +6522 -6522
  45. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_bg.txt +6522 -6522
  46. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_ca.txt +6522 -6522
  47. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_cs.txt +6522 -6522
  48. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_da.txt +6522 -6522
  49. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_de.txt +6522 -6522
  50. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_el.txt +6522 -6522
  51. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_en_uk.txt +6522 -6522
  52. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_es.txt +6522 -6522
  53. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_fi.txt +6522 -6522
  54. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_fr.txt +6522 -6522
  55. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_he.txt +6522 -6522
  56. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_hr.txt +6522 -6522
  57. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_hu.txt +6522 -6522
  58. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_in.txt +6522 -6522
  59. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_is.txt +6522 -6522
  60. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_it.txt +6522 -6522
  61. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_ja.txt +6522 -6522
  62. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_ko.txt +6522 -6522
  63. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_lt.txt +6522 -6522
  64. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_ml.txt +6522 -6522
  65. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_nl.txt +6522 -6522
  66. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_no.txt +6522 -6522
  67. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_pl.txt +6522 -6522
  68. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_pt_BR.txt +6522 -6522
  69. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_pt_PT.txt +6522 -6522
  70. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_ro.txt +6522 -6522
  71. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_ru.txt +6522 -6522
  72. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_sk.txt +6522 -6522
  73. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_sl.txt +6522 -6522
  74. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_sr.txt +6522 -6522
  75. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_sv.txt +6522 -6522
  76. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_th.txt +6522 -6522
  77. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_tr.txt +6522 -6522
  78. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_uk.txt +6522 -6522
  79. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_zh.txt +6522 -6522
  80. birdnet_analyzer/lang/de.json +342 -341
  81. birdnet_analyzer/lang/en.json +342 -341
  82. birdnet_analyzer/lang/fi.json +342 -341
  83. birdnet_analyzer/lang/fr.json +342 -341
  84. birdnet_analyzer/lang/id.json +342 -341
  85. birdnet_analyzer/lang/pt-br.json +342 -341
  86. birdnet_analyzer/lang/ru.json +342 -341
  87. birdnet_analyzer/lang/se.json +342 -341
  88. birdnet_analyzer/lang/tlh.json +342 -341
  89. birdnet_analyzer/lang/zh_TW.json +342 -341
  90. birdnet_analyzer/model.py +1213 -1212
  91. birdnet_analyzer/search/__init__.py +3 -3
  92. birdnet_analyzer/search/__main__.py +3 -3
  93. birdnet_analyzer/search/cli.py +11 -11
  94. birdnet_analyzer/search/core.py +78 -78
  95. birdnet_analyzer/search/utils.py +104 -107
  96. birdnet_analyzer/segments/__init__.py +3 -3
  97. birdnet_analyzer/segments/__main__.py +3 -3
  98. birdnet_analyzer/segments/cli.py +13 -13
  99. birdnet_analyzer/segments/core.py +81 -81
  100. birdnet_analyzer/segments/utils.py +383 -383
  101. birdnet_analyzer/species/__init__.py +3 -3
  102. birdnet_analyzer/species/__main__.py +3 -3
  103. birdnet_analyzer/species/cli.py +13 -13
  104. birdnet_analyzer/species/core.py +35 -35
  105. birdnet_analyzer/species/utils.py +73 -74
  106. birdnet_analyzer/train/__init__.py +3 -3
  107. birdnet_analyzer/train/__main__.py +3 -3
  108. birdnet_analyzer/train/cli.py +13 -13
  109. birdnet_analyzer/train/core.py +113 -113
  110. birdnet_analyzer/train/utils.py +878 -877
  111. birdnet_analyzer/translate.py +132 -133
  112. birdnet_analyzer/utils.py +425 -425
  113. {birdnet_analyzer-2.1.0.dist-info → birdnet_analyzer-2.1.1.dist-info}/METADATA +147 -146
  114. birdnet_analyzer-2.1.1.dist-info/RECORD +124 -0
  115. {birdnet_analyzer-2.1.0.dist-info → birdnet_analyzer-2.1.1.dist-info}/licenses/LICENSE +18 -18
  116. birdnet_analyzer/playground.py +0 -5
  117. birdnet_analyzer-2.1.0.dist-info/RECORD +0 -125
  118. {birdnet_analyzer-2.1.0.dist-info → birdnet_analyzer-2.1.1.dist-info}/WHEEL +0 -0
  119. {birdnet_analyzer-2.1.0.dist-info → birdnet_analyzer-2.1.1.dist-info}/entry_points.txt +0 -0
  120. {birdnet_analyzer-2.1.0.dist-info → birdnet_analyzer-2.1.1.dist-info}/top_level.txt +0 -0
@@ -1,243 +1,243 @@
1
- import os
2
-
3
- SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__))
4
-
5
- #################
6
- # Misc settings #
7
- #################
8
-
9
- # Random seed for gaussian noise
10
- RANDOM_SEED: int = 42
11
-
12
- ##########################
13
- # Model paths and config #
14
- ##########################
15
-
16
- MODEL_VERSION: str = "V2.4"
17
- PB_MODEL: str = os.path.join(SCRIPT_DIR, "checkpoints/V2.4/BirdNET_GLOBAL_6K_V2.4_Model")
18
- # MODEL_PATH = PB_MODEL # This will load the protobuf model
19
- MODEL_PATH: str = os.path.join(SCRIPT_DIR, "checkpoints/V2.4/BirdNET_GLOBAL_6K_V2.4_Model_FP32.tflite")
20
- MDATA_MODEL_PATH: str = os.path.join(SCRIPT_DIR, "checkpoints/V2.4/BirdNET_GLOBAL_6K_V2.4_MData_Model_V2_FP16.tflite")
21
- LABELS_FILE: str = os.path.join(SCRIPT_DIR, "checkpoints/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels.txt")
22
- TRANSLATED_LABELS_PATH: str = os.path.join(SCRIPT_DIR, "labels/V2.4")
23
-
24
- ##################
25
- # Audio settings #
26
- ##################
27
-
28
- # We use a sample rate of 48kHz, so the model input size is
29
- # (batch size, 48000 kHz * 3 seconds) = (1, 144000)
30
- # Recordings will be resampled automatically.
31
- SAMPLE_RATE: int = 48000
32
-
33
- # We're using 3-second chunks
34
- SIG_LENGTH: float = 3.0
35
-
36
- # Define overlap between consecutive chunks <3.0; 0 = no overlap
37
- SIG_OVERLAP: float = 0
38
-
39
- # Define minimum length of audio chunk for prediction,
40
- # chunks shorter than 3 seconds will be padded with zeros
41
- SIG_MINLEN: float = 1.0
42
-
43
- # Frequency range. This is model specific and should not be changed.
44
- SIG_FMIN: int = 0
45
- SIG_FMAX: int = 15000
46
-
47
- # Settings for bandpass filter
48
- BANDPASS_FMIN: int = 0
49
- BANDPASS_FMAX: int = 15000
50
-
51
- # Top N species to display in selection table, ignored if set to None
52
- TOP_N = None
53
-
54
- # Audio speed
55
- AUDIO_SPEED: float = 1.0
56
-
57
- #####################
58
- # Metadata settings #
59
- #####################
60
-
61
- LATITUDE: float = -1
62
- LONGITUDE: float = -1
63
- WEEK: int = -1
64
- LOCATION_FILTER_THRESHOLD: float = 0.03
65
-
66
- ######################
67
- # Inference settings #
68
- ######################
69
-
70
- # If None or empty file, no custom species list will be used
71
- # Note: Entries in this list have to match entries from the LABELS_FILE
72
- # We use the 2024 eBird taxonomy for species names (Clements list)
73
- CODES_FILE: str = os.path.join(SCRIPT_DIR, "eBird_taxonomy_codes_2024E.json")
74
- SPECIES_LIST_FILE: str = os.path.join(SCRIPT_DIR, "example/species_list.txt")
75
-
76
- # Supported file types
77
- ALLOWED_FILETYPES: list[str] = ["wav", "flac", "mp3", "ogg", "m4a", "wma", "aiff", "aif"]
78
-
79
- # Number of threads to use for inference.
80
- # Can be as high as number of CPUs in your system
81
- CPU_THREADS: int = 8
82
- TFLITE_THREADS: int = 1
83
-
84
- # False will output logits, True will convert to sigmoid activations
85
- APPLY_SIGMOID: bool = True
86
- SIGMOID_SENSITIVITY: float = 1.0
87
-
88
- # Minimum confidence score to include in selection table
89
- # (be aware: if APPLY_SIGMOID = False, this no longer represents
90
- # probabilities and needs to be adjusted)
91
- MIN_CONFIDENCE: float = 0.25
92
-
93
- # Number of consecutive detections for one species to merge into one
94
- # If set to 1 or 0, no merging will be done
95
- # If set to None, all detections will be included
96
- MERGE_CONSECUTIVE: int = 1
97
-
98
- # Number of samples to process at the same time. Higher values can increase
99
- # processing speed, but will also increase memory usage.
100
- # Might only be useful for GPU inference.
101
- BATCH_SIZE: int = 1
102
-
103
-
104
- # Number of seconds to load from a file at a time
105
- # Files will be loaded into memory in segments that are only as long as this value
106
- # Lowering this value results in lower memory usage
107
- FILE_SPLITTING_DURATION: int = 600
108
-
109
- # Whether to use noise to pad the signal
110
- # If set to False, the signal will be padded with zeros
111
- USE_NOISE: bool = False
112
-
113
- # Specifies the output format. 'table' denotes a Raven selection table,
114
- # 'audacity' denotes a TXT file with the same format as Audacity timeline labels
115
- # 'csv' denotes a generic CSV file with start, end, species and confidence.
116
- RESULT_TYPES: set[str] | list[str] = {"table"}
117
- ADDITIONAL_COLUMNS: list[str] | None = None
118
- OUTPUT_RAVEN_FILENAME: str = "BirdNET_SelectionTable.txt" # this is for combined Raven selection tables only
119
- # OUTPUT_RTABLE_FILENAME: str = "BirdNET_RTable.csv"
120
- OUTPUT_KALEIDOSCOPE_FILENAME: str = "BirdNET_Kaleidoscope.csv"
121
- OUTPUT_CSV_FILENAME: str = "BirdNET_CombinedTable.csv"
122
-
123
- # File name of the settings csv for batch analysis
124
- ANALYSIS_PARAMS_FILENAME: str = "BirdNET_analysis_params.csv"
125
-
126
- # Whether to skip existing results in the output path
127
- # If set to False, existing files will not be overwritten
128
- SKIP_EXISTING_RESULTS: bool = False
129
-
130
- COMBINE_RESULTS: bool = False
131
- #####################
132
- # Training settings #
133
- #####################
134
-
135
- # Sample crop mode
136
- SAMPLE_CROP_MODE: str = "center"
137
-
138
- # List of non-event classes
139
- NON_EVENT_CLASSES: list[str] = ["noise", "other", "background", "silence"]
140
-
141
- # Upsampling settings
142
- UPSAMPLING_RATIO: float = 0.0
143
- UPSAMPLING_MODE = "repeat"
144
-
145
- # Number of epochs to train for
146
- TRAIN_EPOCHS: int = 50
147
-
148
- # Batch size for training
149
- TRAIN_BATCH_SIZE: int = 32
150
-
151
- # Validation split (percentage)
152
- TRAIN_VAL_SPLIT: float = 0.2
153
-
154
- # Learning rate for training
155
- TRAIN_LEARNING_RATE: float = 0.0001
156
-
157
- # Number of hidden units in custom classifier
158
- # If >0, a two-layer classifier will be trained
159
- TRAIN_HIDDEN_UNITS: int = 0
160
-
161
- # Dropout rate for training
162
- TRAIN_DROPOUT: float = 0.0
163
-
164
- # Whether to use mixup for training
165
- TRAIN_WITH_MIXUP: bool = False
166
-
167
- # Whether to apply label smoothing for training
168
- TRAIN_WITH_LABEL_SMOOTHING: bool = False
169
-
170
- # Whether to use focal loss for training
171
- TRAIN_WITH_FOCAL_LOSS: bool = False
172
-
173
- # Focal loss gamma parameter
174
- FOCAL_LOSS_GAMMA: float = 2.0
175
-
176
- # Focal loss alpha parameter
177
- FOCAL_LOSS_ALPHA: float = 0.25
178
-
179
- # Model output format
180
- TRAINED_MODEL_OUTPUT_FORMAT: str = "tflite"
181
-
182
- # Model save mode (replace or append new classifier)
183
- TRAINED_MODEL_SAVE_MODE: str = "replace"
184
-
185
- # Cache settings
186
- TRAIN_CACHE_MODE: str | None = None
187
- TRAIN_CACHE_FILE: str = "train_cache.npz"
188
-
189
- # Use automatic Hyperparameter tuning
190
- AUTOTUNE: bool = False
191
-
192
- # How many trials are done for the hyperparameter tuning
193
- AUTOTUNE_TRIALS: int = 50
194
-
195
- # How many executions per trial are done for the hyperparameter tuning
196
- # Mutliple executions will be averaged, so the evaluation is more consistent
197
- AUTOTUNE_EXECUTIONS_PER_TRIAL: int = 1
198
-
199
- # If a binary classification model is trained.
200
- # This value will be detected automatically in the training script, if only one class and a non-event class is used.
201
- BINARY_CLASSIFICATION: bool = False
202
-
203
- # If a model for a multi-label setting is trained.
204
- # This value will automatically be set, if subfolders in the input direcotry are named with multiple classes separated by commas.
205
- MULTI_LABEL: bool = False
206
-
207
- ################
208
- # Runtime vars #
209
- ################
210
-
211
- # File input path and output path for selection tables
212
- INPUT_PATH: str = ""
213
- OUTPUT_PATH: str = ""
214
-
215
- # Training data path
216
- TRAIN_DATA_PATH: str = ""
217
- TEST_DATA_PATH: str = ""
218
-
219
- CODES = {}
220
- LABELS: list[str] = []
221
- TRANSLATED_LABELS: list[str] = []
222
- SPECIES_LIST: list[str] = []
223
- ERROR_LOG_FILE: str = os.path.join(SCRIPT_DIR, "error_log.txt")
224
- FILE_LIST = []
225
- FILE_STORAGE_PATH: str = ""
226
-
227
- # Path to custom trained classifier
228
- # If None, no custom classifier will be used
229
- # Make sure to set the LABELS_FILE above accordingly
230
- CUSTOM_CLASSIFIER: str | None = None
231
-
232
- ######################
233
- # Get and set config #
234
- ######################
235
-
236
-
237
- def get_config():
238
- return {k: v for k, v in globals().items() if k.isupper()}
239
-
240
-
241
- def set_config(c: dict):
242
- for k, v in c.items():
243
- globals()[k] = v
1
+ import os
2
+
3
+ SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__))
4
+
5
+ #################
6
+ # Misc settings #
7
+ #################
8
+
9
+ # Random seed for gaussian noise
10
+ RANDOM_SEED: int = 42
11
+
12
+ ##########################
13
+ # Model paths and config #
14
+ ##########################
15
+
16
+ MODEL_VERSION: str = "V2.4"
17
+ PB_MODEL: str = os.path.join(SCRIPT_DIR, "checkpoints/V2.4/BirdNET_GLOBAL_6K_V2.4_Model")
18
+ # MODEL_PATH = PB_MODEL # This will load the protobuf model
19
+ MODEL_PATH: str = os.path.join(SCRIPT_DIR, "checkpoints/V2.4/BirdNET_GLOBAL_6K_V2.4_Model_FP32.tflite")
20
+ MDATA_MODEL_PATH: str = os.path.join(SCRIPT_DIR, "checkpoints/V2.4/BirdNET_GLOBAL_6K_V2.4_MData_Model_V2_FP16.tflite")
21
+ LABELS_FILE: str = os.path.join(SCRIPT_DIR, "checkpoints/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels.txt")
22
+ TRANSLATED_LABELS_PATH: str = os.path.join(SCRIPT_DIR, "labels/V2.4")
23
+
24
+ ##################
25
+ # Audio settings #
26
+ ##################
27
+
28
+ # We use a sample rate of 48kHz, so the model input size is
29
+ # (batch size, 48000 kHz * 3 seconds) = (1, 144000)
30
+ # Recordings will be resampled automatically.
31
+ SAMPLE_RATE: int = 48000
32
+
33
+ # We're using 3-second chunks
34
+ SIG_LENGTH: float = 3.0
35
+
36
+ # Define overlap between consecutive chunks <3.0; 0 = no overlap
37
+ SIG_OVERLAP: float = 0
38
+
39
+ # Define minimum length of audio chunk for prediction,
40
+ # chunks shorter than 3 seconds will be padded with zeros
41
+ SIG_MINLEN: float = 1.0
42
+
43
+ # Frequency range. This is model specific and should not be changed.
44
+ SIG_FMIN: int = 0
45
+ SIG_FMAX: int = 15000
46
+
47
+ # Settings for bandpass filter
48
+ BANDPASS_FMIN: int = 0
49
+ BANDPASS_FMAX: int = 15000
50
+
51
+ # Top N species to display in selection table, ignored if set to None
52
+ TOP_N = None
53
+
54
+ # Audio speed
55
+ AUDIO_SPEED: float = 1.0
56
+
57
+ #####################
58
+ # Metadata settings #
59
+ #####################
60
+
61
+ LATITUDE: float = -1
62
+ LONGITUDE: float = -1
63
+ WEEK: int = -1
64
+ LOCATION_FILTER_THRESHOLD: float = 0.03
65
+
66
+ ######################
67
+ # Inference settings #
68
+ ######################
69
+
70
+ # If None or empty file, no custom species list will be used
71
+ # Note: Entries in this list have to match entries from the LABELS_FILE
72
+ # We use the 2024 eBird taxonomy for species names (Clements list)
73
+ CODES_FILE: str = os.path.join(SCRIPT_DIR, "eBird_taxonomy_codes_2024E.json")
74
+ SPECIES_LIST_FILE: str = os.path.join(SCRIPT_DIR, "example/species_list.txt")
75
+
76
+ # Supported file types
77
+ ALLOWED_FILETYPES: list[str] = ["wav", "flac", "mp3", "ogg", "m4a", "wma", "aiff", "aif"]
78
+
79
+ # Number of threads to use for inference.
80
+ # Can be as high as number of CPUs in your system
81
+ CPU_THREADS: int = 8
82
+ TFLITE_THREADS: int = 1
83
+
84
+ # False will output logits, True will convert to sigmoid activations
85
+ APPLY_SIGMOID: bool = True
86
+ SIGMOID_SENSITIVITY: float = 1.0
87
+
88
+ # Minimum confidence score to include in selection table
89
+ # (be aware: if APPLY_SIGMOID = False, this no longer represents
90
+ # probabilities and needs to be adjusted)
91
+ MIN_CONFIDENCE: float = 0.25
92
+
93
+ # Number of consecutive detections for one species to merge into one
94
+ # If set to 1 or 0, no merging will be done
95
+ # If set to None, all detections will be included
96
+ MERGE_CONSECUTIVE: int = 1
97
+
98
+ # Number of samples to process at the same time. Higher values can increase
99
+ # processing speed, but will also increase memory usage.
100
+ # Might only be useful for GPU inference.
101
+ BATCH_SIZE: int = 1
102
+
103
+
104
+ # Number of seconds to load from a file at a time
105
+ # Files will be loaded into memory in segments that are only as long as this value
106
+ # Lowering this value results in lower memory usage
107
+ FILE_SPLITTING_DURATION: int = 600
108
+
109
+ # Whether to use noise to pad the signal
110
+ # If set to False, the signal will be padded with zeros
111
+ USE_NOISE: bool = False
112
+
113
+ # Specifies the output format. 'table' denotes a Raven selection table,
114
+ # 'audacity' denotes a TXT file with the same format as Audacity timeline labels
115
+ # 'csv' denotes a generic CSV file with start, end, species and confidence.
116
+ RESULT_TYPES: set[str] | list[str] = {"table"}
117
+ ADDITIONAL_COLUMNS: list[str] | None = None
118
+ OUTPUT_RAVEN_FILENAME: str = "BirdNET_SelectionTable.txt" # this is for combined Raven selection tables only
119
+ # OUTPUT_RTABLE_FILENAME: str = "BirdNET_RTable.csv"
120
+ OUTPUT_KALEIDOSCOPE_FILENAME: str = "BirdNET_Kaleidoscope.csv"
121
+ OUTPUT_CSV_FILENAME: str = "BirdNET_CombinedTable.csv"
122
+
123
+ # File name of the settings csv for batch analysis
124
+ ANALYSIS_PARAMS_FILENAME: str = "BirdNET_analysis_params.csv"
125
+
126
+ # Whether to skip existing results in the output path
127
+ # If set to False, existing files will not be overwritten
128
+ SKIP_EXISTING_RESULTS: bool = False
129
+
130
+ COMBINE_RESULTS: bool = False
131
+ #####################
132
+ # Training settings #
133
+ #####################
134
+
135
+ # Sample crop mode
136
+ SAMPLE_CROP_MODE: str = "center"
137
+
138
+ # List of non-event classes
139
+ NON_EVENT_CLASSES: list[str] = ["noise", "other", "background", "silence"]
140
+
141
+ # Upsampling settings
142
+ UPSAMPLING_RATIO: float = 0.0
143
+ UPSAMPLING_MODE = "repeat"
144
+
145
+ # Number of epochs to train for
146
+ TRAIN_EPOCHS: int = 50
147
+
148
+ # Batch size for training
149
+ TRAIN_BATCH_SIZE: int = 32
150
+
151
+ # Validation split (percentage)
152
+ TRAIN_VAL_SPLIT: float = 0.2
153
+
154
+ # Learning rate for training
155
+ TRAIN_LEARNING_RATE: float = 0.0001
156
+
157
+ # Number of hidden units in custom classifier
158
+ # If >0, a two-layer classifier will be trained
159
+ TRAIN_HIDDEN_UNITS: int = 0
160
+
161
+ # Dropout rate for training
162
+ TRAIN_DROPOUT: float = 0.0
163
+
164
+ # Whether to use mixup for training
165
+ TRAIN_WITH_MIXUP: bool = False
166
+
167
+ # Whether to apply label smoothing for training
168
+ TRAIN_WITH_LABEL_SMOOTHING: bool = False
169
+
170
+ # Whether to use focal loss for training
171
+ TRAIN_WITH_FOCAL_LOSS: bool = False
172
+
173
+ # Focal loss gamma parameter
174
+ FOCAL_LOSS_GAMMA: float = 2.0
175
+
176
+ # Focal loss alpha parameter
177
+ FOCAL_LOSS_ALPHA: float = 0.25
178
+
179
+ # Model output format
180
+ TRAINED_MODEL_OUTPUT_FORMAT: str = "tflite"
181
+
182
+ # Model save mode (replace or append new classifier)
183
+ TRAINED_MODEL_SAVE_MODE: str = "replace"
184
+
185
+ # Cache settings
186
+ TRAIN_CACHE_MODE: str | None = None
187
+ TRAIN_CACHE_FILE: str = "train_cache.npz"
188
+
189
+ # Use automatic Hyperparameter tuning
190
+ AUTOTUNE: bool = False
191
+
192
+ # How many trials are done for the hyperparameter tuning
193
+ AUTOTUNE_TRIALS: int = 50
194
+
195
+ # How many executions per trial are done for the hyperparameter tuning
196
+ # Mutliple executions will be averaged, so the evaluation is more consistent
197
+ AUTOTUNE_EXECUTIONS_PER_TRIAL: int = 1
198
+
199
+ # If a binary classification model is trained.
200
+ # This value will be detected automatically in the training script, if only one class and a non-event class is used.
201
+ BINARY_CLASSIFICATION: bool = False
202
+
203
+ # If a model for a multi-label setting is trained.
204
+ # This value will automatically be set, if subfolders in the input direcotry are named with multiple classes separated by commas.
205
+ MULTI_LABEL: bool = False
206
+
207
+ ################
208
+ # Runtime vars #
209
+ ################
210
+
211
+ # File input path and output path for selection tables
212
+ INPUT_PATH: str = ""
213
+ OUTPUT_PATH: str = ""
214
+
215
+ # Training data path
216
+ TRAIN_DATA_PATH: str = ""
217
+ TEST_DATA_PATH: str = ""
218
+
219
+ CODES = {}
220
+ LABELS: list[str] = []
221
+ TRANSLATED_LABELS: list[str] = []
222
+ SPECIES_LIST: list[str] = []
223
+ ERROR_LOG_FILE: str = os.path.join(SCRIPT_DIR, "error_log.txt")
224
+ FILE_LIST = []
225
+ FILE_STORAGE_PATH: str = ""
226
+
227
+ # Path to custom trained classifier
228
+ # If None, no custom classifier will be used
229
+ # Make sure to set the LABELS_FILE above accordingly
230
+ CUSTOM_CLASSIFIER: str | None = None
231
+
232
+ ######################
233
+ # Get and set config #
234
+ ######################
235
+
236
+
237
+ def get_config():
238
+ return {k: v for k, v in globals().items() if k.isupper()}
239
+
240
+
241
+ def set_config(c: dict):
242
+ for k, v in c.items():
243
+ globals()[k] = v