Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered.
Shao-kun-Zhang 8b51189d56 | 2 years ago | |
---|---|---|
.. | ||
pytorchcv | 2 years ago | |
quantization_utils | 2 years ago | |
utils | 2 years ago | |
README.md | 2 years ago | |
__init__.py | 2 years ago | |
cifar10_resnet20.hocon | 2 years ago | |
cifar100_resnet20.hocon | 2 years ago | |
conditional_batchnorm.py | 2 years ago | |
dataloader.py | 2 years ago | |
imagenet.hocon | 2 years ago | |
main_direct.py | 2 years ago | |
options.py | 2 years ago | |
test.py | 2 years ago | |
trainer_direct.py | 2 years ago |
Python >= 3.7.10
Pytorch == 1.7.1
cd data_generate
Please install all required package in requirements.txt.
"--save_path_head" in run_generate_cifar10.sh/run_generate_cifar100.sh is the path where you want to save your generated data pickle.
For cifar10/100
bash run_generate_cifar10.sh
bash run_generate_cifar100.sh
For ImageNet
"--save_path_head" in run_generate.sh is the path where you want to save your generated data pickle.
"--model" in run_generate.sh is the pre-trained model you want (also is the quantized model).
You can use resnet18/mobilenet_w1/mobilenetv2_w1.
bash run_generate.sh
cd ..
Modify "qw" and "qa" in cifar10_resnet20.hocon/cifar100_resnet20.hocon/imagenet.hocon to select desired bit-width.
Modify "dataPath" in cifar10_resnet20.hocon/cifar100_resnet20.hocon/imagenet.hocon to the real dataset path (for construct the test dataloader).
Modify the "Path_to_data_pickle" in main_direct.py (line 122 and line 135) to the data_path and label_path you just generate from Stage1.
Use the below commands to train the quantized network. Please note that the model that generates the data and the quantized model should be the same.
For cifar10/100
python main_direct.py --model_name resnet20_cifar10 --conf_path cifar10_resnet20.hocon --id=0
python main_direct.py --model_name resnet20_cifar100 --conf_path cifar100_resnet20.hocon --id=0
For ImageNet, you can choose the model by modifying "--model_name" (resnet18/mobilenet_w1/mobilenetv2_w1)
python main_direct.py --model_name resnet18 --conf_path imagenet.hocon --id=0
The pre-trained models and corresponding logs can be downloaded here
Please make sure the "qw" and "qa" in *.hocon, *.hocon, "--model_name" and "--model_path" are correct.
For cifar10/100
python test.py --model_name resnet20_cifar10 --model_path path_to_pre-trained model --conf_path cifar10_resnet20.hocon
python test.py --model_name resnet20_cifar100 --model_path path_to_pre-trained model --conf_path cifar100_resnet20.hocon
For ImageNet
python test.py --model_name resnet18/mobilenet_w1/mobilenetv2_w1 --model_path path_to_pre-trained model --conf_path imagenet.hocon
Results of pre-trained models are shown below:
Model | Bit-width | Dataset | Top-1 Acc. |
---|---|---|---|
resnet18 | W4A4 | ImageNet | 66.47% |
resnet18 | W5A5 | ImageNet | 69.94% |
mobilenetv1 | W4A4 | ImageNet | 51.36% |
mobilenetv1 | W5A5 | ImageNet | 68.17% |
mobilenetv2 | W4A4 | ImageNet | 65.10% |
mobilenetv2 | W5A5 | ImageNet | 71.28% |
resnet-20 | W3A3 | cifar10 | 77.07% |
resnet-20 | W4A4 | cifar10 | 91.49% |
resnet-20 | W3A3 | cifar100 | 64.98% |
resnet-20 | W4A4 | cifar100 | 48.25% |
神经网络模型压缩框架
Python Jupyter Notebook Cuda C++ Markdown other
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》