This repository provides training and evaluation pipelines for deep learning models to classify burrowing owl vocalizations using spectrograms derived from audio signals. It includes a custom-designed TinyCNN optimized for embedded deployment on STM32 microcontrollers, with optional comparison to baseline models like MobileNetV2 and ProxylessNAS.
CSE145ML-main/
│
├── scripts/
│ ├── Custom-TinyCNN.py # Train Custom TinyCNN model
│ ├── TinyCNN-to-TfLite.py # Convert TinyCNN to TFLite and C header
│ ├── Torch_C_header.py # Convert ProxylessNAS to TFLite + header (benchmark only)
│ ├── tflite_quantize.py # AI-Edge quantization for benchmarking models
│ ├── test_tflite.py # Evaluate TFLite models and plot accuracy
│ ├── test.py # Evaluate trained models
│ ├── train_proxylessnas.py # Train ProxylessNAS model
│ ├── train_proxylessnas_abhay.py # Custom ProxylessNAS variant
│ └── dataset.py # OwlSoundDataset class
│
├── models/ # Pretrained/exported models
├── graphs/ # Training/evaluation plots
├── requirements.txt # Python dependencies
└── README.md # Project documentation
This project uses the BUOWSET dataset:
- Classes: Cluck, Coocoo, Twitter, Alarm, Chick Begging, no_buow
- Format: WAV audio files + metadata CSV
- Metadata:
meta/metadata.csvwith fold info - Splits: Folds 0-2 = training, Fold 3 = validation
pip install -r requirements.txt💡 Windows users should install
soundfilemanually if torchaudio fails.
python scripts/Custom-TinyCNN.pyThis will train the TinyCNN model, which is used for final STM32 deployment.
python scripts/test.pyOutputs:
- Accuracy
- Precision / Recall / F1
- Confusion matrix
Results are saved to the graphs/ directory.
The Custom-TinyCNN model is exported using the TinyCNN-to-TfLite.py script. This script handles the complete flow from a PyTorch .pth model to a TFLite .tflite file, and generates a C header (.h) file for STM32 deployment.
To export the model:
python TinyCNN-to-TfLite.pyThis will:
- Load the TinyCNN PyTorch model
- Convert it to TensorFlow Lite format
- Apply post-training quantization
- Generate:
buow_tinycnn.tflitebuow_tinycnn.h(for use with TF-Lite Micro on STM32)
Quantization is performed during TFLite conversion using TensorFlow Lite’s post-training quantization. Specifically:
- Quantization mode:
tf.lite.Optimize.DEFAULT - Resulting model size: ~11KB
- Optimized for low memory and flash usage suitable for STM32 deployment
Quantization is built into the TinyCNN-to-TfLite.py script and requires no additional tooling.
The final quantized model (buow_tinycnn.tflite) is compiled into a C header file (buow_tinycnn.h) using:
xxd -i buow_tinycnn.tflite > buow_tinycnn.hThis header can be included directly in embedded C projects using TF-Lite Micro.
This is the only model used for deployment.
All other models (e.g., MobileNetV2, ProxylessNAS) were used for baseline comparison only and are not deployed.
| Metric | ProxylessNAS | MobileNetV2 | TinyCNN |
|---|---|---|---|
| Accuracy | 97.2% | 97.69% | 95.3% |
| F1-Score | 0.92 | 0.92 | 0.84 |
TinyCNN offers a compact trade-off with deployment feasibility on embedded hardware.
- Custom-TinyCNN (🟢 Deployed): Compact, purpose-built CNN for real-time classification on STM32H747I-DISCO (~11KB with quantization)
- MobileNetV2 (🔵 Benchmark only): Lightweight mobile CNN used for baseline performance comparison
- ProxylessNAS (🔵 Benchmark only): NAS-optimized CNN evaluated during early experiments
- Abhay Lal – M.S. CSE, UC San Diego
- Zach Lawrence – B.S. Computer Science, UC San Diego
- Max Shen – B.S. Computer Engineering, UC San Diego
MIT License. Feel free to use and modify.
Special thanks to the CSE 145/237D Embedded System Design Project course instructors at UC San Diego for project guidance and to the creators of BUOWSET for providing the dataset. Also special mention to Ludwig for initiating this project and being a helpful mentor to work with.