xarray-behave 0.37.6__tar.gz → 0.37.7__tar.gz

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 (40) hide show
  1. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/PKG-INFO +1 -1
  2. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/__init__.py +1 -1
  3. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/gui/app.py +4 -0
  4. xarray_behave-0.37.7/src/xarray_behave/gui/das_legacy.py +377 -0
  5. xarray_behave-0.37.7/src/xarray_behave/gui/forms/das_predict.yaml +167 -0
  6. xarray_behave-0.37.7/src/xarray_behave/gui/forms/das_train.yaml +264 -0
  7. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/LICENSE +0 -0
  8. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/README.md +0 -0
  9. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/pyproject.toml +0 -0
  10. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/annot.py +0 -0
  11. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/event_utils.py +0 -0
  12. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/gui/__init__.py +0 -0
  13. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/gui/audio_player.py +0 -0
  14. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/gui/formbuilder.py +0 -0
  15. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/gui/forms/envelope_computation.yaml +0 -0
  16. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/gui/forms/from_dir.yaml +0 -0
  17. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/gui/forms/from_file.yaml +0 -0
  18. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/gui/forms/from_zarr.yaml +0 -0
  19. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/gui/forms/spec_freq.yaml +0 -0
  20. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/gui/icon.png +0 -0
  21. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/gui/table.py +0 -0
  22. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/gui/utils.py +0 -0
  23. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/gui/view_dialog.py +0 -0
  24. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/gui/views.py +0 -0
  25. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/gui/widgets.py +0 -0
  26. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/io/__init__.py +0 -0
  27. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/io/annotations.py +0 -0
  28. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/io/annotations_manual.py +0 -0
  29. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/io/audio.py +0 -0
  30. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/io/balltracks.py +0 -0
  31. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/io/movieparams.py +0 -0
  32. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/io/poses.py +0 -0
  33. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/io/samplestamps/__init__.py +0 -0
  34. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/io/samplestamps/samplestamps.py +0 -0
  35. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/io/samplestamps/utils.py +0 -0
  36. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/io/timestamps.py +0 -0
  37. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/io/tracks.py +0 -0
  38. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/loaders.py +0 -0
  39. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/metrics.py +0 -0
  40. {xarray_behave-0.37.6 → xarray_behave-0.37.7}/src/xarray_behave/xarray_behave.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: xarray-behave
3
- Version: 0.37.6
3
+ Version: 0.37.7
4
4
  Summary: xarray tools for behavioral data.
5
5
  Author-email: Jan Clemens <clemensjan@googlemail.com>
6
6
  Requires-Python: >=3.10
@@ -1,6 +1,6 @@
1
1
  """xarray tools for behavioral data."""
2
2
 
3
- __version__ = "0.37.6"
3
+ __version__ = "0.37.7"
4
4
 
5
5
  from .xarray_behave import assemble, assemble_metrics, load, save
6
6
  import os
@@ -366,6 +366,10 @@ class MainWindow(QtWidgets.QMainWindow):
366
366
  try:
367
367
  from das.gui_app import DASConformerWindow
368
368
  except ImportError as e:
369
+ if isinstance(e, ModuleNotFoundError) and e.name == "das.gui_app":
370
+ from . import das_legacy
371
+
372
+ return getattr(das_legacy, f"das_{initial_tab}")(self, None)
369
373
  logger.exception(e)
370
374
  logger.info(" Failed to import das-conformer. Install it in the current environment to use DAS.")
371
375
  return None
