bioaccx 0.1.0__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 (113) hide show
  1. bioaccx-0.1.0/.gitignore +15 -0
  2. bioaccx-0.1.0/.python-version +1 -0
  3. bioaccx-0.1.0/LICENSE +21 -0
  4. bioaccx-0.1.0/PKG-INFO +229 -0
  5. bioaccx-0.1.0/README.md +184 -0
  6. bioaccx-0.1.0/README.pt-BR.md +189 -0
  7. bioaccx-0.1.0/bioaccx/__init__.py +6 -0
  8. bioaccx-0.1.0/bioaccx/__main__.py +10 -0
  9. bioaccx-0.1.0/bioaccx/_click.py +49 -0
  10. bioaccx-0.1.0/bioaccx/_legacy_cli.py +166 -0
  11. bioaccx-0.1.0/bioaccx/arbimon.py +228 -0
  12. bioaccx-0.1.0/bioaccx/audio.py +142 -0
  13. bioaccx-0.1.0/bioaccx/audio_mixup.py +260 -0
  14. bioaccx-0.1.0/bioaccx/cli.py +638 -0
  15. bioaccx-0.1.0/bioaccx/config.py +613 -0
  16. bioaccx-0.1.0/bioaccx/convert_head.py +501 -0
  17. bioaccx-0.1.0/bioaccx/dataset.py +2079 -0
  18. bioaccx-0.1.0/bioaccx/embedder.py +374 -0
  19. bioaccx-0.1.0/bioaccx/embeddings_sqlite.py +88 -0
  20. bioaccx-0.1.0/bioaccx/exporters/__init__.py +4 -0
  21. bioaccx-0.1.0/bioaccx/exporters/onnx_exporter.py +360 -0
  22. bioaccx-0.1.0/bioaccx/exporters/tflite_exporter.py +308 -0
  23. bioaccx-0.1.0/bioaccx/extract_head.py +471 -0
  24. bioaccx-0.1.0/bioaccx/gui/__init__.py +13 -0
  25. bioaccx-0.1.0/bioaccx/gui/audio.py +143 -0
  26. bioaccx-0.1.0/bioaccx/gui/configio.py +145 -0
  27. bioaccx-0.1.0/bioaccx/gui/i18n.py +98 -0
  28. bioaccx-0.1.0/bioaccx/gui/jobs.py +271 -0
  29. bioaccx-0.1.0/bioaccx/gui/locales/en.json +207 -0
  30. bioaccx-0.1.0/bioaccx/gui/locales/pt-BR.json +752 -0
  31. bioaccx-0.1.0/bioaccx/gui/results.py +497 -0
  32. bioaccx-0.1.0/bioaccx/gui/schema.py +318 -0
  33. bioaccx-0.1.0/bioaccx/gui/server.py +607 -0
  34. bioaccx-0.1.0/bioaccx/gui/web/app.js +638 -0
  35. bioaccx-0.1.0/bioaccx/gui/web/explorer.js +627 -0
  36. bioaccx-0.1.0/bioaccx/gui/web/form.js +612 -0
  37. bioaccx-0.1.0/bioaccx/gui/web/i18n.js +97 -0
  38. bioaccx-0.1.0/bioaccx/gui/web/index.html +201 -0
  39. bioaccx-0.1.0/bioaccx/gui/web/styles.css +794 -0
  40. bioaccx-0.1.0/bioaccx/gui/web/theme.js +66 -0
  41. bioaccx-0.1.0/bioaccx/inat.py +121 -0
  42. bioaccx-0.1.0/bioaccx/registry.py +215 -0
  43. bioaccx-0.1.0/bioaccx/report.py +1030 -0
  44. bioaccx-0.1.0/bioaccx/ssh.py +192 -0
  45. bioaccx-0.1.0/bioaccx/train.py +1521 -0
  46. bioaccx-0.1.0/bioaccx/trainers/__init__.py +4 -0
  47. bioaccx-0.1.0/bioaccx/trainers/grouped.py +257 -0
  48. bioaccx-0.1.0/bioaccx/trainers/keras_trainer.py +461 -0
  49. bioaccx-0.1.0/bioaccx/trainers/sklearn_trainer.py +53 -0
  50. bioaccx-0.1.0/bioaccx/umap.py +405 -0
  51. bioaccx-0.1.0/bioaccx/xc.py +171 -0
  52. bioaccx-0.1.0/docs/README.md +24 -0
  53. bioaccx-0.1.0/docs/en/augmentation.md +135 -0
  54. bioaccx-0.1.0/docs/en/cli.md +163 -0
  55. bioaccx-0.1.0/docs/en/config-reference.md +201 -0
  56. bioaccx-0.1.0/docs/en/configuration.md +333 -0
  57. bioaccx-0.1.0/docs/en/dataset-modes.md +270 -0
  58. bioaccx-0.1.0/docs/en/embeddings-umap.md +113 -0
  59. bioaccx-0.1.0/docs/en/gui.md +219 -0
  60. bioaccx-0.1.0/docs/en/installation.md +187 -0
  61. bioaccx-0.1.0/docs/en/model-surgery.md +211 -0
  62. bioaccx-0.1.0/docs/en/outputs.md +224 -0
  63. bioaccx-0.1.0/docs/en/python-api.md +61 -0
  64. bioaccx-0.1.0/docs/en/quickstart.md +27 -0
  65. bioaccx-0.1.0/docs/en/registry.md +64 -0
  66. bioaccx-0.1.0/docs/en/remote-sources.md +105 -0
  67. bioaccx-0.1.0/docs/pt-BR/config-reference.md +203 -0
  68. bioaccx-0.1.0/docs/pt-BR/gui.md +230 -0
  69. bioaccx-0.1.0/docs/pt-BR/installation.md +190 -0
  70. bioaccx-0.1.0/docs/pt-BR/quickstart.md +28 -0
  71. bioaccx-0.1.0/example_config.yaml +414 -0
  72. bioaccx-0.1.0/pyproject.toml +93 -0
  73. bioaccx-0.1.0/scripts/install.ps1 +70 -0
  74. bioaccx-0.1.0/scripts/install.sh +95 -0
  75. bioaccx-0.1.0/tests/__init__.py +0 -0
  76. bioaccx-0.1.0/tests/conftest.py +272 -0
  77. bioaccx-0.1.0/tests/integration/__init__.py +0 -0
  78. bioaccx-0.1.0/tests/integration/test_audio_mixup.py +534 -0
  79. bioaccx-0.1.0/tests/integration/test_cli_modes.py +174 -0
  80. bioaccx-0.1.0/tests/integration/test_e2e.py +336 -0
  81. bioaccx-0.1.0/tests/integration/test_embeddings_umap.py +246 -0
  82. bioaccx-0.1.0/tests/integration/test_export_softmax_filter.py +216 -0
  83. bioaccx-0.1.0/tests/integration/test_exporters.py +296 -0
  84. bioaccx-0.1.0/tests/integration/test_gui_server.py +641 -0
  85. bioaccx-0.1.0/tests/integration/test_pipeline.py +964 -0
  86. bioaccx-0.1.0/tests/unit/__init__.py +0 -0
  87. bioaccx-0.1.0/tests/unit/test_audio.py +229 -0
  88. bioaccx-0.1.0/tests/unit/test_blocks.py +107 -0
  89. bioaccx-0.1.0/tests/unit/test_cli.py +206 -0
  90. bioaccx-0.1.0/tests/unit/test_cli_subcommands.py +403 -0
  91. bioaccx-0.1.0/tests/unit/test_config.py +476 -0
  92. bioaccx-0.1.0/tests/unit/test_convert_head.py +345 -0
  93. bioaccx-0.1.0/tests/unit/test_dataset.py +2048 -0
  94. bioaccx-0.1.0/tests/unit/test_docs.py +96 -0
  95. bioaccx-0.1.0/tests/unit/test_embedder.py +118 -0
  96. bioaccx-0.1.0/tests/unit/test_embeddings_sqlite.py +500 -0
  97. bioaccx-0.1.0/tests/unit/test_encoding.py +70 -0
  98. bioaccx-0.1.0/tests/unit/test_extract_head.py +132 -0
  99. bioaccx-0.1.0/tests/unit/test_grouped.py +122 -0
  100. bioaccx-0.1.0/tests/unit/test_grouped_trainer.py +114 -0
  101. bioaccx-0.1.0/tests/unit/test_gui_audio.py +136 -0
  102. bioaccx-0.1.0/tests/unit/test_gui_configio.py +126 -0
  103. bioaccx-0.1.0/tests/unit/test_gui_i18n.py +181 -0
  104. bioaccx-0.1.0/tests/unit/test_gui_jobs.py +302 -0
  105. bioaccx-0.1.0/tests/unit/test_gui_results.py +394 -0
  106. bioaccx-0.1.0/tests/unit/test_gui_schema.py +210 -0
  107. bioaccx-0.1.0/tests/unit/test_gui_web.py +88 -0
  108. bioaccx-0.1.0/tests/unit/test_keras_trainer.py +85 -0
  109. bioaccx-0.1.0/tests/unit/test_registry.py +112 -0
  110. bioaccx-0.1.0/tests/unit/test_report.py +510 -0
  111. bioaccx-0.1.0/tests/unit/test_umap_colors.py +69 -0
  112. bioaccx-0.1.0/tools/gen_docs.py +377 -0
  113. bioaccx-0.1.0/uv.lock +2250 -0
