A comparative study on deep-learning techniques that can also be deployed on resource-constrained edge devices. Analyzes the performance of seven Convolutional Neural Network models in the context of data augmentation, feature extraction, and model compression using acoustic data.
A Comparative Study of Preprocessing and Model Compression Techniques in Deep Learning for Forest Sound Classification
@article{paranayapa2024comparative,
title={A Comparative Study of Preprocessing and Model Compression Techniques in Deep Learning for Forest Sound Classification},
author={Paranayapa, Thivindu and Ranasinghe, Piumini and Ranmal, Dakshina and Meedeniya, Dulani and Perera, Charith},
journal={Sensors},
volume={24},
number={4},
pages={1149},
year={2024},
publisher={MDPI},
doi={10.3390/s24041149}
}
All Python notebooks used in this study can be found in the scripts directory.
-
Download the FSC22 data from https://www.kaggle.com/datasets/dakshinaranmal/fsc22-v1
Note: The dataset used in this study has one class removed due to ambiguity. To successfully run the notebooks it is necessary to get the updated version of FSC22 from the above mentioned url.
-
Extract the download FSC22 - v1 dataset zip (archive.zip) in the dataset folder in the project file structure. Once extracted successfully there will be a subfolder named fsc22 inside the dataset folder.
-
Create a Conda environment. (Python 3.10.12 was used during research)
-
Activate the Conda environment.
-
Install the following libraries in the Conda environment.
pip install "tensorflow<2.11" conda install pytorch::pytorch conda install anaconda::numpy conda install anaconda::pandas conda install conda-forge::tqdm conda install conda-forge::librosa pip install soundfile==0.8.1 pip install audiomentations conda install conda-forge::matplotlib conda install conda-forge::optuna pip install tensorflow-model-optimization pip install nncf pip install openvino
-
Run the AudioHandler notebook. (scripts/audio_processing/Audio Handler.ipynb)
Once completed, the pickle file of FSC22 resampled at 20kHz will be inside the dataset -> fsc22 -> Pickle Files directory.
-
Run the Feature Generator notebook providing necessary command line inputs as required. (scripts/audio_processing/Feature Generator.ipynb)
Once completed pickle files following the given data augmentation and feature extraction techniques will be created inside the dataset -> fsc22 -> Pickle Files directory.
-
Run notebooks of the selected models which can be found at scripts/base_models. (Ex: AlexNet, DenseNet121, EfficientNetV2B0, InceptionV3, MobileNetV3-Small, ResNet50V2)
In every model notebook, first hyper parameters will be tuned, followed by model training and the model will be saved in the given directory.
Note: Provide a relative path inside the project directory to save the trained model.
Models can be compressed mainly using two compression techniques namely Pruning and Quantization.
Pruning can be done following three approaches.
-
Weight Pruning
Run the Weight Pruning notebook providing necessary command line inputs as required. (scripts/model_compression/Weight Pruning.ipynb)
-
Filter Pruning
Run the Filter Pruning notebook providing necessary command line inputs as required. (scripts/model_compression/Filter Pruning.ipynb)
-
Hybrid Pruning
Run the Filter Pruning notebook for an already weight pruned model obtained using the Weight Pruning notebook.
Quantization can be done following two approaches.
-
Tensorflow model quantization
Quantization of models of type .h5 can be quantized with this. Models which are initially trained or weight pruned can be quantized.
Run the TF_Quantization notebook providing necessary command line inputs as required. (scripts/model_compression/TF_Quantization.ipynb)
-
OpenVINO model quantization
Quantization of models of type IR (OpenVINO Intermediate Representation) can be quantized with this. Models which are filter pruned or hybrid pruned can be quantized.
Run the OpenVINO Quantization notebook providing necessary command line inputs as required. (scripts/model_compression/OpenVINO_Quantization.ipynb)