birdnet-analyzer 2.0.0__py3-none-any.whl → 2.0.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 (122) hide show
  1. birdnet_analyzer/__init__.py +9 -8
  2. birdnet_analyzer/analyze/__init__.py +5 -5
  3. birdnet_analyzer/analyze/__main__.py +3 -4
  4. birdnet_analyzer/analyze/cli.py +25 -25
  5. birdnet_analyzer/analyze/core.py +241 -245
  6. birdnet_analyzer/analyze/utils.py +692 -701
  7. birdnet_analyzer/audio.py +368 -372
  8. birdnet_analyzer/cli.py +709 -707
  9. birdnet_analyzer/config.py +242 -242
  10. birdnet_analyzer/eBird_taxonomy_codes_2021E.json +25279 -25279
  11. birdnet_analyzer/embeddings/__init__.py +3 -4
  12. birdnet_analyzer/embeddings/__main__.py +3 -3
  13. birdnet_analyzer/embeddings/cli.py +12 -13
  14. birdnet_analyzer/embeddings/core.py +69 -70
  15. birdnet_analyzer/embeddings/utils.py +179 -193
  16. birdnet_analyzer/evaluation/__init__.py +196 -195
  17. birdnet_analyzer/evaluation/__main__.py +3 -3
  18. birdnet_analyzer/evaluation/assessment/__init__.py +0 -0
  19. birdnet_analyzer/evaluation/assessment/metrics.py +388 -0
  20. birdnet_analyzer/evaluation/assessment/performance_assessor.py +409 -0
  21. birdnet_analyzer/evaluation/assessment/plotting.py +379 -0
  22. birdnet_analyzer/evaluation/preprocessing/__init__.py +0 -0
  23. birdnet_analyzer/evaluation/preprocessing/data_processor.py +631 -0
  24. birdnet_analyzer/evaluation/preprocessing/utils.py +98 -0
  25. birdnet_analyzer/gui/__init__.py +19 -23
  26. birdnet_analyzer/gui/__main__.py +3 -3
  27. birdnet_analyzer/gui/analysis.py +175 -174
  28. birdnet_analyzer/gui/assets/arrow_down.svg +4 -4
  29. birdnet_analyzer/gui/assets/arrow_left.svg +4 -4
  30. birdnet_analyzer/gui/assets/arrow_right.svg +4 -4
  31. birdnet_analyzer/gui/assets/arrow_up.svg +4 -4
  32. birdnet_analyzer/gui/assets/gui.css +28 -28
  33. birdnet_analyzer/gui/assets/gui.js +93 -93
  34. birdnet_analyzer/gui/embeddings.py +619 -620
  35. birdnet_analyzer/gui/evaluation.py +795 -813
  36. birdnet_analyzer/gui/localization.py +75 -68
  37. birdnet_analyzer/gui/multi_file.py +245 -246
  38. birdnet_analyzer/gui/review.py +519 -527
  39. birdnet_analyzer/gui/segments.py +191 -191
  40. birdnet_analyzer/gui/settings.py +128 -129
  41. birdnet_analyzer/gui/single_file.py +267 -269
  42. birdnet_analyzer/gui/species.py +95 -95
  43. birdnet_analyzer/gui/train.py +696 -698
  44. birdnet_analyzer/gui/utils.py +810 -808
  45. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_af.txt +6522 -6522
  46. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_ar.txt +6522 -6522
  47. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_bg.txt +6522 -6522
  48. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_ca.txt +6522 -6522
  49. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_cs.txt +6522 -6522
  50. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_da.txt +6522 -6522
  51. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_de.txt +6522 -6522
  52. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_el.txt +6522 -6522
  53. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_en_uk.txt +6522 -6522
  54. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_es.txt +6522 -6522
  55. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_fi.txt +6522 -6522
  56. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_fr.txt +6522 -6522
  57. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_he.txt +6522 -6522
  58. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_hr.txt +6522 -6522
  59. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_hu.txt +6522 -6522
  60. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_in.txt +6522 -6522
  61. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_is.txt +6522 -6522
  62. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_it.txt +6522 -6522
  63. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_ja.txt +6522 -6522
  64. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_ko.txt +6522 -6522
  65. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_lt.txt +6522 -6522
  66. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_ml.txt +6522 -6522
  67. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_nl.txt +6522 -6522
  68. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_no.txt +6522 -6522
  69. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_pl.txt +6522 -6522
  70. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_pt_BR.txt +6522 -6522
  71. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_pt_PT.txt +6522 -6522
  72. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_ro.txt +6522 -6522
  73. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_ru.txt +6522 -6522
  74. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_sk.txt +6522 -6522
  75. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_sl.txt +6522 -6522
  76. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_sr.txt +6522 -6522
  77. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_sv.txt +6522 -6522
  78. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_th.txt +6522 -6522
  79. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_tr.txt +6522 -6522
  80. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_uk.txt +6522 -6522
  81. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_zh.txt +6522 -6522
  82. birdnet_analyzer/lang/de.json +334 -334
  83. birdnet_analyzer/lang/en.json +334 -334
  84. birdnet_analyzer/lang/fi.json +334 -334
  85. birdnet_analyzer/lang/fr.json +334 -334
  86. birdnet_analyzer/lang/id.json +334 -334
  87. birdnet_analyzer/lang/pt-br.json +334 -334
  88. birdnet_analyzer/lang/ru.json +334 -334
  89. birdnet_analyzer/lang/se.json +334 -334
  90. birdnet_analyzer/lang/tlh.json +334 -334
  91. birdnet_analyzer/lang/zh_TW.json +334 -334
  92. birdnet_analyzer/model.py +1212 -1243
  93. birdnet_analyzer/playground.py +5 -0
  94. birdnet_analyzer/search/__init__.py +3 -3
  95. birdnet_analyzer/search/__main__.py +3 -3
  96. birdnet_analyzer/search/cli.py +11 -12
  97. birdnet_analyzer/search/core.py +78 -78
  98. birdnet_analyzer/search/utils.py +107 -111
  99. birdnet_analyzer/segments/__init__.py +3 -3
  100. birdnet_analyzer/segments/__main__.py +3 -3
  101. birdnet_analyzer/segments/cli.py +13 -14
  102. birdnet_analyzer/segments/core.py +81 -78
  103. birdnet_analyzer/segments/utils.py +383 -394
  104. birdnet_analyzer/species/__init__.py +3 -3
  105. birdnet_analyzer/species/__main__.py +3 -3
  106. birdnet_analyzer/species/cli.py +13 -14
  107. birdnet_analyzer/species/core.py +35 -35
  108. birdnet_analyzer/species/utils.py +74 -75
  109. birdnet_analyzer/train/__init__.py +3 -3
  110. birdnet_analyzer/train/__main__.py +3 -3
  111. birdnet_analyzer/train/cli.py +13 -14
  112. birdnet_analyzer/train/core.py +113 -113
  113. birdnet_analyzer/train/utils.py +877 -847
  114. birdnet_analyzer/translate.py +133 -104
  115. birdnet_analyzer/utils.py +426 -419
  116. {birdnet_analyzer-2.0.0.dist-info → birdnet_analyzer-2.0.1.dist-info}/METADATA +137 -129
  117. birdnet_analyzer-2.0.1.dist-info/RECORD +125 -0
  118. {birdnet_analyzer-2.0.0.dist-info → birdnet_analyzer-2.0.1.dist-info}/WHEEL +1 -1
  119. {birdnet_analyzer-2.0.0.dist-info → birdnet_analyzer-2.0.1.dist-info}/licenses/LICENSE +18 -18
  120. birdnet_analyzer-2.0.0.dist-info/RECORD +0 -117
  121. {birdnet_analyzer-2.0.0.dist-info → birdnet_analyzer-2.0.1.dist-info}/entry_points.txt +0 -0
  122. {birdnet_analyzer-2.0.0.dist-info → birdnet_analyzer-2.0.1.dist-info}/top_level.txt +0 -0
