- Main only contains the scripts to run quantization on efficientnetv2, check other branches for quantized models
- check the replaced branch for efficientnetV2 with the replaced activation function, hard swish.
- Compiled branch contains code for the compiled version of efficientnet v2 after sturctured pruning, quantization and compilation for DPU 1024, Zynq Mpsoc FPGA
- Branch : Compiled
- Branch: qt_for_latency_blocks
-
Environment requirement - pytorch, opencv, tqdm ... - vai_q_pytorch(Optional, required by quantization) - XIR Python frontend (Optional, required by quantization)
-
Installation with GPU Docker
- Please refer to vitis-ai for how to obtain the GPU docker image.
- Installation without GPU Docker
- Create virtual envrionment and activate it:
conda activate vitis-ai-pytorch
Donload CIFAR-10 Dataset,
or you can set down-true inside the load_data
in efficientnetv3_quant.py
python ./code/test/efficientnetv2_quant.py --device "cpu" --quant_mode calib --subset_len 1000
To deploy model and export it in xmodel format:
sudo /opt/vitis_ai/conda/envs/vitis-ai-wego-torch/bin/python ./code/test/efficientnetv2_quant.py --quant_mode test --subset_len 1 --batch_size=1 --deploy
Similarly for quantization-aware training
Fast fintune models 2000 images, calib 2000 images
export W_QUANT=1
sudo /opt/vitis_ai/conda/envs/vitis-ai-wego-torch/bin/python code/efficientnetv2_QAT.py --device "cpu" --quant_mode calib --fast_finetune --subset_len 50
Test
python code/efficientnetv2_QAT.py --device "cpu" --quant_mode test --fast_finetune
--deploy
python code/efficientnetv2_QAT.py --device "cpu" --quant_mode test --fast_finetune --subset_len 1 --batch_size 1 --deploy