以下介绍通过ATC模型转换工具获取离线模型的操作步骤,更多操作请参见《ATC工具使用指南》。
例如:resnet50.prototxt和resnet50.caffemodel
atc --model=$HOME/module/resnet50.prototxt --weight=$HOME/module/resnet50.caffemodel --framework=0 --output=$HOME/module/out/caffe_resnet50 --soc_version=Ascend310B1
ATC run success
成功执行命令后,在--output参数指定的路径下,可查看离线模型(如:resnet50.om)。
atc --mode=1 --om=$HOME/module/out/caffe_resnet50/resnet50.om --json=/home/HwHiAiUser/data/resnet50.json
以下介绍通过AMCT工具获取量化信息文件的操作步骤,更多操作请参见《AMCT工具(Caffe)》。
例如:resnet50.prototxt和resnet50.caffemodel
cd data mkdir image && cd image wget https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/models/amct_acl/classification/calibration.rar unrar e calibration.rar
python3 ./src/process_data.py
执行完成后,在data目录会生成新的calibration目录,并在该目录生成calibration.bin格式数据集。
amct_caffe calibration --model=./model/resnet50.prototxt --weights=./model/resnet50.caffemodel --save_path=./results --input_shape="data:1,3,224,224" --data_dir="./data/calibration" --data_types="float32"
INFO - [AMCT]:[Utils]: The weights_file is saved in $HOME/xxx/results/resnet50_fake_quant_weights.caffemodel INFO - [AMCT]:[Utils]: The model_file is saved in $HOME/xxx/results/resnet50_fake_quant_model.prototxt
resnet50_deploy_model.prototxt和resnet50_deploy_weights.caffemodel文件可用于进行ATC模型转换,resnet50_fake_quant_model.prototxt和resnet50_fake_quant_weights.caffemodel可用于进行Caffe量化原始模型的dump操作。
将从量化原始模型和量化信息文件操作中获取到的量化原始模型文件resnet50_deploy_model.prototxt和resnet50_deploy_weights.caffemodel,以全网层信息文件中的ATC操作执行模型转换即可获取到量化离线模型文件和量化离线模型文件转换的json文件。