This repository is a fork of the upstream SAM-Audio project, adapted for a BirdSet-based latent-classification workflow.
The main purpose of this fork is to use SAM-Audio as a feature extractor instead of only treating it as a direct source-separation model. BirdSet samples are chunked, passed through the SAM-Audio model, and the resulting target latents are saved as reusable tensors for downstream multilabel bird-audio classification.
This project focuses on the following pipeline:
.pt archiveIn other words, the fork turns SAM-Audio into a latent feature backbone for ecological audio classification.

The architecture follows a simple pattern:
{"latents": [E, C, D, T], "labels": [E, N_C]}latent_pipeline/ — latent generation, training, and visualization scriptsevaluation/ — metric implementations and evaluation utilitiesdocs/ — project notes and workflow documentationnotebooks/ — exploratory notebooksapply_sam/ — older preprocessing scripts kept for referencesam_audio/ — upstream SAM-Audio model and processor codeexamples/ — official SAM-Audio prompting examplespython latent_pipeline/generate_latents.py \
--train_path /path/to/train_dataset \
--test_path /path/to/test_dataset \
--output_dir /path/to/output \
--model sam-audio-base \
--description "bird audio" \
--batch_size 8
This saves latent tensors and labels in a compact format that can be reused across training runs.
python latent_pipeline/train_latents.py \
--train_path /path/to/train_latents.pt \
--test_path /path/to/test_latents.pt \
--pooling mean_max \
--num_epochs 20 \
--lr 5e-4
python latent_pipeline/sweep_latents.py \
--train_path /path/to/train_latents.pt \
--test_path /path/to/test_latents.pt \
--poolings mean,max,mean_max,gru \
--num_epochs_list 10,20,30 \
--lrs 1e-4,5e-4,1e-3 \
--hidden_dims 256,1024 \
--output_csv sweep_results.csv
python latent_pipeline/visualize_latents.py \
--latents_path /path/to/train_latents.pt \
--output_dir /path/to/plots \
--method both
The main logic is split across:
latent_pipeline/generate_latents.py — converts BirdSet entries into fixed-length chunks and extracts SAM-Audio target latentslatent_pipeline/dataset_latents.py — dataset wrapper for loading saved latent archiveslatent_pipeline/classifier_latents.py — latent classifiers with configurable pooling and normalizationlatent_pipeline/train_latents.py — train/eval loop for the latent-space classifierlatent_pipeline/sweep_latents.py — hyperparameter sweep across pooling, learning rate, hidden size, and epochsevaluation/metrics.py — multilabel mAP and AUROC metric implementationsRequirements:
Install dependencies:
pip install .
If you are using the upstream SAM-Audio model checkpoints, authenticate to Hugging Face before running the latent extraction pipeline.
This repository is based on the original SAM-Audio project from Meta AI. The upstream work is a general-purpose audio segmentation foundation model that uses text, visual, and temporal prompts to isolate target sounds in mixtures.
This fork builds on that foundation by treating SAM-Audio as a feature extractor for BirdSet-style downstream audio classification tasks.
Additional documentation is available under the docs directory:
See CONTRIBUTING.md and CODE_OF_CONDUCT.md for project guidelines.
This project is licensed under the SAM License. See LICENSE.
If you use the upstream SAM-Audio model in your research, please cite the original paper:
@article{shi2025samaudio,
title={SAM Audio: Segment Anything in Audio},
author={Bowen Shi and Andros Tjandra and John Hoffman and Helin Wang and Yi-Chiao Wu and Luya Gao and Julius Richter and Matt Le and Apoorv Vyas and Sanyuan Chen and Christoph Feichtenhofer and Piotr Doll{\'a}r and Wei-Ning Hsu and Ann Lee},
year={2025},
url={https://arxiv.org/abs/2512.18099}
}
Jupyter Notebook
93.0%
Python
7.0%
This repository is a fork of the upstream SAM-Audio project, adapted for a BirdSet-based latent-classification workflow.
The main purpose of this fork is to use SAM-Audio as a feature extractor instead of only treating it as a direct source-separation model. BirdSet samples are chunked, passed through the SAM-Audio model, and the resulting target latents are saved as reusable tensors for downstream multilabel bird-audio classification.
This project focuses on the following pipeline:
.pt archiveIn other words, the fork turns SAM-Audio into a latent feature backbone for ecological audio classification.

The architecture follows a simple pattern:
{"latents": [E, C, D, T], "labels": [E, N_C]}latent_pipeline/ — latent generation, training, and visualization scriptsevaluation/ — metric implementations and evaluation utilitiesdocs/ — project notes and workflow documentationnotebooks/ — exploratory notebooksapply_sam/ — older preprocessing scripts kept for referencesam_audio/ — upstream SAM-Audio model and processor codeexamples/ — official SAM-Audio prompting examplespython latent_pipeline/generate_latents.py \
--train_path /path/to/train_dataset \
--test_path /path/to/test_dataset \
--output_dir /path/to/output \
--model sam-audio-base \
--description "bird audio" \
--batch_size 8
This saves latent tensors and labels in a compact format that can be reused across training runs.
python latent_pipeline/train_latents.py \
--train_path /path/to/train_latents.pt \
--test_path /path/to/test_latents.pt \
--pooling mean_max \
--num_epochs 20 \
--lr 5e-4
python latent_pipeline/sweep_latents.py \
--train_path /path/to/train_latents.pt \
--test_path /path/to/test_latents.pt \
--poolings mean,max,mean_max,gru \
--num_epochs_list 10,20,30 \
--lrs 1e-4,5e-4,1e-3 \
--hidden_dims 256,1024 \
--output_csv sweep_results.csv
python latent_pipeline/visualize_latents.py \
--latents_path /path/to/train_latents.pt \
--output_dir /path/to/plots \
--method both
The main logic is split across:
latent_pipeline/generate_latents.py — converts BirdSet entries into fixed-length chunks and extracts SAM-Audio target latentslatent_pipeline/dataset_latents.py — dataset wrapper for loading saved latent archiveslatent_pipeline/classifier_latents.py — latent classifiers with configurable pooling and normalizationlatent_pipeline/train_latents.py — train/eval loop for the latent-space classifierlatent_pipeline/sweep_latents.py — hyperparameter sweep across pooling, learning rate, hidden size, and epochsevaluation/metrics.py — multilabel mAP and AUROC metric implementationsRequirements:
Install dependencies:
pip install .
If you are using the upstream SAM-Audio model checkpoints, authenticate to Hugging Face before running the latent extraction pipeline.
This repository is based on the original SAM-Audio project from Meta AI. The upstream work is a general-purpose audio segmentation foundation model that uses text, visual, and temporal prompts to isolate target sounds in mixtures.
This fork builds on that foundation by treating SAM-Audio as a feature extractor for BirdSet-style downstream audio classification tasks.
Additional documentation is available under the docs directory:
See CONTRIBUTING.md and CODE_OF_CONDUCT.md for project guidelines.
This project is licensed under the SAM License. See LICENSE.
If you use the upstream SAM-Audio model in your research, please cite the original paper:
@article{shi2025samaudio,
title={SAM Audio: Segment Anything in Audio},
author={Bowen Shi and Andros Tjandra and John Hoffman and Helin Wang and Yi-Chiao Wu and Luya Gao and Julius Richter and Matt Le and Apoorv Vyas and Sanyuan Chen and Christoph Feichtenhofer and Piotr Doll{\'a}r and Wei-Ning Hsu and Ann Lee},
year={2025},
url={https://arxiv.org/abs/2512.18099}
}
Jupyter Notebook
93.0%
Python
7.0%