1.原始模型文件
百度云盘下载: 链接 提取码: 2kyw
2.矫正集的data.npy和label.npy
先在model目录,运行gen_inputbin.py,生成input.bin测试集
将量化图片放到dataset的img目录下,运行preprocess_dataset.py,生成dataset.npy和label.npy
3.NN compiler的cfg文件
[Common]
mode = run
[Parser]
model_type = tflite
model_name = mobilenet_v1
detection_postprocess =
model_domain = image_classification
input_model = ./mobilenet_v1_1.0_224/mobilenet_v1_1.0_224.tflite
input = input
input_shape = [1, 224, 224, 3]
output = MobilenetV1/Predictions/Reshape_1
output_dir = ./
[AutoQuantizationTool]
quantize_method = SYMMETRIC
quant_precision = int8
model_name = mobilenet_v1
ops_per_channel = DepthwiseConv
reverse_rgb = False
preprocess_mode = normalize
label_id_offset = 0
calibration_data = ./dataset/dataset.npy
calibration_label = ./dataset/label.npy
[GBuilder]
inputs=./model/input.bin
outputs = output_mobilenet_v1.bin
simulator=aipu_simulator_z1
profile= True
target = Z1_0701
4.simulator执行的输入输出结果
AIPU仿真执行,aipubuild config/tflite_mobilenet_v1_build.cfg,得到运行结果文件output_mobilenet_v1.bin
5.结果解析
运行quant_predict.py,对结果进行解析
predict first 5 label:
index 262, prob 50, name: keeshond
index 250, prob 39, name: malamute, malemute, Alaskan malamute
index 232, prob 30, name: collie
index 225, prob 27, name: groenendael
index 236, prob 16, name: German shepherd, German shepherd dog, German police dog, alsatian
从结果看出,推理预测keeshond(荷兰毛狮犬)概率更高
6.测试图片
运行相关文件请见附件
百度云盘下载:附件 提取码: 53kg