Skip to content

Add YAMNet subprocess backend and auto-resampling for classification#505

Merged
satra merged 6 commits into
alphafrom
fix/add-ast-yamnet-docs
May 1, 2026
Merged

Add YAMNet subprocess backend and auto-resampling for classification#505
satra merged 6 commits into
alphafrom
fix/add-ast-yamnet-docs

Conversation

@satra

@satra satra commented May 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add YAMNet TensorFlow subprocess venv backend (yamnet.py)
  • Route classify_audios(audios, model="yamnet") to the subprocess backend
  • Auto-resample to expected sample rate in both HF and YAMNet classifiers (per-audio in loop, memory-efficient)
  • Add __all__ to all task/workflow modules for clean pdoc navigation
  • Update docs and model registry to reflect YAMNet as fully supported
  • Fix mypy error in SER module (hf_hub_download str cast)

Test plan

  • YAMNet works with 16kHz synthetic audio
  • YAMNet works with 48kHz real speech audio (auto-resamples)
  • HF AST classifier auto-resamples 48kHz audio instead of erroring
  • Existing classification tests pass (5/5)
  • scene_results_to_segments works with YAMNet output
  • ruff + mypy clean

🤖 Generated with Claude Code

Version

Published prerelease version: 1.3.1-alpha.26

Changelog

🐛 Bug Fix

  • Add YAMNet subprocess backend and auto-resampling for classification #505 (@satra)

Authors: 1

- classification/doc.md: AST and YAMNet added to Models section
  (organized by category: scene, demographics, content)
- model_registry.yaml: new audio_scene_classification section
- model_registry.md: regenerated
- Fixed generate_model_registry.py path (docs/ → src/senselab/)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@satra
satra temporarily deployed to docs-preview May 1, 2026 13:32 — with GitHub Actions Inactive

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the model registry generation script and introduces a new 'Audio Scene Classification' category, adding the AST and YAMNet models. Feedback identifies that YAMNet is incompatible with the current transformers-based API and suggests correcting a model link in the documentation for consistency.

Comment thread src/senselab/model_registry.yaml Outdated
Comment on lines +226 to +232
- name: YAMNet
task: audio_scene_classification
source: huggingface
model_id: google/yamnet
parameters: 3.2M
training_data: AudioSet (521 classes)
recommended_for: Lightweight audio scene classification (TensorFlow-based)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The google/yamnet model is a TensorFlow-based model and is not compatible with the transformers library. Since senselab currently uses HuggingFaceAudioClassifier.classify_audios_with_transformers for models with the huggingface source (as seen in src/senselab/audio/tasks/classification/api.py), this model will fail to load or run. Unless a TensorFlow backend is implemented, it should not be listed as a supported model in the registry.


**Auditory Scene / Sound Event Classification:**
- [Audio Spectrogram Transformer (AST)](https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593) — 521 AudioSet classes (speech, music, environmental sounds, animals, etc.). Recommended for general-purpose scene analysis.
- [YAMNet](https://huggingface.co/google/yamnet) — Google's AudioSet classifier (521 classes). TensorFlow-based.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Listing YAMNet here as a supported model might be misleading if it cannot be used with the classify_audios API due to its TensorFlow dependency and lack of transformers compatibility. Consider removing it or adding a note that it is not yet supported via the senselab API.

- [Adult vs. Child Speech](https://huggingface.co/bookbot/wav2vec2-adult-child-cls)

**Content:**
- [Music Genre](https://huggingface.co/agercas/distilhubert-finetuned-gtzan/blob/main/config.json)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The link for the Music Genre model points to the config.json file. It is better to point to the main model card page for consistency.

Suggested change
- [Music Genre](https://huggingface.co/agercas/distilhubert-finetuned-gtzan/blob/main/config.json)
- [Music Genre](https://huggingface.co/agercas/distilhubert-finetuned-gtzan)

Without __all__, pdoc shows internal submodules (api, huggingface,
etc.) as navigation items. With __all__, pdoc only shows the public
API functions — what users actually need.

Applied to 21 task modules + 1 workflow module across audio, video,
text, and utils.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@satra
satra temporarily deployed to docs-preview May 1, 2026 13:36 — with GitHub Actions Inactive
- YAMNet: noted as TensorFlow-based, not directly supported via classify_audios
- Music genre model link: config.json → main model card
- Model registry: YAMNet source changed from huggingface to tensorflow

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@satra
satra temporarily deployed to docs-preview May 1, 2026 13:38 — with GitHub Actions Inactive
satra and others added 2 commits May 1, 2026 09:55
…tion

- YAMNet runs in isolated TF subprocess venv (tensorflow, tensorflow-hub)
- Accessible via classify_audios(audios, model="yamnet")
- Auto-resamples to 16kHz inside the loop (memory-efficient)
- HF classifier now auto-resamples instead of erroring on wrong sample rate
- Updated doc.md and model_registry to reflect YAMNet as fully supported

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@satra
satra temporarily deployed to docs-preview May 1, 2026 13:56 — with GitHub Actions Inactive
@satra satra changed the title Add AST + YAMNet to docs and model registry Add YAMNet subprocess backend and auto-resampling for classification May 1, 2026
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@satra
satra merged commit 865d626 into alpha May 1, 2026
9 checks passed
github-actions Bot added a commit that referenced this pull request May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant