3.矫正集
将图片和label放到calibration目录下的img路径和label.txt下,
执行 preprocess_for_dataset.py 生成 dataset.npy和label.npy矫正集文件。
4.cfg
如附件中 tflite_mobilenet_v1_run.cfg 所示:
[Common]
mode=run
[Parser]
model_type = tflite
model_name = mobilenet_v1
detection_postprocess =
model_domain = image_classification
output = MobilenetV1/Predictions/Reshape_1
input_model = ./mobilenet_v1_1.0_224.tflite
input = input
input_shape = [1,224,224,3]
output_dir = ./
[AutoQuantizationTool]
model_name = mobilenet_v1
quantize_method = SYMMETRIC
ops_per_channel = DepthwiseConv
calibration_data = ./dataset/dataset.npy
calibration_label = ./dataset/label.npy
preprocess_mode = normalize
quant_precision=int8
reverse_rgb = False
label_id_offset = 0
[GBuilder]
inputs=./model/input.bin
simulator=aipu_simulator_z1
outputs=output_mobilenet.bin
profile= True
target=Z1_0701
5.simulator 执行结果
aipubuild config/tflite_mobilenet_v1_run.cfg
运行之后得到 output_mobilenet.bin,使用 quant_predict.py 解析后:
predict first 5 label:
index 231, prob 192, name: Shetland sheepdog, Shetland sheep dog, Shetland
index 232, prob 47, name: collie
index 260, prob 6, name: Pomeranian
index 262, prob 4, name: keeshond
index 233, prob 3, name: Border collie
从结果中可以看出预测到Shetland sheepdog(设得兰牧羊犬).
相关文件请见附件。
文件名 | 大小 | 下载次数 | 操作 |
---|---|---|---|
yicheng.zip | 3.22MB | 14 | 下载 |