Audio Classification
PyTorch
LiteRT
LiteRT
kernel-insect-cnn
insect
bioacoustics
experimental
local-inference
Instructions to use ganesh333/kernel-insect-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use ganesh333/kernel-insect-classifier with LiteRT:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Download src/model.py from ganesh333/kernel-insect-classifier: direct link, hf CLI and curl.
- Browser
- Download file 882 Bytes
-
https://huggingface.co/ganesh333/kernel-insect-classifier/resolve/main/src/model.py
- Command line
-
hf download hf://ganesh333/kernel-insect-classifier/src/model.py
-
curl -L -o model.py https://huggingface.co/ganesh333/kernel-insect-classifier/resolve/main/src/model.py
882 Bytes
| """Small CNN for 32-way insect acoustic species classification.""" | |
| import torch | |
| from torch import nn | |
| class InsectCNN(nn.Module): | |
| def __init__(self, num_classes=32): | |
| super().__init__() | |
| self.features = nn.Sequential( | |
| nn.Conv2d(1, 16, 3, padding=1), nn.BatchNorm2d(16), nn.ReLU(), | |
| nn.MaxPool2d(2), | |
| nn.Conv2d(16, 32, 3, padding=1), nn.BatchNorm2d(32), nn.ReLU(), | |
| nn.MaxPool2d(2), | |
| nn.Conv2d(32, 64, 3, padding=1), nn.BatchNorm2d(64), nn.ReLU(), | |
| nn.AdaptiveAvgPool2d((4, 4)), | |
| ) | |
| self.classifier = nn.Sequential(nn.Flatten(), nn.Dropout(0.25), | |
| nn.Linear(64*4*4, 128), nn.ReLU(), | |
| nn.Dropout(0.25), nn.Linear(128, num_classes)) | |
| def forward(self, x): | |
| return self.classifier(self.features(x)) | |