This repo is the implementation of DFlare. DFlare is the tool proposed in our paper Finding Deviated Behaviors of the Compressed DNN Models for Image Classifications, which is accepted by ACM TOSEM in 2023.
The main logic of DFlare is in test_gen_main.py
. To run the code, please run the wrapper: gen_wrapper_tflite.py
Here is an example:
python3 gen_wrapper_tflite.py --dataset mnist --arch lenet1 --maxit 10000000 --seed 0 --num 500 --cps_type quan --output_dir ./results
where model
can be one of 'lenet1', 'lenet5', 'resnet'.
If model
is resnet
, then it should be --dataset cifar
.
seed
can be 0,1,2,3,4.
seed_inputs.p
stores the seed inputs used by us.
./diffchaser_models
list the models from diffchaser.
Pelase downloadn it from here and follow the instructions in the readme.
Models are available at PyTorch
Moldes are available at DeepSpeech.
Please note that the compressed model and the original models cannot be executed in the same enviroment.
The compressed models need the python package deepspeech-tflite'' while the original models need the package
deepspeech'' or ``deepspeech-gpu''. More details are available at here.
To apply it on other models, please revise the `gen_wrapper_tflite.py'
DFlare majorly requires the following package.
pyflann-py3==0.1.0
opencv-python-headless==4.5.3.56
numpy
However, the tflite model requires much more. Here we give the list of package in our environment.
A full list package for reference is in tflite_requirement.txt
.
pip: 21.2.4
cuda: 10.1
Keras==2.4.3
tensorflow==2.2.0
Feel free to leave a question using issue report, or contact me via yongqiang.tian - at - uwaterloo.ca