Skip to content

Fix PCEN preprocessor and improve checkpoint config merging - #127

Merged
mosheman5 merged 2 commits into
masterfrom
fix/pcen-and-pytorch-compat
Apr 29, 2026
Merged

Fix PCEN preprocessor and improve checkpoint config merging#127
mosheman5 merged 2 commits into
masterfrom
fix/pcen-and-pytorch-compat

Conversation

@shaing10

@shaing10 shaing10 commented Apr 24, 2026

Copy link
Copy Markdown
Collaborator

Summary:

  • Fix LibrosaPcen: accept hop_length param (backward compat with n_mels), handle torch.Tensor input, squeeze singleton dims to prevent 5D tensor crash, update deprecated librosa.core.pcen to librosa.pcen
  • Add max_freq merging from checkpoint in merge_with_checkpoint()
  • Add PCEN preprocessor config (_preprocessor_with_pcen.yaml)
  • Add optional max_freq field to config validator

Context

The Amber dolphin models (echo, whistle) use a Spectrogram → PCEN preprocessor chain. These models failed on inference due to:

  1. LibrosaPcen.init() not accepting hop_length (the param saved in their checkpoints)
  2. LibrosaPcen.call() passing a torch.Tensor to librosa.pcen (expects numpy)
  3. np.expand_dims adding a redundant channel dim on top of the existing one from the data pipeline, creating a 5D tensor that crashes ResNet182D.forward()

All 4 Amber models (barks, echo, buzz, whistle) verified working on this branch with identical outputs to client/amber.

Test plan

  • Barks model (4af2w6lt) — inference passes, output matches baseline
  • Echo model (bki984uw) — inference passes, output matches baseline
  • Buzz model (ccgojzau) — inference passes, output matches baseline
  • Whistle model (g8gtuypk) — inference passes, output matches baseline
  • Verify existing models (non-PCEN) still work on master (no regressions — PCEN changes are additive, n_mels param still supported)

- Fix LibrosaPcen: accept hop_length param (backward compat with n_mels),
  handle torch.Tensor input, squeeze singleton dims to prevent 5D tensor
  crash, update deprecated librosa.core.pcen to librosa.pcen
- Add max_freq merging from checkpoint in merge_with_checkpoint()
- Add PCEN preprocessor config (_preprocessor_with_pcen.yaml)
- Add max_center_freq to BandStopFilter augmentation config
- Add optional max_freq field to config validator

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@shaing10
shaing10 requested a review from mosheman5 April 24, 2026 18:02
@shaing10 shaing10 self-assigned this Apr 24, 2026
@shaing10 shaing10 added the ci-test label to trigger CI flow label Apr 24, 2026
…d for inference)

The max_center_freq references ${data.max_freq} which does not exist in
default data configs. This field is only relevant during training, not
inference, so removing it avoids breaking existing configs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@shaing10 shaing10 added ci-test label to trigger CI flow and removed ci-test label to trigger CI flow labels Apr 24, 2026
@mosheman5
mosheman5 merged commit 6f624e8 into master Apr 29, 2026
2 checks passed
@mosheman5
mosheman5 deleted the fix/pcen-and-pytorch-compat branch April 29, 2026 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-test label to trigger CI flow

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants