birdnet-analyzer 2.0.0__py3-none-any.whl → 2.1.0__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 (123) hide show
  1. birdnet_analyzer/__init__.py +9 -8
  2. birdnet_analyzer/analyze/__init__.py +19 -5
  3. birdnet_analyzer/analyze/__main__.py +3 -4
  4. birdnet_analyzer/analyze/cli.py +30 -25
  5. birdnet_analyzer/analyze/core.py +246 -245
  6. birdnet_analyzer/analyze/utils.py +694 -701
  7. birdnet_analyzer/audio.py +368 -372
  8. birdnet_analyzer/cli.py +732 -707
  9. birdnet_analyzer/config.py +243 -242
  10. birdnet_analyzer/eBird_taxonomy_codes_2024E.json +13046 -0
  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 +70 -70
  15. birdnet_analyzer/embeddings/utils.py +220 -193
  16. birdnet_analyzer/evaluation/__init__.py +189 -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 +364 -0
  21. birdnet_analyzer/evaluation/assessment/plotting.py +378 -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 +179 -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 +36 -28
  33. birdnet_analyzer/gui/assets/gui.js +93 -93
  34. birdnet_analyzer/gui/embeddings.py +638 -620
  35. birdnet_analyzer/gui/evaluation.py +801 -813
  36. birdnet_analyzer/gui/localization.py +75 -68
  37. birdnet_analyzer/gui/multi_file.py +265 -246
  38. birdnet_analyzer/gui/review.py +472 -527
  39. birdnet_analyzer/gui/segments.py +191 -191
  40. birdnet_analyzer/gui/settings.py +149 -129
  41. birdnet_analyzer/gui/single_file.py +264 -269
  42. birdnet_analyzer/gui/species.py +95 -95
  43. birdnet_analyzer/gui/train.py +687 -698
  44. birdnet_analyzer/gui/utils.py +797 -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 +341 -334
  83. birdnet_analyzer/lang/en.json +341 -334
  84. birdnet_analyzer/lang/fi.json +341 -334
  85. birdnet_analyzer/lang/fr.json +341 -334
  86. birdnet_analyzer/lang/id.json +341 -334
  87. birdnet_analyzer/lang/pt-br.json +341 -334
  88. birdnet_analyzer/lang/ru.json +341 -334
  89. birdnet_analyzer/lang/se.json +341 -334
  90. birdnet_analyzer/lang/tlh.json +341 -334
  91. birdnet_analyzer/lang/zh_TW.json +341 -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 +425 -419
  116. {birdnet_analyzer-2.0.0.dist-info → birdnet_analyzer-2.1.0.dist-info}/METADATA +146 -129
  117. birdnet_analyzer-2.1.0.dist-info/RECORD +125 -0
  118. {birdnet_analyzer-2.0.0.dist-info → birdnet_analyzer-2.1.0.dist-info}/WHEEL +1 -1
  119. {birdnet_analyzer-2.0.0.dist-info → birdnet_analyzer-2.1.0.dist-info}/licenses/LICENSE +18 -18
  120. birdnet_analyzer/eBird_taxonomy_codes_2021E.json +0 -25280
  121. birdnet_analyzer-2.0.0.dist-info/RECORD +0 -117
  122. {birdnet_analyzer-2.0.0.dist-info → birdnet_analyzer-2.1.0.dist-info}/entry_points.txt +0 -0
  123. {birdnet_analyzer-2.0.0.dist-info → birdnet_analyzer-2.1.0.dist-info}/top_level.txt +0 -0
