CASE: CNN Acceleration for Speech-Classification in Edge-Computing (Paper)
This repository is the guidance for the implementation of casenet on M-KUBOS Device.
There are three step to implement Machine Learning (ML) model on M-KUBOS Device:
- Training the CNN model in PyTorch framework.
- Making the Hardware logic for M-KUBOS FPGA using Vivado.
- Implementating the Python application program on the M-KUBOS Device.
CASENet model is trained on Google Speech Commands Dataset. This dataset contains several spoken speech commands, but this work only uses only 10 speech commands from those. This dataset has 1 sec long audio file for each spoken commands.
General flow is as follows:
- Install necessary packages in your machine i.e. pytorch, librosa etc.
- Download the data from this GD link. This is already pre-processed a little bit to make the lengths of all audio files uniform.
- Data augmentation can be applied to the audio file i.e. time shifting, noise addition etc. using processdata.py file.
- The CNN model and all relevant function for training the model on Google Speech Commands are defined in main file main_wd.py file.
- This file will save the model weights in text form also you can save the audio files to test on M-KUBOS using this file.
- HLS contains the code HLS logic. (This code is written for CNN network with 3 convolutional layers. The structure of the network can be changed in C code but it should be same as the network which was trained using Pytorch in part 1.)
- Next part is to use the Vivado software to generate hardware file for FPGA. (Instructions to use Vivado software are explained in this tutorial.)
By the point you have:
- Weights of the CNN network in .txt file.
- Input files for testing the network on M-KUBOS in .txt file.
- Hardware files for the FPGA (.bit and .hwh files).
The next step is to transfer these files to M-KUBOS and run the applications program CASENet2.py
This file uses pynq library to use on-chip FPGA and send/receive data from ARM to FPGA part. There are many variables in the application program according to the size of CNN, these parameters should exactly be same as CNN parameters in HLS file and in Pytorch model file.