--- language: - en - uk library_name: pytorch tags: - audio - audio-classification - drone-detection - pytorch - crnn - real-time - edge-deployment license: mit datasets: - geronimobasso/drone-audio-detection-samples model-index: - name: DroneClassifier results: - task: type: audio-classification name: Audio Classification dataset: name: Drone Audio Detection Samples type: geronimobasso/drone-audio-detection-samples metrics: - type: loss value: 0.1442 name: loss - type: f1 value: 0.9953 name: F1 Score (thr 0.25) - type: accuracy value: 0.9928 name: Accuracy --- # DroneClassifier — Real-Time Drone Audio Detection **Model.** A lightweight CNN utilizing depthwise convolutions and mean+max pooling over the time dimension; no GRU is used. Recurrence is unnecessary for a one-second window, and omitting it simplifies export to ONNX and C++. **Data.** The `fit()` function reads all shards from `data/*.parquet` once, decodes the audio into 16 kHz mono int16 format, and stores it in a memory-mapped cache. This cache is built once and does not require loading all 39 shards into RAM. Before execution, the script displays the mapping for label values ​​(if the Parquet files follow the HuggingFace format). The specific value corresponding to "engine" is defined via the `--positive-label` parameter. **Augmentation.** Speed ​​variation: ±12%. Low-pass and high-pass filtering, and reverberation. Mixing in real "other" (background/non-target) clips or colored noise at an SNR of 0–25 dB. Random gain adjustment: −15 to +10 dB. Inherent microphone noise. SpecAugment (frequency and time masking) applied to batches. **Training.** Balanced class sampling, AdamW optimizer, OneCycle learning rate schedule, AMP (Automatic Mixed Precision) on CUDA, and early stopping. A checkpoint is saved based on the best validation AUC, with a threshold determined by the F1 score. **Detection.** `detect_file()` processes data in batches, smooths the output, applies hysteresis, and returns detected events with their respective start and end times. **Export.** `export_onnx()` generates `engine.onnx`, `mel_fb.f32`, and `engine_meta.txt`. The Mel-filter matrix is ​​derived directly from `torchaudio`, ensuring the C++ implementation does not rely on a custom implementation of the filter bank.