@@ -1,246 +1,265 @@
1
- import gradio as gr
2
-
3
- import birdnet_analyzer.config as cfg
4
- import birdnet_analyzer.gui.utils as gu
5
- import birdnet_analyzer.gui.localization as loc
6
-
7
- OUTPUT_TYPE_MAP = {
8
- "Raven selection table": "table",
9
- "Audacity": "audacity",
10
- "CSV": "csv",
11
- "Kaleidoscope": "kaleidoscope",
12
- }
13
-
14
-
15
- @gu.gui_runtime_error_handler
16
- def run_batch_analysis(
17
- output_path,
18
- use_top_n,
19
- top_n,
20
- confidence,
21
- sensitivity,
22
- overlap,
23
- merge_consecutive,
24
- audio_speed,
25
- fmin,
26
- fmax,
27
- species_list_choice,
28
- species_list_file,
29
- lat,
30
- lon,
31
- week,
32
- use_yearlong,
33
- sf_thresh,
34
- custom_classifier_file,
35
- output_type,
36
- combine_tables,
37
- locale,
38
- batch_size,
39
- threads,
40
- input_dir,
41
- skip_existing,
42
- progress=gr.Progress(),
43
- ):
44
- from birdnet_analyzer.gui.analysis import run_analysis
45
-
46
- gu.validate(input_dir, loc.localize("validation-no-directory-selected"))
47
- batch_size = int(batch_size)
48
- threads = int(threads)
49
-
50
- if species_list_choice == gu._CUSTOM_SPECIES:
51
- gu.validate(species_list_file, loc.localize("validation-no-species-list-selected"))
52
-
53
- if fmin is None or fmax is None or fmin < cfg.SIG_FMIN or fmax > cfg.SIG_FMAX or fmin > fmax:
54
- raise gr.Error(f"{loc.localize('validation-no-valid-frequency')} [{cfg.SIG_FMIN}, {cfg.SIG_FMAX}]")
55
-
56
- return run_analysis(
57
- None,
58
- output_path,
59
- use_top_n,
60
- top_n,
61
- confidence,
62
- sensitivity,
63
- overlap,
64
- merge_consecutive,
65
- audio_speed,
66
- fmin,
67
- fmax,
68
- species_list_choice,
69
- species_list_file,
70
- lat,
71
- lon,
72
- week,
73
- use_yearlong,
74
- sf_thresh,
75
- custom_classifier_file,
76
- output_type,
77
- combine_tables,
78
- "en" if not locale else locale,
79
- batch_size if batch_size and batch_size > 0 else 1,
80
- threads if threads and threads > 0 else 4,
81
- input_dir,
82
- skip_existing,
83
- True,
84
- progress,
85
- )
86
-
87
-
88
- def build_multi_analysis_tab():
89
- with gr.Tab(loc.localize("multi-tab-title")):
90
- input_directory_state = gr.State()
91
- output_directory_predict_state = gr.State()
92
-
93
- with gr.Row():
94
- with gr.Column():
95
- select_directory_btn = gr.Button(loc.localize("multi-tab-input-selection-button-label"))
96
- directory_input = gr.Matrix(
97
- interactive=False,
98
- headers=[
99
- loc.localize("multi-tab-samples-dataframe-column-subpath-header"),
100
- loc.localize("multi-tab-samples-dataframe-column-duration-header"),
101
- ],
102
- )
103
-
104
- def select_directory_on_empty(): # Nishant - Function modified for For Folder selection
105
- folder = gu.select_folder(state_key="batch-analysis-data-dir")
106
-
107
- if folder:
108
- files_and_durations = gu.get_audio_files_and_durations(folder)
109
- if len(files_and_durations) > 100:
110
- return [folder, files_and_durations[:100] + [["..."]]] # hopefully fixes issue#272
111
- return [folder, files_and_durations]
112
-
113
- return ["", [[loc.localize("multi-tab-samples-dataframe-no-files-found")]]]
114
-
115
- select_directory_btn.click(
116
- select_directory_on_empty, outputs=[input_directory_state, directory_input], show_progress=True
117
- )
118
-
119
- with gr.Column():
120
- select_out_directory_btn = gr.Button(loc.localize("multi-tab-output-selection-button-label"))
121
- selected_out_textbox = gr.Textbox(
122
- label=loc.localize("multi-tab-output-textbox-label"),
123
- interactive=False,
124
- placeholder=loc.localize("multi-tab-output-textbox-placeholder"),
125
- )
126
-
127
- def select_directory_wrapper(): # Nishant - Function modified for For Folder selection
128
- folder = gu.select_folder(state_key="batch-analysis-output-dir")
129
- return (folder, folder) if folder else ("", "")
130
-
131
- select_out_directory_btn.click(
132
- select_directory_wrapper,
133
- outputs=[output_directory_predict_state, selected_out_textbox],
134
- show_progress=False,
135
- )
136
-
137
- (
138
- use_top_n,
139
- top_n_input,
140
- confidence_slider,
141
- sensitivity_slider,
142
- overlap_slider,
143
- merge_consecutive_slider,
144
- audio_speed_slider,
145
- fmin_number,
146
- fmax_number,
147
- ) = gu.sample_sliders()
148
-
149
- (
150
- species_list_radio,
151
- species_file_input,
152
- lat_number,
153
- lon_number,
154
- week_number,
155
- sf_thresh_number,
156
- yearlong_checkbox,
157
- selected_classifier_state,
158
- map_plot,
159
- ) = gu.species_lists()
160
-
161
- with gr.Accordion(loc.localize("multi-tab-output-accordion-label"), open=True):
162
- with gr.Group():
163
- output_type_radio = gr.CheckboxGroup(
164
- list(OUTPUT_TYPE_MAP.items()),
165
- value="table",
166
- label=loc.localize("multi-tab-output-radio-label"),
167
- info=loc.localize("multi-tab-output-radio-info"),
168
- )
169
-
170
- with gr.Row():
171
- with gr.Column():
172
- combine_tables_checkbox = gr.Checkbox(
173
- False,
174
- label=loc.localize("multi-tab-output-combine-tables-checkbox-label"),
175
- info=loc.localize("multi-tab-output-combine-tables-checkbox-info"),
176
- )
177
-
178
- with gr.Row():
179
- skip_existing_checkbox = gr.Checkbox(
180
- False,
181
- label=loc.localize("multi-tab-skip-existing-checkbox-label"),
182
- info=loc.localize("multi-tab-skip-existing-checkbox-info"),
183
- )
184
-
185
- with gr.Row():
186
- batch_size_number = gr.Number(
187
- precision=1,
188
- label=loc.localize("multi-tab-batchsize-number-label"),
189
- value=1,
190
- info=loc.localize("multi-tab-batchsize-number-info"),
191
- minimum=1,
192
- )
193
- threads_number = gr.Number(
194
- precision=1,
195
- label=loc.localize("multi-tab-threads-number-label"),
196
- value=4,
197
- info=loc.localize("multi-tab-threads-number-info"),
198
- minimum=1,
199
- )
200
-
201
- locale_radio = gu.locale()
202
-
203
- start_batch_analysis_btn = gr.Button(loc.localize("analyze-start-button-label"), variant="huggingface")
204
-
205
- result_grid = gr.Matrix(
206
- headers=[
207
- loc.localize("multi-tab-result-dataframe-column-file-header"),
208
- loc.localize("multi-tab-result-dataframe-column-execution-header"),
209
- ],
210
- )
211
-
212
- inputs = [
213
- output_directory_predict_state,
214
- use_top_n,
215
- top_n_input,
216
- confidence_slider,
217
- sensitivity_slider,
218
- overlap_slider,
219
- merge_consecutive_slider,
220
- audio_speed_slider,
221
- fmin_number,
222
- fmax_number,
223
- species_list_radio,
224
- species_file_input,
225
- lat_number,
226
- lon_number,
227
- week_number,
228
- yearlong_checkbox,
229
- sf_thresh_number,
230
- selected_classifier_state,
231
- output_type_radio,
232
- combine_tables_checkbox,
233
- locale_radio,
234
- batch_size_number,
235
- threads_number,
236
- input_directory_state,
237
- skip_existing_checkbox,
238
- ]
239
-
240
- start_batch_analysis_btn.click(run_batch_analysis, inputs=inputs, outputs=result_grid)
241
-
242
- return lat_number, lon_number, map_plot
243
-
244
-
245
- if __name__ == "__main__":
246
- gu.open_window(build_multi_analysis_tab)
1
+ # ruff: noqa: I001
2
+ import gradio as gr
3
+
4
+ import birdnet_analyzer.config as cfg
5
+ import birdnet_analyzer.gui.utils as gu
6
+ import birdnet_analyzer.gui.localization as loc
7
+
8
+ OUTPUT_TYPE_MAP = {
9
+ "Raven selection table": "table",
10
+ "Audacity": "audacity",
11
+ "CSV": "csv",
12
+ "Kaleidoscope": "kaleidoscope",
13
+ }
14
+ ADDITIONAL_COLUMNS_MAP = {
15
+ "Latitude": "lat",
16
+ "Longitude": "lon",
17
+ "Week": "week",
18
+ "Overlap": "overlap",
19
+ "Sensitivity": "sensitivity",
20
+ "Minimum confidence": "min_conf",
21
+ "Species list file": "species_list",
22
+ "Model file": "model",
23
+ }
24
+
25
+ @gu.gui_runtime_error_handler
26
+ def run_batch_analysis(
27
+ output_path,
28
+ use_top_n,
29
+ top_n,
30
+ confidence,
31
+ sensitivity,
32
+ overlap,
33
+ merge_consecutive,
34
+ audio_speed,
35
+ fmin,
36
+ fmax,
37
+ species_list_choice,
38
+ species_list_file,
39
+ lat,
40
+ lon,
41
+ week,
42
+ use_yearlong,
43
+ sf_thresh,
44
+ custom_classifier_file,
45
+ output_type,
46
+ additional_columns,
47
+ combine_tables,
48
+ locale,
49
+ batch_size,
50
+ threads,
51
+ input_dir,
52
+ skip_existing,
53
+ progress=gr.Progress(),
54
+ ):
55
+ from birdnet_analyzer.gui.analysis import run_analysis
56
+
57
+ gu.validate(input_dir, loc.localize("validation-no-directory-selected"))
58
+ batch_size = int(batch_size)
59
+ threads = int(threads)
60
+
61
+ if species_list_choice == gu._CUSTOM_SPECIES:
62
+ gu.validate(species_list_file, loc.localize("validation-no-species-list-selected"))
63
+
64
+ if fmin is None or fmax is None or fmin < cfg.SIG_FMIN or fmax > cfg.SIG_FMAX or fmin > fmax:
65
+ raise gr.Error(f"{loc.localize('validation-no-valid-frequency')} [{cfg.SIG_FMIN}, {cfg.SIG_FMAX}]")
66
+
67
+ return run_analysis(
68
+ None,
69
+ output_path,
70
+ use_top_n,
71
+ top_n,
72
+ confidence,
73
+ sensitivity,
74
+ overlap,
75
+ merge_consecutive,
76
+ audio_speed,
77
+ fmin,
78
+ fmax,
79
+ species_list_choice,
80
+ species_list_file,
81
+ lat,
82
+ lon,
83
+ week,
84
+ use_yearlong,
85
+ sf_thresh,
86
+ custom_classifier_file,
87
+ output_type,
88
+ additional_columns,
89
+ combine_tables,
90
+ locale if locale else "en",
91
+ batch_size if batch_size and batch_size > 0 else 1,
92
+ threads if threads and threads > 0 else 4,
93
+ input_dir,
94
+ skip_existing,
95
+ True,
96
+ progress,
97
+ )
98
+
99
+
100
+ def build_multi_analysis_tab():
101
+ with gr.Tab(loc.localize("multi-tab-title")):
102
+ input_directory_state = gr.State()
103
+ output_directory_predict_state = gr.State()
104
+
105
+ with gr.Row():
106
+ with gr.Column():
107
+ select_directory_btn = gr.Button(loc.localize("multi-tab-input-selection-button-label"))
108
+ directory_input = gr.Matrix(
109
+ interactive=False,
110
+ headers=[
111
+ loc.localize("multi-tab-samples-dataframe-column-subpath-header"),
112
+ loc.localize("multi-tab-samples-dataframe-column-duration-header"),
113
+ ],
114
+ )
115
+
116
+ def select_directory_on_empty(): # Nishant - Function modified for For Folder selection
117
+ folder = gu.select_folder(state_key="batch-analysis-data-dir")
118
+
119
+ if folder:
120
+ files_and_durations = gu.get_audio_files_and_durations(folder)
121
+ if len(files_and_durations) > 100:
122
+ return [folder, files_and_durations[:100] + [["..."]]] # hopefully fixes issue#272
123
+ return [folder, files_and_durations]
124
+
125
+ return ["", [[loc.localize("multi-tab-samples-dataframe-no-files-found")]]]
126
+
127
+ select_directory_btn.click(select_directory_on_empty, outputs=[input_directory_state, directory_input], show_progress=True)
128
+
129
+ with gr.Column():
130
+ select_out_directory_btn = gr.Button(loc.localize("multi-tab-output-selection-button-label"))
131
+ selected_out_textbox = gr.Textbox(
132
+ label=loc.localize("multi-tab-output-textbox-label"),
133
+ interactive=False,
134
+ placeholder=loc.localize("multi-tab-output-textbox-placeholder"),
135
+ )
136
+
137
+ def select_directory_wrapper(): # Nishant - Function modified for For Folder selection
138
+ folder = gu.select_folder(state_key="batch-analysis-output-dir")
139
+ return (folder, folder) if folder else ("", "")
140
+
141
+ select_out_directory_btn.click(
142
+ select_directory_wrapper,
143
+ outputs=[output_directory_predict_state, selected_out_textbox],
144
+ show_progress=False,
145
+ )
146
+
147
+ (
148
+ use_top_n,
149
+ top_n_input,
150
+ confidence_slider,
151
+ sensitivity_slider,
152
+ overlap_slider,
153
+ merge_consecutive_slider,
154
+ audio_speed_slider,
155
+ fmin_number,
156
+ fmax_number,
157
+ ) = gu.sample_sliders()
158
+
159
+ (
160
+ species_list_radio,
161
+ species_file_input,
162
+ lat_number,
163
+ lon_number,
164
+ week_number,
165
+ sf_thresh_number,
166
+ yearlong_checkbox,
167
+ selected_classifier_state,
168
+ map_plot,
169
+ ) = gu.species_lists()
170
+
171
+ with gr.Accordion(loc.localize("multi-tab-output-accordion-label"), open=True), gr.Group():
172
+ output_type_radio = gr.CheckboxGroup(
173
+ list(OUTPUT_TYPE_MAP.items()),
174
+ value="table",
175
+ label=loc.localize("multi-tab-output-radio-label"),
176
+ info=loc.localize("multi-tab-output-radio-info"),
177
+ )
178
+ additional_columns_ = gr.CheckboxGroup(
179
+ list(ADDITIONAL_COLUMNS_MAP.items()),
180
+ visible=False,
181
+ label=loc.localize("multi-tab-additional-columns-checkbox-label"),
182
+ info=loc.localize("multi-tab-additional-columns-checkbox-info"),
183
+ )
184
+
185
+ with gr.Row():
186
+ combine_tables_checkbox = gr.Checkbox(
187
+ False,
188
+ label=loc.localize("multi-tab-output-combine-tables-checkbox-label"),
189
+ info=loc.localize("multi-tab-output-combine-tables-checkbox-info"),
190
+ )
191
+
192
+ with gr.Row():
193
+ skip_existing_checkbox = gr.Checkbox(
194
+ False,
195
+ label=loc.localize("multi-tab-skip-existing-checkbox-label"),
196
+ info=loc.localize("multi-tab-skip-existing-checkbox-info"),
197
+ )
198
+
199
+ with gr.Row():
200
+ batch_size_number = gr.Number(
201
+ precision=1,
202
+ label=loc.localize("multi-tab-batchsize-number-label"),
203
+ value=1,
204
+ info=loc.localize("multi-tab-batchsize-number-info"),
205
+ minimum=1,
206
+ )
207
+ threads_number = gr.Number(
208
+ precision=1,
209
+ label=loc.localize("multi-tab-threads-number-label"),
210
+ value=4,
211
+ info=loc.localize("multi-tab-threads-number-info"),
212
+ minimum=1,
213
+ )
214
+
215
+ locale_radio = gu.locale()
216
+
217
+ start_batch_analysis_btn = gr.Button(loc.localize("analyze-start-button-label"), variant="huggingface")
218
+
219
+ result_grid = gr.Matrix(
220
+ headers=[
221
+ loc.localize("multi-tab-result-dataframe-column-file-header"),
222
+ loc.localize("multi-tab-result-dataframe-column-execution-header"),
223
+ ],
224
+ )
225
+
226
+ inputs = [
227
+ output_directory_predict_state,
228
+ use_top_n,
229
+ top_n_input,
230
+ confidence_slider,
231
+ sensitivity_slider,
232
+ overlap_slider,
233
+ merge_consecutive_slider,
234
+ audio_speed_slider,
235
+ fmin_number,
236
+ fmax_number,
237
+ species_list_radio,
238
+ species_file_input,
239
+ lat_number,
240
+ lon_number,
241
+ week_number,
242
+ yearlong_checkbox,
243
+ sf_thresh_number,
244
+ selected_classifier_state,
245
+ output_type_radio,
246
+ additional_columns_,
247
+ combine_tables_checkbox,
248
+ locale_radio,
249
+ batch_size_number,
250
+ threads_number,
251
+ input_directory_state,
252
+ skip_existing_checkbox,
253
+ ]
254
+
255
+ def show_additional_columns(values):
256
+ return gr.update(visible="csv" in values)
257
+
258
+ start_batch_analysis_btn.click(run_batch_analysis, inputs=inputs, outputs=result_grid)
259
+ output_type_radio.change(show_additional_columns, inputs=output_type_radio, outputs=additional_columns_)
260
+
261
+ return lat_number, lon_number, map_plot
262
+
263
+
264
+ if __name__ == "__main__":
265
+ gu.open_window(build_multi_analysis_tab)