Skip to content

VigneshS10/Model-Quantization-For-Diabetes-Classification-in-Edge-Devices

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Model Quantization to optimize Alexnet, MobileNet and Resnet-50 for Diabetes Classification

Quantization for deep learning is the process of approximating a neural network that uses floating-point numbers by a neural network of low bit width numbers. This dramatically reduces both the memory requirement and computational cost of using neural networks.

In this repository, I have implemented static quantization strategy for Alexnet, MobileNet and Resnet-50 trained on a Retina based Diabetes Classification dataset and also have proven the benefits occuring from doing so by giving relevant statistics and evaluation metrics.


Requirements

To install requirements:

pip install -r requirements.txt

Dataset

Download the dataset from the links given below.

Train
Train2
Val

Training and Evaluation

  1. Download the dataset from the link above.
  2. Be sure to change the file directory paths in all the required places as per your convenience.
  3. Run the quant python files to train your model on the diabetes classification dataset.
  4. Both the normal model and the quantized models will be saved in the events folder, the predictions in the predictions folder and event logs in the event folder.
  5. Statistics such as Accuracy, Model size and CPU inference latency are all in built for evaluation in the quant python files.

Results

From the statistics given below, my quantization strategy reduced the model size, and the inference latency multiple folds while maintaining the accuracy of the model without any noticeble decline.

Model Top 1 Acc (%) Model size CPU Inference Latency
Alexnet 42.537 90 MB 37.94 ms/sample
Quantized Alexnet 42.537 23.2 MB 29.65 ms/sample

Model Top 1 Acc (%) Model size CPU Inference Latency
MobileNet 58.46 8.7 MB 10.23 ms/sample
Quantized MobileNet 58.41 2.8 MB 6.27 ms/sample

Model Top 1 Acc (%) Model size CPU Inference Latency
Resnet50 62.44 90 MB 162.19 ms/sample
Quantized Resnet50 63.41 23.2 MB 101.07 ms/sample

Pretrained models

Pretrained models for the all the mentioned models can be downloaded from this link for inference.

Contact

For any queries, feel free to contact at vignesh.nitt10@gmail.com.

Releases

No releases published

Packages

No packages published

Languages