bioacoustics
Prepare, train, and run passive-acoustic wildlife classifiers with PytorchWildlife 1.3.0, including YAML configuration, annotated audio windows, mel spectrograms, ResNet checkpoints, and CSV interpretation.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- bioacoustics
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Prepare, train, and run passive-acoustic wildlife classifiers with PytorchWildlife 1.3.0, including YAML configuration, annotated audio windows, mel spectrograms, ResNet checkpoints, and CSV interpretation.
- disable-model-invocation
- true
02 资源文件 6
- 参考文档references/configuration.md3.7 KB
- 参考文档references/data-formats.md4.0 KB
- 参考文档references/troubleshooting.md4.6 KB
- 参考文档references/workflows.md4.1 KB
- 脚本scripts/audio_inference.py16.5 KB
- 脚本scripts/prepare_dataset.py12.9 KB
03 SKILL.md 正文
Bioacoustics
Use this route for passive-acoustic wildlife monitoring: audio annotations,
window construction, mel-spectrogram caches, ResNet spectrogram classifiers,
and binary or multiclass CSV results. The supported package surface is
PytorchWildlife.data.bioacoustics and PytorchWildlife.models.bioacoustics
from PytorchWildlife 1.3.0, plus the public companion CLI contracts distilled
here.
Route and boundaries
- Use this skill for YAML domain configuration, environment-variable
expansion, COCO-like audio annotations, sliding/balanced/customized windows,
spectrogram generation,
.npydatasets, checkpoint inference, and the companion preparation/training/inference flags. - Route image detection/classification to
detectionorclassification. Route JSON/image/video serialization, visualization, and general video utilities todata-and-postprocessing. - Do not start training, download model weights, download datasets, launch a service, or imply that CUDA is required. Training and real inference are explicit user-approved operations; parser and tiny-fixture checks are safe.
Safe operating order
- Copy a config and set
paths.data_root,paths.output_root, andpaths.spectrograms_dirto user-owned locations.${VAR}values are expanded byload_config; do not rely on an empty default path. - Validate
sample_rate > 0,window_size_sec > 0, and0 <= overlap_sec < window_size_sec. For balanced windows use0 <= negative_proportion < 1; verify the output directories are writable. Use configuration for the exact nested keys and defaults. - Validate the annotation JSON and audio paths, then run statistics and
build windows. The common 5-second/4-second setup has a 1-second hop.
Choose
slidingfor full coverage,balancedfor sampled negatives, orcustomizedonly with a supplied builder. - Generate missing mel
.npyfiles, then create grouped train/validation/test CSVs. Keep recordings, not overlapping windows, as the split group to avoid leakage. Use the adapted preparation helper; it has no checkout-relative imports. - Before training, check every CSV has the configured
x_col(normallyspec_name),y_col(label), and readable.npyfiles. A missing cache is a preparation problem, not a model problem. See data formats. - Train
ResNetClassifieronly after choosing binary (num_classes == 2) or multiclass (num_classes > 2) mode, checking class ids and checkpoint provenance. Use the companion flags summarized in workflows. - For inference, use a local checkpoint and an audio folder, JSON, or CSV of
windows. Resolve the device before loading the checkpoint;
cudafalls back tocpuin the adapted helper when CUDA is unavailable. Use the audio inference helper and inspect its output schema before aggregation.
Core contracts
DomainConfignestsPathConfig,AudioConfig,SpectrogramConfig,TrainingConfig, andSplitsConfig.load_config(path)reads YAML and recursively expands environment variables; it does not fully validate numeric ranges, class counts, file existence, or writability.build_windows(...)returns window dictionaries containingwindow_id,dataset,sample_rate,sound_id,start,end, andlabel; multiclass windows also containann_overlap.startandendare sample indices at the requested target rate.build_inference_windows(source, window_size_sec, overlap_sec, sample_rate)accepts an audio directory or list of files and returnswindow_id,sound_path,start, andend. It needslibrosato obtain durations and rejects neither bad overlap nor missing files by itself, so validate first.compute_mel_spectrograms_gpu(...)is opportunistically accelerated: the implementation chooses CUDA when available and otherwise uses CPU. It reuses existing.npyfiles and defaults to<audio-basename>_<start>_<end>.npy, withfloat32storage. CUDA is an optional acceleration path, not a verified performance promise.BioacousticsDatasetreads CSV paths and labels; it returns(tensor, integer_label, path).BioacousticsInferenceDatasetneeds only the configured spectrogram-path column and returns(tensor, path). Spectrograms are shaped to[C,H,W], optionally normalized and resized.ResNetClassifiersupportsresnet18,resnet34, andresnet50. Binary mode emits one logit and uses sigmoid; multiclass mode emitsnum_classeslogits and uses softmax/argmax. Constructor initialization may request ImageNet weights, so checkpoint inference can still require a local cache or network unless the dependency weights are already available.
Output and review rules
Binary inference CSVs contain audio, start(s), end(s), prediction,
probability, and confidence. Multiclass CSVs contain file_path, audio,
start(s), end(s), prediction, one <ClassName>_prob per class (spaces
become underscores), and no binary confidence column in the companion writer.
Per-second binary aggregation produces audio, second, count_overlaps,
prediction, avg_prediction, avg_probability, and avg_confidence; it is
weighted by overlap duration and is not a multiclass reducer.
Treat a config with num_classes 0 or 1, too few/many class names, labels
outside 0..num_classes-1, a missing spec_name column, missing .npy files,
or an invalid window geometry as a hard preflight failure. Keep original
recording identity and sample-rate units when interpreting timestamps. For
predictable failures, use troubleshooting.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).