@@ -1,242 +1,242 @@
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 2021 eBird taxonomy for species names (Clements list)
73
- CODES_FILE: str = os.path.join(SCRIPT_DIR, "eBird_taxonomy_codes_2021E.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
- OUTPUT_RAVEN_FILENAME: str = "BirdNET_SelectionTable.txt" # this is for combined Raven selection tables only
118
- # OUTPUT_RTABLE_FILENAME: str = "BirdNET_RTable.csv"
119
- OUTPUT_KALEIDOSCOPE_FILENAME: str = "BirdNET_Kaleidoscope.csv"
120
- OUTPUT_CSV_FILENAME: str = "BirdNET_CombinedTable.csv"
121
-
122
- # File name of the settings csv for batch analysis
123
- ANALYSIS_PARAMS_FILENAME: str = "BirdNET_analysis_params.csv"
124
-
125
- # Whether to skip existing results in the output path
126
- # If set to False, existing files will not be overwritten
127
- SKIP_EXISTING_RESULTS: bool = False
128
-
129
- COMBINE_RESULTS: bool = False
130
- #####################
131
- # Training settings #
132
- #####################
133
-
134
- # Sample crop mode
135
- SAMPLE_CROP_MODE: str = "center"
136
-
137
- # List of non-event classes
138
- NON_EVENT_CLASSES: list[str] = ["noise", "other", "background", "silence"]
139
-
140
- # Upsampling settings
141
- UPSAMPLING_RATIO: float = 0.0
142
- UPSAMPLING_MODE = "repeat"
143
-
144
- # Number of epochs to train for
145
- TRAIN_EPOCHS: int = 50
146
-
147
- # Batch size for training
148
- TRAIN_BATCH_SIZE: int = 32
149
-
150
- # Validation split (percentage)
151
- TRAIN_VAL_SPLIT: float = 0.2
152
-
153
- # Learning rate for training
154
- TRAIN_LEARNING_RATE: float = 0.0001
155
-
156
- # Number of hidden units in custom classifier
157
- # If >0, a two-layer classifier will be trained
158
- TRAIN_HIDDEN_UNITS: int = 0
159
-
160
- # Dropout rate for training
161
- TRAIN_DROPOUT: float = 0.0
162
-
163
- # Whether to use mixup for training
164
- TRAIN_WITH_MIXUP: bool = False
165
-
166
- # Whether to apply label smoothing for training
167
- TRAIN_WITH_LABEL_SMOOTHING: bool = False
168
-
169
- # Whether to use focal loss for training
170
- TRAIN_WITH_FOCAL_LOSS: bool = False
171
-
172
- # Focal loss gamma parameter
173
- FOCAL_LOSS_GAMMA: float = 2.0
174
-
175
- # Focal loss alpha parameter
176
- FOCAL_LOSS_ALPHA: float = 0.25
177
-
178
- # Model output format
179
- TRAINED_MODEL_OUTPUT_FORMAT: str = "tflite"
180
-
181
- # Model save mode (replace or append new classifier)
182
- TRAINED_MODEL_SAVE_MODE: str = "replace"
183
-
184
- # Cache settings
185
- TRAIN_CACHE_MODE: str | None = None
186
- TRAIN_CACHE_FILE: str = "train_cache.npz"
187
-
188
- # Use automatic Hyperparameter tuning
189
- AUTOTUNE: bool = False
190
-
191
- # How many trials are done for the hyperparameter tuning
192
- AUTOTUNE_TRIALS: int = 50
193
-
194
- # How many executions per trial are done for the hyperparameter tuning
195
- # Mutliple executions will be averaged, so the evaluation is more consistent
196
- AUTOTUNE_EXECUTIONS_PER_TRIAL: int = 1
197
-
198
- # If a binary classification model is trained.
199
- # This value will be detected automatically in the training script, if only one class and a non-event class is used.
200
- BINARY_CLASSIFICATION: bool = False
201
-
202
- # If a model for a multi-label setting is trained.
203
- # This value will automatically be set, if subfolders in the input direcotry are named with multiple classes separated by commas.
204
- MULTI_LABEL: bool = False
205
-
206
- ################
207
- # Runtime vars #
208
- ################
209
-
210
- # File input path and output path for selection tables
211
- INPUT_PATH: str = ""
212
- OUTPUT_PATH: str = ""
213
-
214
- # Training data path
215
- TRAIN_DATA_PATH: str = ""
216
- TEST_DATA_PATH: str = ""
217
-
218
- CODES = {}
219
- LABELS: list[str] = []
220
- TRANSLATED_LABELS: list[str] = []
221
- SPECIES_LIST: list[str] = []
222
- ERROR_LOG_FILE: str = os.path.join(SCRIPT_DIR, "error_log.txt")
223
- FILE_LIST = []
224
- FILE_STORAGE_PATH: str = ""
225
-
226
- # Path to custom trained classifier
227
- # If None, no custom classifier will be used
228
- # Make sure to set the LABELS_FILE above accordingly
229
- CUSTOM_CLASSIFIER = None
230
-
231
- ######################
232
- # Get and set config #
233
- ######################
234
-
235
-
236
- def get_config():
237
- return {k: v for k, v in globals().items() if k.isupper()}
238
-
239
-
240
- def set_config(c: dict):
241
- for k, v in c.items():
242
- 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 2021 eBird taxonomy for species names (Clements list)
73
+ CODES_FILE: str = os.path.join(SCRIPT_DIR, "eBird_taxonomy_codes_2021E.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
+ OUTPUT_RAVEN_FILENAME: str = "BirdNET_SelectionTable.txt" # this is for combined Raven selection tables only
118
+ # OUTPUT_RTABLE_FILENAME: str = "BirdNET_RTable.csv"
119
+ OUTPUT_KALEIDOSCOPE_FILENAME: str = "BirdNET_Kaleidoscope.csv"
120
+ OUTPUT_CSV_FILENAME: str = "BirdNET_CombinedTable.csv"
121
+
122
+ # File name of the settings csv for batch analysis
123
+ ANALYSIS_PARAMS_FILENAME: str = "BirdNET_analysis_params.csv"
124
+
125
+ # Whether to skip existing results in the output path
126
+ # If set to False, existing files will not be overwritten
127
+ SKIP_EXISTING_RESULTS: bool = False
128
+
129
+ COMBINE_RESULTS: bool = False
130
+ #####################
131
+ # Training settings #
132
+ #####################
133
+
134
+ # Sample crop mode
135
+ SAMPLE_CROP_MODE: str = "center"
136
+
137
+ # List of non-event classes
138
+ NON_EVENT_CLASSES: list[str] = ["noise", "other", "background", "silence"]
139
+
140
+ # Upsampling settings
141
+ UPSAMPLING_RATIO: float = 0.0
142
+ UPSAMPLING_MODE = "repeat"
143
+
144
+ # Number of epochs to train for
145
+ TRAIN_EPOCHS: int = 50
146
+
147
+ # Batch size for training
148
+ TRAIN_BATCH_SIZE: int = 32
149
+
150
+ # Validation split (percentage)
151
+ TRAIN_VAL_SPLIT: float = 0.2
152
+
153
+ # Learning rate for training
154
+ TRAIN_LEARNING_RATE: float = 0.0001
155
+
156
+ # Number of hidden units in custom classifier
157
+ # If >0, a two-layer classifier will be trained
158
+ TRAIN_HIDDEN_UNITS: int = 0
159
+
160
+ # Dropout rate for training
161
+ TRAIN_DROPOUT: float = 0.0
162
+
163
+ # Whether to use mixup for training
164
+ TRAIN_WITH_MIXUP: bool = False
165
+
166
+ # Whether to apply label smoothing for training
167
+ TRAIN_WITH_LABEL_SMOOTHING: bool = False
168
+
169
+ # Whether to use focal loss for training
170
+ TRAIN_WITH_FOCAL_LOSS: bool = False
171
+
172
+ # Focal loss gamma parameter
173
+ FOCAL_LOSS_GAMMA: float = 2.0
174
+
175
+ # Focal loss alpha parameter
176
+ FOCAL_LOSS_ALPHA: float = 0.25
177
+
178
+ # Model output format
179
+ TRAINED_MODEL_OUTPUT_FORMAT: str = "tflite"
180
+
181
+ # Model save mode (replace or append new classifier)
182
+ TRAINED_MODEL_SAVE_MODE: str = "replace"
183
+
184
+ # Cache settings
185
+ TRAIN_CACHE_MODE: str | None = None
186
+ TRAIN_CACHE_FILE: str = "train_cache.npz"
187
+
188
+ # Use automatic Hyperparameter tuning
189
+ AUTOTUNE: bool = False
190
+
191
+ # How many trials are done for the hyperparameter tuning
192
+ AUTOTUNE_TRIALS: int = 50
193
+
194
+ # How many executions per trial are done for the hyperparameter tuning
195
+ # Mutliple executions will be averaged, so the evaluation is more consistent
196
+ AUTOTUNE_EXECUTIONS_PER_TRIAL: int = 1
197
+
198
+ # If a binary classification model is trained.
199
+ # This value will be detected automatically in the training script, if only one class and a non-event class is used.
200
+ BINARY_CLASSIFICATION: bool = False
201
+
202
+ # If a model for a multi-label setting is trained.
203
+ # This value will automatically be set, if subfolders in the input direcotry are named with multiple classes separated by commas.
204
+ MULTI_LABEL: bool = False
205
+
206
+ ################
207
+ # Runtime vars #
208
+ ################
209
+
210
+ # File input path and output path for selection tables
211
+ INPUT_PATH: str = ""
212
+ OUTPUT_PATH: str = ""
213
+
214
+ # Training data path
215
+ TRAIN_DATA_PATH: str = ""
216
+ TEST_DATA_PATH: str = ""
217
+
218
+ CODES = {}
219
+ LABELS: list[str] = []
220
+ TRANSLATED_LABELS: list[str] = []
221
+ SPECIES_LIST: list[str] = []
222
+ ERROR_LOG_FILE: str = os.path.join(SCRIPT_DIR, "error_log.txt")
223
+ FILE_LIST = []
224
+ FILE_STORAGE_PATH: str = ""
225
+
226
+ # Path to custom trained classifier
227
+ # If None, no custom classifier will be used
228
+ # Make sure to set the LABELS_FILE above accordingly
229
+ CUSTOM_CLASSIFIER = None
230
+
231
+ ######################
232
+ # Get and set config #
233
+ ######################
234
+
235
+
236
+ def get_config():
237
+ return {k: v for k, v in globals().items() if k.isupper()}
238
+
239
+
240
+ def set_config(c: dict):
241
+ for k, v in c.items():
242
+ globals()[k] = v