--- license: apache-2.0 library_name: pytorch tags: - bioacoustics - audio-classification - bird-classification - efficientnet - transfer-learning - perch --- # ⚠️ Deprecated — see [`perchv2-pytorch`](https://github.com/bghani/perchv2-pytorch) instead **These weights are no longer the recommended way to use this project.** The main repo now provides a PyTorch backbone built by converting Google's actual released ONNX graph directly (via `onnx2torch`) — confirmed **1.00000000 cosine similarity** against `onnxruntime`'s own output, and fully differentiable. That approach needs the original `perch_v2.onnx` file (get it from [`justinchuby/Perch-onnx`](https://huggingface.co/justinchuby/Perch-onnx/tree/main) or see the [main repo README](https://github.com/bghani/perchv2-pytorch#getting-the-weights) for details). The weights on this page are kept only as `legacy/` in that repo, for reference — **not recommended for new use.** See why below. ## What this is Unofficial, community-converted PyTorch weights for Google's [Perch v2](https://www.kaggle.com/models/google/bird-vocalization-classifier) bioacoustic foundation model, built by hand-reconstructing the architecture in `timm`'s `tf_efficientnet_b3` and copying over weights converted from the original JAX/Flax SavedModel. Not produced or endorsed by Google. - **Architecture:** `timm` `tf_efficientnet_b3`, single-channel input (`in_chans=1`), classification head stripped — returns a pooled **1536-dim** embedding. - **File:** `perch_v2_backbone_timm.pt` — backbone weights only (no classification head). ## Known limitation — why this is deprecated Earlier validation reported ~0.80 whole-network cosine similarity, attributed to numerical error accumulating across blocks. That explanation was incomplete. Further investigation found and fixed two real architectural bugs (a stem padding mismatch and a missing convolution bias, both confirmed directly against the ONNX graph), bringing cosine similarity up to **~0.97**. That still wasn't the full picture. A later three-way comparison — real ONNX output, the `onnx2torch`-converted backbone, and this `timm` backbone — found this backbone sitting at a **relative L2 error of ~0.23–0.29** against the true model, despite the reassuring-looking ~0.97 cosine similarity. Cosine similarity measures an angle between vectors; it can look close to 1.0 while the actual magnitude of the error stays large. This showed up concretely: a linear probe trained on this backbone's frozen embeddings converged slower and to a lower accuracy than one trained on the ONNX-converted backbone's embeddings, on the same task. A further architectural bug was identified (blocks 5, 8, and 18 also use asymmetric padding, the same class of issue as the original stem bug) but attempting to fix it caused an unexplained regression, so it was left unfixed. Whether this is the source of the remaining L2 gap is an open question — full details in [`legacy/README.md`](https://github.com/bghani/perchv2-pytorch/blob/main/legacy/README.md). **If you need accurate, trainable Perchv2 backbone, use the ONNX-converted backbone in the [main repo](https://github.com/bghani/perchv2-pytorch) instead — not these weights.** ## License Apache 2.0, inherited from the original Perch v2 release. See [NOTICE](https://github.com/bghani/perchv2-pytorch/blob/main/NOTICE) in the main repo for the full derivative-work attribution.