CoolFace
Apppublic

stevafernandes/bee-sound

sourceHugging Facemitupdated 19d agoView on Hugging Face
0likes
App README

Hive Sound Predictability

Which quantities in the colony workbook can be predicted from a two-minute hive recording, and which cannot? The Space predicts every target (colony survival within 0-3 and 4-6 months, presence, level and high load of each measured pathogen: CBPV, DWV, KBV) from uploaded audio and, next to each prediction, shows the colony-grouped validation evidence for that target. Targets that the validation found not distinguishable from chance are labelled "no evidence of predictability from sound" and their calls are greyed out. The full analysis is in REPORT.md (tab "Report") and the survival-factor analysis in artifacts/results/survival_report.md (tab "Survival factors").

Pipeline (all code in this repository)

stepscriptoutput
featuresextract_features.pyhandcrafted acoustic features, AST and CLAP embeddings, recording QC
Gemini listeninggemini_batch.pystructured description of every recording, plus a full repeat pass to measure reliability
predictabilityevaluate.pycolony-grouped CV, cluster bootstrap CI, block-permutation p, confound controls
survival factorssurvival_analysis.pyGEE and Firth logistic regressions, colony-level and timing tests
deployable modelstrain_models.pymodels/*.joblib, models/config.json (validation evidence per target, including the colony-grouped OOF performance of the exact deployed rule, and the F1-optimal decision threshold), models/oof_predictions.json (out-of-fold output per training recording, shown by the app next to any in-sample score)
reportmake_report.pyREPORT.md

Shared modules: acoustic.py (identical feature code at training and inference), data.py (workbook loader and data-driven target registry: a new workbook column such as a Varroa count becomes a target automatically), gemini_audio.py (google-genai SDK; structured listening and a summary constrained to the computed numbers).

Gemini

Set the Space secret GEMINI_API_KEY. Without it the app runs without the Gemini panels. The model list is configurable with GEMINI_MODELS (default gemini-3.8-flash,gemini-flash-latest).

Reproduce

bash
pip install -r requirements.txt
python extract_features.py --audio-dir /path/to/wav --what handcrafted ast clap
GEMINI_API_KEY=... python gemini_batch.py --audio-dir /path/to/wav --retest 1131
python evaluate.py --audio-dir /path/to/wav --n-perm 100
python survival_analysis.py --audio-dir /path/to/wav
python train_models.py --audio-dir /path/to/wav
python make_report.py
python make_examples.py --audio-dir /path/to/wav
python -m pytest tests -q
python app.py

Deploy

The Space needs, next to the code: models/ (config.json, oofpredictions.json and the *.joblib files written by `trainmodels.py), AIDataTraining.xlsx, REPORT.md, artifacts/results/ and, optionally, examples/*.wav. Without models/config.json` the app starts but prediction is disabled and a message says what is missing (the report and evidence tabs still work).

bash
git clone https://huggingface.co/spaces/<user>/<space>
cp -r hf_space/. <space>/ && cd <space>
git lfs install && git lfs track "*.wav" "*.xlsx"
git add . && git commit -m "Hive sound predictability" && git push

artifacts/features/*.npz (embedding caches, only needed to retrain) are git-ignored and not required by the app. Every model file is below 1 MB, so no LFS is needed for models/. Set the Space secret GEMINI_API_KEY for the Gemini panels. The first prediction after a cold start downloads the AST weights (about 350 MB); the app starts that download in the background at launch.