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.