@@ -0,0 +1,377 @@
1
+ """DAS 0.33 dialogs, retained for releases without das.gui_app."""
2
+
3
+ import logging
4
+ import multiprocessing
5
+ import os
6
+ import pathlib
7
+ import threading
8
+ from typing import Any, Dict
9
+
10
+ import numpy as np
11
+ import rich
12
+ import yaml
13
+ from qtpy import QtCore, QtWidgets
14
+
15
+ import xarray_behave
16
+ from . import utils
17
+ from .formbuilder import YamlDialog
18
+
19
+ logger = logging.getLogger(__name__)
20
+ package_dir = xarray_behave.__path__[0]
21
+
22
+ def das_train(self, qt_keycode):
23
+ def _filter_form_data(form_data: Dict[str, Any], is_cli: bool = False) -> Dict[str, Any]:
24
+ """[summary]
25
+
26
+ Args:
27
+ form_data (Dict[Any]): [description]
28
+ cli (bool, optional): Process boolean flags. Defaults to False.
29
+
30
+ Returns:
31
+ Dict[Any]: [description]
32
+ """
33
+
34
+ form_data["model_name"] = "tcn_stft"
35
+ if form_data["frontend"] == "STFT":
36
+ form_data["nb_pre_conv"] = int(np.sqrt(int(form_data["nb_pre_conv"])))
37
+ form_data["pre_nb_dft"] = int(form_data["pre_nb_dft"])
38
+ else:
39
+ form_data["nb_pre_conv"] = int(0)
40
+ del form_data["frontend"]
41
+ form_data["reduce_lr"] = form_data["reduce_lr_patience"] is not None
42
+ post_opt = form_data["postopt"] == "Yes"
43
+ form_data = {k: v for k, v in form_data.items() if v not in ["Yes", "No", None]}
44
+ form_data["post_opt"] = post_opt
45
+
46
+ if not len(form_data["y_suffix"]):
47
+ del form_data["y_suffix"]
48
+ if not len(form_data["save_prefix"]):
49
+ del form_data["save_prefix"]
50
+
51
+ for field in ["seed", "fraction_data", "reduce_lr_patience"]:
52
+ if field in form_data and form_data[field] is None:
53
+ del form_data[field]
54
+ form_data["use_separable"] = [item.lower() == "true" for item in form_data["use_separable"]]
55
+ if is_cli:
56
+ form_data["use_separable"] = " ".join([str(item) for item in form_data["use_separable"]])
57
+ for field in ["balance", "ignore_boundaries", "reduce_lr", "tensorboard", "post_opt"]:
58
+ if field in form_data:
59
+ if form_data[field] is False: # rename and pre-prend "no_"
60
+ del form_data[field]
61
+ form_data["no_" + field] = ""
62
+ else: # empyt value
63
+ form_data[field] = ""
64
+
65
+ return form_data
66
+
67
+ def save(arg):
68
+ savefilename, _ = QtWidgets.QFileDialog.getSaveFileName(
69
+ self, "Save configuration to", "", filter="yaml files (*.yaml);;all files (*)"
70
+ )
71
+ if len(savefilename):
72
+ data = dialog.form.get_form_data()
73
+ logger.info(f" Saving form fields to {savefilename}.")
74
+ with open(savefilename, "w") as stream:
75
+ yaml.safe_dump(data, stream)
76
+ logger.info("Done.")
77
+
78
+ def make_cli(arg):
79
+ script_ext = "cmd" if os.name == "nt" else "sh"
80
+ savefilename = "train." + script_ext
81
+ savefilename, _ = QtWidgets.QFileDialog.getSaveFileName(
82
+ self, "Script name", savefilename, filter=f"script (*.{script_ext};;all files (*)"
83
+ )
84
+ if len(savefilename):
85
+ form_data = dialog.form.get_form_data()
86
+ form_data = _filter_form_data(form_data, is_cli=True)
87
+
88
+ cmd = "python3 -m das.train"
89
+ # FIXME formatting
90
+ for key, val in form_data.items():
91
+ cmd += f" --{key.replace('_', '-')} {val}"
92
+ with open(savefilename, "w") as f:
93
+ f.write(cmd)
94
+
95
+ # TODO: dialog to suggest editing the script (change paths, activate conda env, cluster specific stuff)
96
+ logger.info("Done.")
97
+
98
+ def load(arg):
99
+ yaml_filename, _ = QtWidgets.QFileDialog.getOpenFileName(parent=None, caption="Select yaml file")
100
+ if len(yaml_filename):
101
+ logger.info(f" Updating form fields with information from {yaml_filename}.")
102
+ with open(yaml_filename, "r") as stream:
103
+ data = yaml.safe_load(stream)
104
+ dialog.form.set_form_data(data) # update form
105
+ logger.info("Done.")
106
+
107
+ data_dir = QtWidgets.QFileDialog.getExistingDirectory(None, caption="Open Data Folder (*.npy)")
108
+ # TODO: check that this is a valid data_dir!
109
+ dialog = YamlDialog(
110
+ yaml_file=package_dir + "/gui/forms/das_train.yaml",
111
+ title="Train network",
112
+ # main_callback=train,
113
+ callbacks={"save": save, "load": load, "make_cli": make_cli},
114
+ )
115
+ dialog.form.fields["data_dir"].setText(data_dir)
116
+ dialog.form.fields["save_dir"].setText(os.path.splitext(data_dir)[0] + ".res")
117
+ y_suffices = list(set([p.stem.strip("y_") for p in pathlib.Path(data_dir).glob("**/y_*.npy")]))
118
+ dialog.form.fields["y_suffix"].set_options(y_suffices)
119
+
120
+ dialog.show()
121
+ result = dialog.exec_()
122
+ if result == QtWidgets.QDialog.Accepted:
123
+ form_data = dialog.form.get_form_data()
124
+ form_data = _filter_form_data(form_data)
125
+
126
+ got_das = False
127
+ try:
128
+ import das.train
129
+
130
+ got_das = True
131
+ except ImportError:
132
+ logger.exception("Need to install das. Alternatively, make scripts and run training elsewhere.")
133
+
134
+ if got_das:
135
+ # start in independent process, otherwise GUI will freeze during training
136
+ form_data["log_messages"] = True
137
+
138
+ queue = multiprocessing.Queue() # for progress updates from the callback for display in the GUI
139
+ stop_event = threading.Event() # checked in the keras callback for stopping training from the GUI
140
+
141
+ progress = QtWidgets.QProgressDialog("Initializing training", "Stop training", 0, form_data["nb_epoch"], None)
142
+ progress.setWindowTitle("DAS training")
143
+ progress.setWindowModality(QtCore.Qt.NonModal)
144
+
145
+ # Custom cancel-button callback the sets the stop_event to stop training."""
146
+ def custom_cancel():
147
+ utils.invoke_in_main_thread(progress.setLabelText, "Stopping training.")
148
+ stop_event.set() # stop training
149
+
150
+ progress.canceled.connect(custom_cancel)
151
+
152
+ form_data["_qt_progress"] = (queue, stop_event)
153
+ worker_training = utils.Worker(das.train.train, **form_data)
154
+
155
+ pool = QtCore.QThreadPool.globalInstance()
156
+
157
+ def update_progress(queue):
158
+ while True:
159
+ value = queue.get()
160
+
161
+ if value[0] is None or value[0] < 0 or pool.activeThreadCount() == 1:
162
+ utils.invoke_in_main_thread(progress.cancel)
163
+ utils.invoke_in_main_thread(progress.close)
164
+ break # stop this thread
165
+ else:
166
+ utils.invoke_in_main_thread(progress.setValue, value[0])
167
+ utils.invoke_in_main_thread(progress.setLabelText, str(value[1]))
168
+ QtWidgets.QApplication.processEvents()
169
+
170
+ worker_progress = utils.Worker(update_progress, queue)
171
+ pool.start(worker_progress)
172
+ pool.start(worker_training)
173
+ QtWidgets.QApplication.processEvents()
174
+
175
+ def das_predict(self, qt_keycode):
176
+ logger.info("Predicting song using DAS:")
177
+
178
+ if hasattr(self, "ds") and "song_raw" not in self.ds:
179
+ logger.error(" Missing `song_raw`. skipping.")
180
+
181
+ try:
182
+ import das.predict
183
+ import das.utils
184
+ except ImportError as e:
185
+ logger.exception(e)
186
+ logger.info(" Failed to import das. Install via `pip install das`.")
187
+ return
188
+
189
+ dialog = YamlDialog(yaml_file=package_dir + "/gui/forms/das_predict.yaml", title="Predict labels using DAS")
190
+
191
+ # get model path and populate form
192
+ model_path, _ = QtWidgets.QFileDialog.getOpenFileName(None, caption="Open model file (*_model.h5)")
193
+ if len(model_path):
194
+ dialog.form["model_path"] = model_path
195
+ else:
196
+ logger.warning("No model selected.")
197
+ return
198
+
199
+ # populate values for postprocessing from params if they exist
200
+ model_path = model_path.rsplit("_", 1)[0] # split off suffix (_model.h5 or params.yaml)
201
+ params = das.utils.load_params(model_path)
202
+ if "post_opt" in params and isinstance(params["post_opt"], dict):
203
+ dialog.form["segment_fillgap"] = params["post_opt"]["gap_dur"]
204
+ dialog.form["segment_minlen"] = params["post_opt"]["min_len"]
205
+
206
+ # if no file loaded, ask to select file or folder
207
+ if not hasattr(self, "ds"):
208
+ dialog.form["file"] = "Select file or folder"
209
+
210
+ dialog.show()
211
+ result = dialog.exec_()
212
+
213
+ if result == QtWidgets.QDialog.Accepted:
214
+ form_data = dialog.form.get_form_data()
215
+ model_path = form_data["model_path"]
216
+ if model_path == " ":
217
+ logger.warning("No model for prediction selected.")
218
+ return
219
+ else:
220
+ model_path = model_path.rsplit("_", 1)[0] # split off suffix
221
+
222
+ # set these to 0 to avoid post processing - none will use values from params file
223
+ if form_data["segment_fillgap"] is None:
224
+ form_data["segment_fillgap"] = 0
225
+ if form_data["segment_minlen"] is None:
226
+ form_data["segment_minlen"] = 0
227
+
228
+ if form_data["filter_song"] == "no":
229
+ form_data["bandpass_low_freq"] = None
230
+ form_data["bandpass_up_freq"] = None
231
+
232
+ if form_data["file"] != "Current file":
233
+ if form_data["folder"] != " ":
234
+ file_path = form_data["folder"]
235
+ elif form_data["file"] != " ":
236
+ file_path = form_data["file"]
237
+ else:
238
+ logger.warning("No audio data. Either open a file or select a folder or file in the predict dialog.")
239
+ return
240
+
241
+ das.predict.cli_predict(
242
+ file_path,
243
+ model_path,
244
+ verbose=1,
245
+ batch_size=32,
246
+ save_format=form_data["save_format"],
247
+ event_thres=form_data["event_thres"],
248
+ event_dist=form_data["event_dist"],
249
+ event_dist_min=form_data["event_dist_min"],
250
+ event_dist_max=form_data["event_dist_max"],
251
+ segment_thres=form_data["event_thres"],
252
+ segment_fillgap=form_data["segment_fillgap"],
253
+ segment_minlen=form_data["segment_minlen"],
254
+ bandpass_low_freq=form_data["bandpass_low_freq"],
255
+ bandpass_up_freq=form_data["bandpass_up_freq"],
256
+ resample=form_data["resample"],
257
+ )
258
+ return
259
+ elif hasattr(self, "ds") and form_data["file"] == "Current file":
260
+ start_seconds = form_data["start_seconds"]
261
+ start_index = utils.find_nearest_idx(self.ds.sampletime.values, start_seconds)
262
+
263
+ end_seconds = form_data["end_seconds"]
264
+ end_index = end_seconds
265
+ if end_seconds is not None:
266
+ end_index = utils.find_nearest_idx(self.ds.sampletime.values, end_seconds)
267
+
268
+ audio = self.ds.song_raw.data[start_index:end_index]
269
+
270
+ params = das.utils.load_params(model_path)
271
+ if audio.shape[0] < params["nb_hist"]:
272
+ logger.warning(
273
+ f" Aborting. Audio has fewer samples ({audio.shape[0]}) shorter than network chunk size ({params['nb_hist']}). Fix by select longer audio."
274
+ )
275
+ return
276
+
277
+ # select batch size so that at least 10 batches are run
278
+ # minimizes loss of annotations from batch size "quantization" errors
279
+ batch_size = 32
280
+ nb_batches = int(
281
+ np.floor((audio.shape[0] - ((batch_size - 1) + params["nb_hist"])) / (params["stride"] * (batch_size)))
282
+ )
283
+ while nb_batches < 10 and batch_size > 1:
284
+ batch_size -= 1
285
+
286
+ logger.info(" Running inference on audio.")
287
+ logger.info(f" Model from {model_path}.")
288
+ params = das.utils.load_params(model_path)
289
+
290
+ rich.print(form_data)
291
+ events, segments, _, _ = das.predict.predict(
292
+ audio,
293
+ model_path,
294
+ verbose=1,
295
+ batch_size=batch_size,
296
+ event_thres=form_data["event_thres"],
297
+ event_dist=form_data["event_dist"],
298
+ event_dist_min=form_data["event_dist_min"],
299
+ event_dist_max=form_data["event_dist_max"],
300
+ segment_thres=form_data["event_thres"],
301
+ segment_fillgap=form_data["segment_fillgap"],
302
+ segment_minlen=form_data["segment_minlen"],
303
+ bandpass_low_freq=form_data["bandpass_low_freq"],
304
+ bandpass_up_freq=form_data["bandpass_up_freq"],
305
+ resample=form_data["resample"],
306
+ fs_audio=self.fs_song,
307
+ )
308
+
309
+ # Process detected song
310
+ if not events and not segments:
311
+ logger.warning("Found no song.")
312
+ return
313
+
314
+ suffix = ""
315
+ if form_data["proof_reading_mode"]:
316
+ suffix = "_proposals"
317
+
318
+ # events['seconds'] is in samples/fs - translate to time stamps via sample time
319
+ detected_event_names = []
320
+ if "sequence" in events:
321
+ detected_event_names = np.unique(events["sequence"])
322
+
323
+ if len(detected_event_names) > 0 and detected_event_names[0] is not None:
324
+ logger.info(f" found {len(events['seconds'])} instances of events '{detected_event_names}'.")
325
+ event_samples = (np.array(events["seconds"]) * self.fs_song + start_index).astype(np.uintp)
326
+
327
+ # make sure all detected events are within bounds
328
+ event_samples = event_samples[event_samples >= 0]
329
+ event_samples = event_samples[event_samples < self.ds.sampletime.shape[0]]
330
+
331
+ event_seconds = self.ds.sampletime[event_samples]
332
+ for name_or_index, seconds in zip(events["sequence"], event_seconds):
333
+ if type(name_or_index) is int:
334
+ event_name = str(events["names"][name_or_index])
335
+ else:
336
+ event_name = str(name_or_index)
337
+ self.event_times.add_time(event_name + str(suffix), seconds, seconds, category="event")
338
+
339
+ detected_segment_names = []
340
+ if "sequence" in segments: # and len(segments['sequence']): # and segments['sequence'] is not None:
341
+ # segments['sequence'] = [s for s in segments['sequence'] if s is not None]
342
+ detected_segment_names = np.unique(segments["sequence"])
343
+ # if these are indices, get corresponding names
344
+ if (
345
+ len(detected_segment_names)
346
+ and type(detected_segment_names[0]) is not str
347
+ and type(detected_segment_names[0]) is not np.str_
348
+ ):
349
+ detected_segment_names = [segments["names"][ii] for ii in detected_segment_names]
350
+
351
+ if len(detected_segment_names) > 0: # and detected_segment_names[0] is not None:
352
+ logger.info(f" found {len(segments['onsets_seconds'])} instances of segments '{detected_segment_names}'.")
353
+ onsets_samples = (np.array(segments["onsets_seconds"]) * self.fs_song + start_index).astype(np.uintp)
354
+ offsets_samples = (np.array(segments["offsets_seconds"]) * self.fs_song + start_index).astype(np.uintp)
355
+
356
+ # make sure all detected segments are within bounds
357
+ onsets_samples = onsets_samples[onsets_samples >= 0]
358
+ offsets_samples = offsets_samples[offsets_samples >= 0]
359
+ onsets_samples = onsets_samples[onsets_samples < self.ds.sampletime.shape[0]]
360
+ offsets_samples = offsets_samples[offsets_samples < self.ds.sampletime.shape[0]]
361
+
362
+ onsets_seconds = self.ds.sampletime[onsets_samples]
363
+ offsets_seconds = self.ds.sampletime[offsets_samples]
364
+ for name_or_index, onset_seconds, offset_seconds in zip(
365
+ segments["sequence"], onsets_seconds, offsets_seconds
366
+ ):
367
+ if type(name_or_index) is not str and type(detected_segment_names[0]) is not np.str_:
368
+ segment_name = segments["names"][name_or_index]
369
+ else:
370
+ segment_name = str(name_or_index)
371
+
372
+ self.event_times.add_time(segment_name + str(suffix), onset_seconds, offset_seconds, category="segment")
373
+
374
+ self.nb_eventtypes = len(self.event_times)
375
+ self.eventtype_colors = utils.make_colors(self.nb_eventtypes)
376
+ self.update_eventtype_selector()
377
+ logger.info("Done.")
@@ -0,0 +1,167 @@
1
+ main:
2
+
3
+ - name: model_path
4
+ label: Model
5
+ type: file_open
6
+ default: " "
7
+ filter: "*_model.h5"
8
+
9
+
10
+ - name: file
11
+ label: Predict song for
12
+ type: stacked
13
+ options: "Current file,Select file or folder"
14
+ default: "Current file"
15
+
16
+ "Current file":
17
+ - type: text
18
+ text: 'Predict song for the current loaded file.'
19
+
20
+ - name: start_seconds
21
+ label: Start seconds
22
+ type: double
23
+ default: 0.0
24
+ decimals: 4
25
+ range: 0.0,10000000.0
26
+
27
+ - name: end_seconds
28
+ label: End seconds
29
+ type: optional_double
30
+ default: 0.0
31
+ default_disabled: True
32
+ none_label: Recording end
33
+ decimals: 4
34
+ range: 0.0,1000000.0
35
+
36
+
37
+ "Select file or folder":
38
+ - type: text
39
+ text: 'Predict song for a selected file or all files in a folder.'
40
+
41
+ - name: folder
42
+ label: 'folder'
43
+ type: file_dir
44
+ default: " "
45
+
46
+ - name: file
47
+ label: 'file'
48
+ type: file_open
49
+ default: " "
50
+
51
+ - name: save_format
52
+ label: Annotation file format
53
+ type: list
54
+ default: csv
55
+ options: csv,h5
56
+
57
+ - type: text
58
+ text: 'csv: tabular text file with label, start and end seconds for each predicted song.<br>
59
+ h5: more stuff.'
60
+
61
+
62
+ - name: proof_reading_mode
63
+ label: Proof reading mode
64
+ type: bool
65
+ default: True
66
+ help: Appends '_proposals' to song name. Individual proposals can be corrected and approved.
67
+
68
+ - name: resample
69
+ label: Resample audio to rate used for training
70
+ type: bool
71
+ default: True
72
+
73
+ - name: filter_song
74
+ label: Bandpass filter audio
75
+ type: stacked
76
+ default: "no"
77
+ options: "no,yes"
78
+
79
+ "no":
80
+
81
+ "yes":
82
+ - name: bandpass_low_freq
83
+ label: Lower cutoff
84
+ type: double
85
+ default: 50.0
86
+ range: 0.0, 1000000.0
87
+
88
+ - name: bandpass_up_freq
89
+ label: Upper cutoff
90
+ type: double
91
+ default: 10000.0
92
+ range: 0.0, 1000000.0
93
+
94
+ - type: text
95
+ text: '<b>Event detection</b>'
96
+
97
+ - name: event_thres
98
+ label: Threshold
99
+ type: double
100
+ default: 0.5
101
+ range: 0,1
102
+
103
+ - name: event_dist
104
+ label: Minimal event interval for detection (seconds)
105
+ type: double
106
+ default: 0.01
107
+ decimals: 4
108
+ range: 0,100000
109
+
110
+ - type: text
111
+ text: '<i>Filter events by interval after detection</i><br />
112
+ Will discard events that come too close (minimal distance) or
113
+ too far (maximal distance) after other events.'
114
+
115
+ - name: event_dist_min
116
+ label: Delete events closer than (seconds)
117
+ type: double
118
+ default: 0.0
119
+ decimals: 4
120
+ range: 0,100000
121
+
122
+ - name: event_dist_max
123
+ label: Delete events farther than (seconds)
124
+ type: optional_double
125
+ default: 1
126
+ default_disabled: True
127
+ none_label: infinity
128
+ decimals: 4
129
+ range: 0,100000
130
+
131
+
132
+ - type: text
133
+ text: '<b>Segment detection</b>'
134
+
135
+ - name: segment_thres
136
+ label: Threshold
137
+ type: double
138
+ default: 0.5
139
+ decimals: 2
140
+ range: 0,1
141
+
142
+ - type: text
143
+ text: '<i>Post process segments</i><br />
144
+ Will fill short gaps within a segement and discard short segments.'
145
+
146
+ - name: segment_fillgap
147
+ label: Fill gaps shorter than (seconds)
148
+ type: optional_double
149
+ default: 0.02
150
+ default_disabled: True
151
+ none_label: Do not fill
152
+ decimals: 4
153
+ range: 0,1000000
154
+
155
+ - name: segment_minlen
156
+ label: Delete segments shorter than (seconds)
157
+ type: optional_double
158
+ default: 0.02
159
+ default_disabled: True
160
+ none_label: Do not delete
161
+ decimals: 4
162
+ range: 0,1000000
163
+
164
+ - name: save_button
165
+ label: Predict song labels
166
+ type: button
167
+ default: main action
@@ -0,0 +1,264 @@
1
+ main:
2
+
3
+ - type: text
4
+ text: '<b>Data set</b><br />'
5
+
6
+ - name: data_dir
7
+ label: Data directory
8
+ type: file_dir
9
+ default: " "
10
+ filter: "*.npy"
11
+ help: '<b>Directory should be created with <b>Multi-Animal Bottom-Up Pipeline</b>:<br />
12
+ This pipeline uses single model with two output heads:
13
+ a "<u>confidence map</u>" head to predicts the
14
+ nodes for an entire image and a "<u>part affinity field</u>" head to group
15
+ the nodes into distinct animal instances.'
16
+
17
+ - name: save_dir
18
+ label: Save directory
19
+ type: file_dir
20
+ default: " "
21
+
22
+
23
+ - name: save_prefix
24
+ label: Prefix for saved files
25
+ type: string
26
+ default: ""
27
+ help: Results will be save as "{save_dir}/{save_prefix}_YYYYMMDD_HHMMSS"
28
+
29
+ # populate as list from dataset
30
+ - name: y_suffix
31
+ label: Song type
32
+ type: optional_list
33
+ help: 'Select song type to fit the network to. If nothing is selected, will fit network for all targets in the data set'
34
+
35
+ - name: fraction_data
36
+ label: Data fraction
37
+ type: optional_double
38
+ none_label: Use all
39
+ default_disabled: True
40
+ default: 0.1
41
+ decimals: 3
42
+ range: 0,1
43
+ help: 'Fraction of data to use for training. Use smaller fractions to speed up training at the expense of poor performance.'
44
+
45
+ - name: seed
46
+ label: Seed
47
+ type: optional_int
48
+ none_label: No seed
49
+ default_disabled: True
50
+ default: 1
51
+ range: 1,1000
52
+ help: 'Random seed to reproducibly select data fractions.'
53
+
54
+ - name: version_data
55
+ label: Version training data
56
+ type: bool
57
+ default: True
58
+ help: Calculate and save a hash of the dataset used for training.
59
+
60
+ - name: balance
61
+ label: Balance classes
62
+ type: bool
63
+ default: False
64
+ help: Balance classes. Helps if song is extremely sparse.
65
+
66
+ - type: text
67
+ text: '<b>Network parameters</b><br />'
68
+
69
+ - name: frontend
70
+ label: Downsampling frontend
71
+ type: stacked
72
+
73
+ default: "STFT"
74
+ options: "None,STFT" #,TCN"
75
+
76
+ "None":
77
+
78
+ "STFT":
79
+ - name: nb_pre_conv
80
+ label: Downsample factor
81
+ type: list
82
+ default: 16
83
+ options: 1,2,4,8,16,32,64,128
84
+
85
+ - name: pre_nb_dft
86
+ label: Number of frequency bands
87
+ type: int
88
+ default: 64
89
+ range: 1,1000
90
+
91
+
92
+ # "TCN":
93
+ # - name: pre_nb_filters
94
+ # label: Number of filters
95
+ # type: int
96
+ # default: 16
97
+ # range: 1,1000
98
+
99
+ # - name: pre_kernel_size
100
+ # label: Filter duration
101
+ # type: int
102
+ # default: 16
103
+ # range: 1,1000
104
+
105
+ # - name: pre_nb_conv
106
+ # label: Downsample factor
107
+ # type: list
108
+ # default: 16
109
+ # options: 1,2,4,8,16,32,64,128
110
+
111
+ - name: nb_hist
112
+ label: Chunk duration (samples)
113
+ type: int
114
+ default: 1024
115
+ range: 1,100000
116
+ help: Number of samples processed at once. Sets the maximal temporal context available for inference.
117
+
118
+ - name: ignore_boundaries
119
+ label: Ignore boundaries
120
+ type: bool
121
+ default: True
122
+ help: Reduces edge effects by discarding predictions at the chunk boundaries and running with overlapping chunks.
123
+
124
+ - name: nb_filters
125
+ label: Number of filters
126
+ type: int
127
+ default: 32
128
+ range: 1,1024
129
+
130
+ - name: kernel_size
131
+ label: Filter duration (samples)
132
+ type: int
133
+ default: 16
134
+ range: 1,1000
135
+
136
+ - name: nb_conv
137
+ label: Number of TCN blocks
138
+ type: int
139
+ default: 3
140
+ range: 1,100
141
+
142
+ # should be multi_checkbox with nb_conv checkboxes
143
+ - name: use_separable
144
+ label: Separable TCN blocks
145
+ type: string_list
146
+ default: "False False False"
147
+ help: 'One boolean ("True" or "False") per TCN block. Separate by spaces.
148
+ Produces networks with better performance with less training data.
149
+ Only the first few blocks should be made separable if at all.'
150
+
151
+ - name: nb_lstm_units
152
+ label: Number of LSTM units
153
+ type: optional_int
154
+ none_label: No LSTM
155
+ default_disabled: True
156
+ default: 128
157
+ range: 0,10000
158
+ help: Reduce learning rate if performance does not improve after patience epochs.
159
+
160
+
161
+ - name: postopt
162
+ label: Optimize postprocessing
163
+ type: stacked
164
+ default: "No"
165
+ options: "No,Yes"
166
+
167
+ "No":
168
+
169
+ "Yes":
170
+ - type: text
171
+ text: 'Will bruteforce grid search using training data. Can take a while and be memory intensive.
172
+ <b>Only use with small-ish training datasets.</b> Otherwise you will get an out-of-memory error
173
+ and the post-optimization will fail. However, you will still be able to use the trained network.'
174
+
175
+ - type: text
176
+ text: '<i>Fill gaps shorter than a threshold</i>'
177
+
178
+ - name: post_opt_fill_gaps_min
179
+ label: Minimal gap size to try (seconds)
180
+ type: float
181
+ default: 0.001
182
+ range: 0.001,1000
183
+ - name: post_opt_fill_gaps_max
184
+ label: Maximal gap size to try (seconds)
185
+ type: float
186
+ default: 0.1
187
+ range: 0.002,1000
188
+ - name: post_opt_fill_gaps_steps
189
+ label: Number gap sizes to try (min->max, log2-spaced)
190
+ type: int
191
+ default: 10
192
+ range: 1,100
193
+
194
+ - type: text
195
+ text: '<i>Remove syllables shorter than a threshold</i>'
196
+
197
+ - name: post_opt_min_len_min
198
+ label: Minimal duration to try (seconds)
199
+ type: float
200
+ default: 0.001
201
+ range: 0.001,1000
202
+ - name: post_opt_min_len_max
203
+ label: Maximal duration to try (seconds)
204
+ type: float
205
+ default: 0.1
206
+ range: 0.002,1000
207
+ - name: post_opt_min_len_steps
208
+ label: Number of durations to try (min->max, log2-spaced)
209
+ type: int
210
+ default: 10
211
+ range: 1,100
212
+
213
+
214
+ - type: text
215
+ text: '<b>Training parameters</b>'
216
+
217
+ - name: batch_size
218
+ label: Batch size
219
+ type: int
220
+ range: 0,100000
221
+ default: 32
222
+
223
+ - name: learning_rate
224
+ label: Learning rate
225
+ type: double
226
+ decimals: 6
227
+ default: 0.0001
228
+
229
+ - name: reduce_lr_patience
230
+ label: Reduce learning rate patience
231
+ type: optional_int
232
+ none_label: No reduction
233
+ default_disabled: True
234
+ default: 4
235
+ help: Reduce learning rate if performance does not improve after patience epochs.
236
+
237
+ - name: nb_epoch
238
+ label: Number of epochs
239
+ type: int
240
+ default: 400
241
+ range: 1,100000
242
+ help: Maximal number of training epochs. Will stop early if performance does not improve for 20 epochs.
243
+
244
+ - name: tensorboard
245
+ label: Create tensorboard logs
246
+ type: bool
247
+ default: False
248
+
249
+ - name: load
250
+ label: Load config
251
+ type: button
252
+
253
+ - name: save
254
+ label: Save config
255
+ type: button
256
+
257
+ - name: make_cli
258
+ label: Save runtime script
259
+ type: button
260
+
261
+ - name: train
262
+ label: Start training in GUI
263
+ type: button
264
+ default: main action
File without changes
File without changes