Repository navigation
PANNs picks its device, and tags a whole recording frame by frame - #12
Merged
Merged
Conversation
`ml.tag_window` and `ml.tag_probabilities` built CNN14 on the CPU with no way to say otherwise, which is fine for the forty windows `draft` tags around events and not for a concert every two seconds. Both take `device=` now, `ml.PANNS_DEVICE` sets the session default and `"auto"` takes a CUDA GPU when torch sees one; the cached model is rebuilt when a different device is asked for. `ml.tag_frames` tiles a recording into windows and batches them through the model, returning (times, probs, names) with the columns in the caller's order. It is the array a segmenter wants, and the piece that every caller so far had to write itself. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PcjBSXbXjqdj1tmYHoLiKd
4 tasks done
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PcjBSXbXjqdj1tmYHoLiKd
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PcjBSXbXjqdj1tmYHoLiKd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
device=onml.tag_window/ml.tag_probabilities,ml.PANNS_DEVICEfor the session default,ml.resolve_device("auto"→ CUDA when torch sees one). PANNs was hardcoded to CPU; the cached model is rebuilt when a different device is requested.ml.tag_frames(x, fs, win_s=4, hop_s=2, wanted=None, device=None, batch=32) -> (times, probs, names): frame-wise AudioSet posteriors for a whole recording, tiled and batched. On a 90-minute concert this is ~1 min on a laptop GPU against ~30 min on CPU.docs/guide/ml.md) and CHANGELOG updated.Motivation: segmenting IMV concert videos (music / applause / talk) for the DAM catalog needed exactly this; the caller had to monkeypatch
ml._panns_modelto reach the GPU and write the tiling loop by hand.Test plan
tests/test_ml_frames.py(new, stubbed model): tiling and window centres,wantedcolumn order, short input = one window, unknown label raises, device change rebuilds the model,resolve_device.tests/test_ml_tags.pyunchanged and passing.tag_frameson an 87-minute concert at 32 kHz,device="cuda", 2622 windows in 54 s; posteriors identical to the per-windowtag_probabilitiesloop.🤖 Generated with Claude Code
https://claude.ai/code/session_01PcjBSXbXjqdj1tmYHoLiKd