参考文章:https://blog.csdn.net/u014644466/article/details/83278954
准备:
(1)测试网络的prototxt文件
(2)训练生成的caffemodel文件
(3)验证集图像文件
(4)工具下载:git clone https://github.com/lyk125/caffe-int8-convert-tools.git
ncnn官网推荐工具:https://github.com/BUG1989/caffe-int8-convert-tools
(5)caffe深度学习框架
模型转换:
1、输入为三通道模型:不用预处理
2、转换工具生成table文件:
注意:转换前,一定要将模型更新成最新模型。而且要严格按照如下步骤:
https://blog.csdn.net/weixin_41770169/article/details/86543010
$ ~/caffe/build/tools/upgrade_net_proto_text mobilenet_deploy.prototxt mobilenet_deploy_new.prototxt
$ ~/caffe/build/tools/upgrade_net_proto_binary mobilenet.caffemodel mobilenet_new.caffemodel
table文件转换:
python caffe-int8-convert-tool.py --proto=mobilenet_deploy_new.prototxt --model=mobilenet_new.caffemodel --mean 104 117 123 --images=ILSVRC2012_1k --output=mobilenet_new.table --gpu=1
3、caffe2ncnn转换
./caffe2ncnn mobilenet_deploy_new.prototxt mobilenet_new.caffemodel mobilenet_new.param mobilenet_new.bin 256 mobilenet_new.table
我这里原模型大小44M,压缩后11M。