@@ -0,0 +1,15 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+
12
+ # output results
13
+ custom_models/
14
+ .cache/
15
+ test_config.yaml
@@ -0,0 +1 @@
1
+ 3.12
bioaccx-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 biodiversica
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
bioaccx-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,229 @@
1
+ Metadata-Version: 2.5
2
+ Name: bioaccx
3
+ Version: 0.1.0
4
+ Summary: Bioacoustic neural network custom classifier generator
5
+ Project-URL: Homepage, https://github.com/biodiversica/bioaccx
6
+ Project-URL: Documentation, https://github.com/biodiversica/bioaccx/tree/master/docs
7
+ Project-URL: Issues, https://github.com/biodiversica/bioaccx/issues
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Requires-Python: >=3.12
11
+ Requires-Dist: huggingface-hub>=0.20
12
+ Requires-Dist: kagglehub>=1.0.1
13
+ Requires-Dist: numpy>=1.26
14
+ Requires-Dist: onnx>=1.15
15
+ Requires-Dist: onnxconverter-common>=1.14
16
+ Requires-Dist: paramiko>=5.0.0
17
+ Requires-Dist: pyyaml>=6.0
18
+ Requires-Dist: scikit-learn>=1.4
19
+ Requires-Dist: scipy>=1.11
20
+ Requires-Dist: skl2onnx>=1.17
21
+ Requires-Dist: soundfile>=0.12
22
+ Requires-Dist: sympy>=1.12
23
+ Requires-Dist: tensorflow-cpu>=2.16; sys_platform == 'win32' or (sys_platform == 'linux' and platform_machine == 'x86_64')
24
+ Requires-Dist: tensorflow>=2.16; sys_platform == 'darwin' or (sys_platform == 'linux' and platform_machine == 'aarch64')
25
+ Requires-Dist: tf2onnx>=1.16
26
+ Requires-Dist: typer>=0.27
27
+ Provides-Extra: arbimon
28
+ Provides-Extra: cpu
29
+ Requires-Dist: onnxruntime>=1.17; extra == 'cpu'
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest-xdist>=3.5; extra == 'dev'
32
+ Requires-Dist: pytest>=8.0; extra == 'dev'
33
+ Provides-Extra: gpu
34
+ Requires-Dist: onnxruntime-gpu>=1.19; extra == 'gpu'
35
+ Provides-Extra: gui
36
+ Requires-Dist: fastapi>=0.110; extra == 'gui'
37
+ Requires-Dist: ruamel-yaml>=0.18; extra == 'gui'
38
+ Requires-Dist: uvicorn>=0.27; extra == 'gui'
39
+ Provides-Extra: ssh
40
+ Requires-Dist: paramiko>=3.0; extra == 'ssh'
41
+ Provides-Extra: umap
42
+ Requires-Dist: matplotlib>=3.11.0; extra == 'umap'
43
+ Requires-Dist: umap-learn>=0.5.12; extra == 'umap'
44
+ Description-Content-Type: text/markdown
45
+
46
+ # bioaccx
47
+
48
+ **BIOAcoustic Custom Classifier eXchange** — a Python CLI tool for training and sharing custom bioacoustic classifiers on top of pre-trained foundation models such as [BirdNET](https://birdnet.cornell.edu/) and [Perch](https://www.kaggle.com/models/google/bird-vocalization-classifier).
49
+
50
+ The core idea is a clean separation between the **backbone** and the **classifier head**:
51
+
52
+ - The backbone (foundation model) is a large, general-purpose audio encoder shared by the community.
53
+ - The head is a small, task-specific classifier trained on your labeled data — just a few kilobytes.
54
+
55
+ This separation enables two complementary workflows:
56
+
57
+ **Share lightweight heads.** Because the head is tiny compared to the backbone, you can publish and distribute your custom classifier without bundling the full model. Anyone who already has the same backbone can load your head and run inference immediately.
58
+
59
+ **Deploy as a single file.** When you need a self-contained model — for edge devices, cloud APIs, or third-party tools — bioaccx can merge the backbone and head into one ONNX or TFLite file with a single audio input and class-score output.
60
+
61
+ **Skip re-embedding when you already have embeddings.** If you or your team have already run the backbone and saved the resulting embedding vectors, you can point bioaccx at that cache and train or evaluate the head directly — no audio processing, no GPU time, no waiting.
62
+
63
+ **Build datasets from multiple sources in one config.** bioaccx can assemble training data from local recordings, [iNaturalist](https://www.inaturalist.org/) observations, [Xeno-canto](https://xeno-canto.org/) recordings, and [Arbimon](https://arbimon.org/) projects — all mixed in a single table or combined with a local directory. Remote audio is downloaded and cached automatically, so subsequent runs skip the network entirely.
64
+
65
+ bioaccx handles the full pipeline from raw audio to exported model, driven by a single config file.
66
+
67
+ ---
68
+
69
+ > 🇧🇷 [Leia em português](README.pt-BR.md)
70
+
71
+ ---
72
+
73
+ ## How it works
74
+
75
+ ```
76
+ Audio files → Foundation model (backbone) → Embeddings
77
+ ↓
78
+ Keras or sklearn classifier head
79
+ ↓
80
+ ┌────────────────────────────────────────┐
81
+ │ backbone + head merged │ head only │
82
+ │ (single-file deploy) │ (shareable) │
83
+ └────────────────────────────────────────┘
84
+ ```
85
+
86
+ 1. **Foundation model** — a backbone version of a bioacoustic model extracts rich feature vectors from raw audio windows. Supported formats: ONNX, TFLite, TF SavedModel (protobuf).
87
+ 2. **Classifier head** — a small Keras MLP or sklearn LogisticRegression is trained on top of those embeddings using your labeled data.
88
+ 3. **Export** — choose between:
89
+ - **Full model** (`output_type: full`): merges backbone + head into a single ONNX or TFLite graph. Drop-in inference with no external dependencies.
90
+ - **Head only** (`output_type: head`): exports just the classifier. Tiny file, easy to share; requires the backbone at inference time.
91
+ - **Both** (`output_type: both`): produces both variants.
92
+
93
+ ---
94
+
95
+ ---
96
+
97
+ ## Installation
98
+
99
+ **No Python needed.** The installer sets everything up and adds a **bioaccx**
100
+ shortcut that opens the [browser GUI](#the-browser-gui). Run it again to upgrade.
101
+
102
+ Windows — open PowerShell and paste:
103
+
104
+ ```powershell
105
+ powershell -ExecutionPolicy ByPass -c "irm https://github.com/biodiversica/bioaccx/releases/latest/download/install.ps1 | iex"
106
+ ```
107
+
108
+ macOS (Apple Silicon) and Linux — open a terminal and paste:
109
+
110
+ ```sh
111
+ curl -LsSf https://github.com/biodiversica/bioaccx/releases/latest/download/install.sh | sh
112
+ ```
113
+
114
+ **With uv or pip.** bioaccx runs models through ONNX Runtime, and **there is no
115
+ default one** — pick `cpu` or `gpu` when you install. A plain `bioaccx` resolves
116
+ and installs happily, then fails the moment it tries to run a model, so the
117
+ extra is not optional in practice.
118
+
119
+ ```bash
120
+ uv tool install --python 3.12 "bioaccx[cpu]" # CPU inference
121
+ uv tool install --python 3.12 "bioaccx[gpu]" # CUDA 12
122
+ uv tool install --python 3.12 "bioaccx[cpu,gui,umap]" # with the browser GUI and UMAP plots
123
+
124
+ uv add "bioaccx[cpu]" # or as a project dependency
125
+ ```
126
+
127
+ Extras go **inside the brackets** — `uv tool install` has no `--extra` flag — and
128
+ the whole argument needs quoting so the shell does not glob them. `--python`
129
+ keeps uv off a Python newer than TensorFlow supports.
130
+
131
+ See [Installation](docs/en/installation.md) for what the installer does, the
132
+ extras table, supported systems, working on bioaccx itself, GPU acceleration
133
+ with CUDA, and how much disk this needs.
134
+
135
+ ---
136
+
137
+ ## Quick start
138
+
139
+ ```bash
140
+ # 0. Browse available foundation models and their registry IDs
141
+ bioaccx registry
142
+
143
+ # 1. Copy and edit the example config
144
+ cp example_config.yaml my_config.yaml
145
+
146
+ # 2. Validate config without running training
147
+ bioaccx validate my_config.yaml
148
+
149
+ # 3. Export the dataset as chunked WAV files (no model needed)
150
+ bioaccx dataset my_config.yaml
151
+
152
+ # 4. Compute the embedding database + UMAP (no training)
153
+ bioaccx embeddings my_config.yaml
154
+
155
+ # 5. Train and export
156
+ bioaccx train my_config.yaml
157
+ ```
158
+
159
+ `bioaccx merge` and `bioaccx extract-head` do the same jobs without training —
160
+ see [Merging, extracting and converting heads](docs/en/model-surgery.md).
161
+
162
+ ---
163
+
164
+ ## The browser GUI
165
+
166
+ `bioaccx gui` opens a config editor in a browser. It writes the same YAML files
167
+ every other command reads — the terminal stays the way runs are started.
168
+
169
+ ```bash
170
+ uv tool install "bioaccx[cpu,gui]" # the GUI needs the [gui] extra
171
+
172
+ bioaccx gui # start from a template
173
+ bioaccx gui my_config.yaml # open an existing config
174
+ bioaccx gui --lang pt-BR # open it in Portuguese
175
+ ```
176
+
177
+ The form is generated from the config dataclasses, so it offers exactly the keys
178
+ this version understands, with their real defaults and help text; the file it
179
+ writes is shown beside it as you type, and your comments survive the round-trip.
180
+ The **run** tab starts a command on that config and streams its log into the
181
+ page; the **analysis** tab reads what past runs wrote — metrics, the UMAP map
182
+ with the audio behind each point, and two runs side by side.
183
+
184
+ See [The browser GUI](docs/en/gui.md) for all of it, including
185
+ [interface languages](docs/en/gui.md#interface-languages) and serving the editor
186
+ to another machine.
187
+
188
+ ---
189
+
190
+ ## Configuration
191
+
192
+ Everything a run does is described by one YAML file:
193
+ [`example_config.yaml`](example_config.yaml) is a working starting point,
194
+ [Configuration](docs/en/configuration.md) explains it section by section, and
195
+ [Config reference](docs/en/config-reference.md) lists every key with its default.
196
+
197
+ ---
198
+
199
+ ## Documentation
200
+
201
+ The full documentation lives in [`docs/en/`](docs/en/). This page covers what
202
+ bioaccx is, how to install it, and how to get a first run out of it.
203
+
204
+ | Page | What is in it |
205
+ |---|---|
206
+ | [Installation](docs/en/installation.md) | Install paths, the extras table, GPU acceleration, disk space |
207
+ | [Quick start](docs/en/quickstart.md) | The commands of a first run, in order |
208
+ | [The browser GUI](docs/en/gui.md) | `bioaccx gui` — config editor, results explorer, interface languages |
209
+ | [Configuration](docs/en/configuration.md) | The config file section by section, with worked examples |
210
+ | [Config reference](docs/en/config-reference.md) | Every config key, its default and its help text |
211
+ | [Datasets](docs/en/dataset-modes.md) | Label layouts, train/test split, appending, combining sources |
212
+ | [Remote sound sources](docs/en/remote-sources.md) | iNaturalist, Xeno-canto and Arbimon rows in one table |
213
+ | [Augmentation and windowing](docs/en/augmentation.md) | Noise augmentation, random shift, windows and overlap |
214
+ | [Embeddings, cache and UMAP](docs/en/embeddings-umap.md) | The embedding store, `bioaccx embeddings`, UMAP and KMeans/NMI |
215
+ | [Outputs](docs/en/outputs.md) | Directory structure, metadata, precision, excluding labels |
216
+ | [Merging, extracting and converting heads](docs/en/model-surgery.md) | `merge`, `extract-head`, `convert-head` |
217
+ | [Foundation model registry](docs/en/registry.md) | Registry IDs, supported models, adding a new one |
218
+ | [Python API](docs/en/python-api.md) | Using bioaccx as a library |
219
+ | [CLI reference](docs/en/cli.md) | Every command and option |
220
+
221
+ The config and CLI references are generated from the code by
222
+ `tools/gen_docs.py`, so they cannot drift behind it — see
223
+ [`docs/README.md`](docs/README.md).
224
+
225
+ ---
226
+
227
+ ## License
228
+
229
+ [MIT](LICENSE)
@@ -0,0 +1,184 @@
1
+ # bioaccx
2
+
3
+ **BIOAcoustic Custom Classifier eXchange** — a Python CLI tool for training and sharing custom bioacoustic classifiers on top of pre-trained foundation models such as [BirdNET](https://birdnet.cornell.edu/) and [Perch](https://www.kaggle.com/models/google/bird-vocalization-classifier).
4
+
5
+ The core idea is a clean separation between the **backbone** and the **classifier head**:
6
+
7
+ - The backbone (foundation model) is a large, general-purpose audio encoder shared by the community.
8
+ - The head is a small, task-specific classifier trained on your labeled data — just a few kilobytes.
9
+
10
+ This separation enables two complementary workflows:
11
+
12
+ **Share lightweight heads.** Because the head is tiny compared to the backbone, you can publish and distribute your custom classifier without bundling the full model. Anyone who already has the same backbone can load your head and run inference immediately.
13
+
14
+ **Deploy as a single file.** When you need a self-contained model — for edge devices, cloud APIs, or third-party tools — bioaccx can merge the backbone and head into one ONNX or TFLite file with a single audio input and class-score output.
15
+
16
+ **Skip re-embedding when you already have embeddings.** If you or your team have already run the backbone and saved the resulting embedding vectors, you can point bioaccx at that cache and train or evaluate the head directly — no audio processing, no GPU time, no waiting.
17
+
18
+ **Build datasets from multiple sources in one config.** bioaccx can assemble training data from local recordings, [iNaturalist](https://www.inaturalist.org/) observations, [Xeno-canto](https://xeno-canto.org/) recordings, and [Arbimon](https://arbimon.org/) projects — all mixed in a single table or combined with a local directory. Remote audio is downloaded and cached automatically, so subsequent runs skip the network entirely.
19
+
20
+ bioaccx handles the full pipeline from raw audio to exported model, driven by a single config file.
21
+
22
+ ---
23
+
24
+ > 🇧🇷 [Leia em português](README.pt-BR.md)
25
+
26
+ ---
27
+
28
+ ## How it works
29
+
30
+ ```
31
+ Audio files → Foundation model (backbone) → Embeddings
32
+ ↓
33
+ Keras or sklearn classifier head
34
+ ↓
35
+ ┌────────────────────────────────────────┐
36
+ │ backbone + head merged │ head only │
37
+ │ (single-file deploy) │ (shareable) │
38
+ └────────────────────────────────────────┘
39
+ ```
40
+
41
+ 1. **Foundation model** — a backbone version of a bioacoustic model extracts rich feature vectors from raw audio windows. Supported formats: ONNX, TFLite, TF SavedModel (protobuf).
42
+ 2. **Classifier head** — a small Keras MLP or sklearn LogisticRegression is trained on top of those embeddings using your labeled data.
43
+ 3. **Export** — choose between:
44
+ - **Full model** (`output_type: full`): merges backbone + head into a single ONNX or TFLite graph. Drop-in inference with no external dependencies.
45
+ - **Head only** (`output_type: head`): exports just the classifier. Tiny file, easy to share; requires the backbone at inference time.
46
+ - **Both** (`output_type: both`): produces both variants.
47
+
48
+ ---
49
+
50
+ ---
51
+
52
+ ## Installation
53
+
54
+ **No Python needed.** The installer sets everything up and adds a **bioaccx**
55
+ shortcut that opens the [browser GUI](#the-browser-gui). Run it again to upgrade.
56
+
57
+ Windows — open PowerShell and paste:
58
+
59
+ ```powershell
60
+ powershell -ExecutionPolicy ByPass -c "irm https://github.com/biodiversica/bioaccx/releases/latest/download/install.ps1 | iex"
61
+ ```
62
+
63
+ macOS (Apple Silicon) and Linux — open a terminal and paste:
64
+
65
+ ```sh
66
+ curl -LsSf https://github.com/biodiversica/bioaccx/releases/latest/download/install.sh | sh
67
+ ```
68
+
69
+ **With uv or pip.** bioaccx runs models through ONNX Runtime, and **there is no
70
+ default one** — pick `cpu` or `gpu` when you install. A plain `bioaccx` resolves
71
+ and installs happily, then fails the moment it tries to run a model, so the
72
+ extra is not optional in practice.
73
+
74
+ ```bash
75
+ uv tool install --python 3.12 "bioaccx[cpu]" # CPU inference
76
+ uv tool install --python 3.12 "bioaccx[gpu]" # CUDA 12
77
+ uv tool install --python 3.12 "bioaccx[cpu,gui,umap]" # with the browser GUI and UMAP plots
78
+
79
+ uv add "bioaccx[cpu]" # or as a project dependency
80
+ ```
81
+
82
+ Extras go **inside the brackets** — `uv tool install` has no `--extra` flag — and
83
+ the whole argument needs quoting so the shell does not glob them. `--python`
84
+ keeps uv off a Python newer than TensorFlow supports.
85
+
86
+ See [Installation](docs/en/installation.md) for what the installer does, the
87
+ extras table, supported systems, working on bioaccx itself, GPU acceleration
88
+ with CUDA, and how much disk this needs.
89
+
90
+ ---
91
+
92
+ ## Quick start
93
+
94
+ ```bash
95
+ # 0. Browse available foundation models and their registry IDs
96
+ bioaccx registry
97
+
98
+ # 1. Copy and edit the example config
99
+ cp example_config.yaml my_config.yaml
100
+
101
+ # 2. Validate config without running training
102
+ bioaccx validate my_config.yaml
103
+
104
+ # 3. Export the dataset as chunked WAV files (no model needed)
105
+ bioaccx dataset my_config.yaml
106
+
107
+ # 4. Compute the embedding database + UMAP (no training)
108
+ bioaccx embeddings my_config.yaml
109
+
110
+ # 5. Train and export
111
+ bioaccx train my_config.yaml
112
+ ```
113
+
114
+ `bioaccx merge` and `bioaccx extract-head` do the same jobs without training —
115
+ see [Merging, extracting and converting heads](docs/en/model-surgery.md).
116
+
117
+ ---
118
+
119
+ ## The browser GUI
120
+
121
+ `bioaccx gui` opens a config editor in a browser. It writes the same YAML files
122
+ every other command reads — the terminal stays the way runs are started.
123
+
124
+ ```bash
125
+ uv tool install "bioaccx[cpu,gui]" # the GUI needs the [gui] extra
126
+
127
+ bioaccx gui # start from a template
128
+ bioaccx gui my_config.yaml # open an existing config
129
+ bioaccx gui --lang pt-BR # open it in Portuguese
130
+ ```
131
+
132
+ The form is generated from the config dataclasses, so it offers exactly the keys
133
+ this version understands, with their real defaults and help text; the file it
134
+ writes is shown beside it as you type, and your comments survive the round-trip.
135
+ The **run** tab starts a command on that config and streams its log into the
136
+ page; the **analysis** tab reads what past runs wrote — metrics, the UMAP map
137
+ with the audio behind each point, and two runs side by side.
138
+
139
+ See [The browser GUI](docs/en/gui.md) for all of it, including
140
+ [interface languages](docs/en/gui.md#interface-languages) and serving the editor
141
+ to another machine.
142
+
143
+ ---
144
+
145
+ ## Configuration
146
+
147
+ Everything a run does is described by one YAML file:
148
+ [`example_config.yaml`](example_config.yaml) is a working starting point,
149
+ [Configuration](docs/en/configuration.md) explains it section by section, and
150
+ [Config reference](docs/en/config-reference.md) lists every key with its default.
151
+
152
+ ---
153
+
154
+ ## Documentation
155
+
156
+ The full documentation lives in [`docs/en/`](docs/en/). This page covers what
157
+ bioaccx is, how to install it, and how to get a first run out of it.
158
+
159
+ | Page | What is in it |
160
+ |---|---|
161
+ | [Installation](docs/en/installation.md) | Install paths, the extras table, GPU acceleration, disk space |
162
+ | [Quick start](docs/en/quickstart.md) | The commands of a first run, in order |
163
+ | [The browser GUI](docs/en/gui.md) | `bioaccx gui` — config editor, results explorer, interface languages |
164
+ | [Configuration](docs/en/configuration.md) | The config file section by section, with worked examples |
165
+ | [Config reference](docs/en/config-reference.md) | Every config key, its default and its help text |
166
+ | [Datasets](docs/en/dataset-modes.md) | Label layouts, train/test split, appending, combining sources |
167
+ | [Remote sound sources](docs/en/remote-sources.md) | iNaturalist, Xeno-canto and Arbimon rows in one table |
168
+ | [Augmentation and windowing](docs/en/augmentation.md) | Noise augmentation, random shift, windows and overlap |
169
+ | [Embeddings, cache and UMAP](docs/en/embeddings-umap.md) | The embedding store, `bioaccx embeddings`, UMAP and KMeans/NMI |
170
+ | [Outputs](docs/en/outputs.md) | Directory structure, metadata, precision, excluding labels |
171
+ | [Merging, extracting and converting heads](docs/en/model-surgery.md) | `merge`, `extract-head`, `convert-head` |
172
+ | [Foundation model registry](docs/en/registry.md) | Registry IDs, supported models, adding a new one |
173
+ | [Python API](docs/en/python-api.md) | Using bioaccx as a library |
174
+ | [CLI reference](docs/en/cli.md) | Every command and option |
175
+
176
+ The config and CLI references are generated from the code by
177
+ `tools/gen_docs.py`, so they cannot drift behind it — see
178
+ [`docs/README.md`](docs/README.md).
179
+
180
+ ---
181
+
182
+ ## License
183
+
184
+ [MIT](LICENSE)
@@ -0,0 +1,189 @@
1
+ <!-- translated-from: README.md@0ee356cafe56 -->
2
+ # bioaccx
3
+
4
+ **BIOAcoustic Custom Classifier eXchange** — uma ferramenta Python de linha de comando para treinar e compartilhar classificadores bioacústicos customizados sobre modelos base pré-treinados como o [BirdNET](https://birdnet.cornell.edu/) e o [Perch](https://www.kaggle.com/models/google/bird-vocalization-classifier).
5
+
6
+ A ideia central é separar de forma limpa o **backbone** e o **classifier head**:
7
+
8
+ - O backbone (modelo base) é um codificador de áudio grande e de uso geral, compartilhado pela comunidade.
9
+ - O head é um classificador pequeno, específico da sua tarefa, treinado nos seus dados rotulados — alguns poucos kilobytes.
10
+
11
+ Essa separação permite dois fluxos complementares:
12
+
13
+ **Compartilhar heads leves.** Como classificadores customizados são geralmente pequenos perto do backbone, você pode publicar e distribuir seu classificador sem levar junto o modelo inteiro. Quem já tem o mesmo backbone carrega o seu classificador e roda a inferência na hora.
14
+
15
+ **Publicar como um arquivo único.** Quando você precisa de um modelo autocontido — para dispositivos de borda, APIs na nuvem ou ferramentas de terceiros — o bioaccx funde backbone e head em um único arquivo ONNX ou TFLite, com uma entrada de áudio e uma saída de pontuações por classe.
16
+
17
+ **Pular o reprocessamento quando você já tem os embeddings.** Se você ou sua equipe já rodaram o backbone e guardaram os vetores de embedding, dá para apontar o bioaccx para esse cache e treinar ou avaliar o head direto — sem processar áudio, sem tempo de GPU, sem espera.
18
+
19
+ **Montar datasets de várias fontes em uma configuração só.** O bioaccx monta os dados de treino a partir de gravações locais, observações do [iNaturalist](https://www.inaturalist.org/), gravações do [Xeno-canto](https://xeno-canto.org/) e projetos do [Arbimon](https://arbimon.org/) — tudo misturado em uma tabela, ou combinado com um diretório local. O áudio remoto é baixado e cacheado automaticamente, então as execuções seguintes não tocam a rede.
20
+
21
+ O bioaccx cuida do caminho inteiro, do áudio bruto ao modelo exportado, guiado por um único arquivo de configuração.
22
+
23
+ > 🇬🇧 [Read in English](README.md)
24
+
25
+ ---
26
+
27
+ ## Como funciona
28
+
29
+ ```
30
+ Arquivos de áudio → Modelo base (backbone) → Embeddings
31
+ ↓
32
+ Classifier head Keras ou sklearn
33
+ ↓
34
+ ┌────────────────────────────────────────┐
35
+ │ backbone + head fundidos │ só o head │
36
+ │ (arquivo único) │(compartilhável)│
37
+ └────────────────────────────────────────┘
38
+ ```
39
+
40
+ 1. **Modelo base** — uma versão backbone de um modelo bioacústico extrai vetores de características ricos de janelas de áudio bruto. Formatos suportados: ONNX, TFLite, TF SavedModel (protobuf).
41
+ 2. **Classifier head** — uma pequena MLP em Keras ou uma LogisticRegression do sklearn é treinada sobre esses embeddings com os seus dados rotulados.
42
+ 3. **Exportação** — escolha entre:
43
+ - **Modelo completo** (`output_type: full`): funde backbone + head em um único grafo ONNX ou TFLite. Inferência direta, sem dependências externas.
44
+ - **Só o classificador (head)** (`output_type: head`): exporta apenas o classificador. Arquivo minúsculo, fácil de compartilhar; exige o backbone na hora da inferência.
45
+ - **Ambos** (`output_type: both`): produz as duas variantes.
46
+
47
+ ---
48
+
49
+ ## Instalação
50
+
51
+ **Sem precisar de Python.** O instalador prepara tudo e adiciona um atalho
52
+ **bioaccx** que abre a [GUI no navegador](#a-gui-no-navegador). Rode de novo
53
+ para atualizar.
54
+
55
+ No Windows — abra o PowerShell e cole:
56
+
57
+ ```powershell
58
+ powershell -ExecutionPolicy ByPass -c "irm https://github.com/biodiversica/bioaccx/releases/latest/download/install.ps1 | iex"
59
+ ```
60
+
61
+ No macOS (Apple Silicon) e no Linux — abra um terminal e cole:
62
+
63
+ ```sh
64
+ curl -LsSf https://github.com/biodiversica/bioaccx/releases/latest/download/install.sh | sh
65
+ ```
66
+
67
+ **Com uv ou pip.** O bioaccx executa os modelos pelo ONNX Runtime, e **não há um
68
+ padrão** — escolha `cpu` ou `gpu` na instalação. Um `bioaccx` sem extras instala
69
+ sem reclamar e falha no momento em que tenta rodar um modelo, então na prática o
70
+ extra não é opcional.
71
+
72
+ ```bash
73
+ uv tool install --python 3.12 "bioaccx[cpu]" # inferência na CPU
74
+ uv tool install --python 3.12 "bioaccx[gpu]" # CUDA 12
75
+ uv tool install --python 3.12 "bioaccx[cpu,gui,umap]" # com a GUI no navegador e os gráficos UMAP
76
+
77
+ uv add "bioaccx[cpu]" # ou como dependência de um projeto
78
+ ```
79
+
80
+ Os extras vão **dentro dos colchetes** — o `uv tool install` não tem a opção
81
+ `--extra` — e o argumento inteiro precisa de aspas para o shell não expandi-los.
82
+ O `--python` impede o uv de escolher um Python mais novo do que o TensorFlow
83
+ suporta.
84
+
85
+ Veja [Instalação](docs/pt-BR/installation.md) para o que o instalador faz, a
86
+ tabela de extras, os sistemas suportados, como trabalhar no próprio bioaccx,
87
+ aceleração por GPU com CUDA e quanto disso ocupa em disco.
88
+
89
+ ---
90
+
91
+ ## Primeiros passos
92
+
93
+ ```bash
94
+ # 0. Veja os modelos base disponíveis e seus IDs
95
+ bioaccx registry
96
+
97
+ # 1. Copie e edite a configuração de exemplo
98
+ cp example_config.yaml my_config.yaml
99
+
100
+ # 2. Valide a configuração sem rodar o treinamento
101
+ bioaccx validate my_config.yaml
102
+
103
+ # 3. Exporte o dataset como arquivos WAV em trechos (sem precisar do modelo)
104
+ bioaccx dataset my_config.yaml
105
+
106
+ # 4. Calcule o banco de embeddings + UMAP (sem treinar)
107
+ bioaccx embeddings my_config.yaml
108
+
109
+ # 5. Treine e exporte
110
+ bioaccx train my_config.yaml
111
+ ```
112
+
113
+ O `bioaccx merge` e o `bioaccx extract-head` fazem os mesmos trabalhos sem
114
+ treinar — veja
115
+ [Merging, extracting and converting heads](docs/en/model-surgery.md).
116
+
117
+ ---
118
+
119
+ ## A GUI no navegador
120
+
121
+ O `bioaccx gui` abre um editor de configuração no navegador. Ele escreve os
122
+ mesmos arquivos YAML que todos os outros comandos leem — o terminal continua
123
+ sendo o lugar de onde as execuções partem.
124
+
125
+ ```bash
126
+ uv tool install "bioaccx[cpu,gui]" # a GUI precisa do extra [gui]
127
+
128
+ bioaccx gui # começa de um modelo em branco
129
+ bioaccx gui my_config.yaml # abre uma configuração existente
130
+ bioaccx gui --lang pt-BR # abre em português
131
+ ```
132
+
133
+ O formulário é gerado a partir das dataclasses de configuração, então oferece
134
+ exatamente as keys que esta versão entende, com os valores padrão de verdade e
135
+ os textos de ajuda; o arquivo que ele escreve aparece ao lado enquanto você
136
+ digita, e seus comentários sobrevivem ao round-trip. A aba **executar** inicia
137
+ um comando sobre essa configuração, com o log chegando na página ao vivo; a aba
138
+ **análise** lê o que as execuções passadas escreveram — métricas, o mapa UMAP
139
+ com o áudio por trás de cada ponto, e duas execuções lado a lado.
140
+
141
+ Veja [A GUI no navegador](docs/pt-BR/gui.md) para tudo isso, incluindo os
142
+ [idiomas da interface](docs/pt-BR/gui.md#idiomas-da-interface) e como servir o
143
+ editor para outra máquina.
144
+
145
+ ---
146
+
147
+ ## Configuração
148
+
149
+ Tudo o que uma execução faz é descrito por um único arquivo YAML: o
150
+ [`example_config.yaml`](example_config.yaml) é um ponto de partida que funciona,
151
+ [Configuration](docs/en/configuration.md) explica seção por seção (em inglês), e
152
+ a [Referência de configuração](docs/pt-BR/config-reference.md) lista todas as
153
+ keys com seus valores padrão.
154
+
155
+ ---
156
+
157
+ ## Documentação
158
+
159
+ A documentação completa está em [`docs/pt-BR/`](docs/pt-BR/). Esta página cobre
160
+ o que o bioaccx é, como instalá-lo e como tirar dele uma primeira execução.
161
+
162
+ | Página | Conteúdo |
163
+ |---|---|
164
+ | [Instalação](docs/pt-BR/installation.md) | Formas de instalar, a tabela de extras, aceleração por GPU, espaço em disco |
165
+ | [Primeiros passos](docs/pt-BR/quickstart.md) | Os comandos de uma primeira execução, em ordem |
166
+ | [A GUI no navegador](docs/pt-BR/gui.md) | `bioaccx gui` — editor de configuração, explorador de resultados, idiomas |
167
+ | [Referência de configuração](docs/pt-BR/config-reference.md) | Todas as keys, com valor padrão e descrição |
168
+ | [Configuration](docs/en/configuration.md) 🇬🇧 | O arquivo de configuração seção por seção, com exemplos |
169
+ | [Datasets](docs/en/dataset-modes.md) 🇬🇧 | Formatos de rótulo, divisão train/test, acréscimo, múltiplas fontes |
170
+ | [Remote sound sources](docs/en/remote-sources.md) 🇬🇧 | iNaturalist, Xeno-canto e Arbimon em uma tabela só |
171
+ | [Augmentation and windowing](docs/en/augmentation.md) 🇬🇧 | Ruído, deslocamento aleatório, janelas e sobreposição |
172
+ | [Embeddings, cache and UMAP](docs/en/embeddings-umap.md) 🇬🇧 | O banco de embeddings, `bioaccx embeddings`, UMAP e KMeans/NMI |
173
+ | [Outputs](docs/en/outputs.md) 🇬🇧 | Estrutura de diretórios, metadados, precisão, excluir rótulos |
174
+ | [Merging, extracting and converting heads](docs/en/model-surgery.md) 🇬🇧 | `merge`, `extract-head`, `convert-head` |
175
+ | [Foundation model registry](docs/en/registry.md) 🇬🇧 | IDs do registro, modelos suportados, adicionar um novo |
176
+ | [Python API](docs/en/python-api.md) 🇬🇧 | Usar o bioaccx como biblioteca |
177
+ | [CLI reference](docs/en/cli.md) 🇬🇧 | Todos os comandos e opções |
178
+
179
+ As páginas marcadas com 🇬🇧 ainda não foram traduzidas e estão em inglês.
180
+
181
+ As referências de configuração e da CLI são geradas a partir do código pelo
182
+ `tools/gen_docs.py`, então não têm como ficar para trás dele — veja
183
+ [`docs/README.md`](docs/README.md).
184
+
185
+ ---
186
+
187
+ ## Licença
188
+
189
+ [MIT](LICENSE)
@@ -0,0 +1,6 @@
1
+ """bioaccx — bioacoustic custom classifier generator."""
2
+ from bioaccx.config import BioaccxConfig, load_config
3
+ from bioaccx.train import run
4
+
5
+ __all__ = ["BioaccxConfig", "load_config", "run"]
6
+ __version__ = "0.1.0"
@@ -0,0 +1,10 @@
1
+ import signal
2
+
3
+ from bioaccx.cli import main
4
+
5
+ # The GUI cancels a run on Windows with Ctrl+Break (see gui/jobs.py), which
6
+ # would otherwise end the process without the clean "Interrupted." exit.
7
+ if hasattr(signal, "SIGBREAK"):
8
+ signal.signal(signal.SIGBREAK, signal.default_int_handler)
9
+
10
+ main()