1.模型
测试模型:mobilenet_v1_1.0/mobilenet_v2_1.4/inception_v1
下载地址:
https://github.com/tensorflow/models/tree/master/research/slim#pre-trained-models
https://www.tensorflow.org/
2.矫正集的data.npy和label.npy
#以下所有操作docker下运行
sudo docker run -i -t zepan/zhouyi /bin/bash
将图片和label放到calibration目录下的img路径和label.txt下,
python preprocess_for_dataset.py
我这里使用docker下demo中mobilenet的data.npy与label.npy
链接:https://pan.baidu.com/s/15uhkqp4Opm0ljBRyVPeOpQ
提取码:z6w1
3.NN compiler的cfg文件
input节点和output节点需要查看模型结构:https://netron.app/
mobilenet
[Common]
mode = run
[Parser]
model_type = tflite
model_name = mobilenet_v2_1.4
detection_postprocess =
model_domain = image_classification
input_model = ./model/model.tflite
input = input
input_shape = [1, 224, 224, 3]
output = MobilenetV2/Predictions/Reshape_1
output_dir = ./
[AutoQuantizationTool]
quantize_method = SYMMETRIC
quant_precision = int8
ops_per_channel = DepthwiseConv
reverse_rgb = False
label_id_offset =
dataset_name =
detection_postprocess =
anchor_generator =
log = False
calibration_data = ./dataset/dataset.npy
calibration_label = ./dataset/label.npy
[GBuilder]
inputs=./model/input.bin
simulator=aipu_simulator_z1
outputs=mobilenet_v2_1.4.bin
profile= True
target=Z1_0701
inception_v1
[Common]
mode = run
[Parser]
model_type = tflite
model_name = inception_v1
detection_postprocess =
model_domain = image_classification
input_model = ./model/inception_v1.tflite
input = input
input_shape = [1, 224, 224, 3]
output = InceptionV1/Logits/Predictions/Softmax
output_dir = ./
[AutoQuantizationTool]
quantize_method = SYMMETRIC
quant_precision = int8
ops_per_channel = DepthwiseConv
reverse_rgb = False
label_id_offset = 0
log = False
calibration_data = ./dataset/dataset.npy
calibration_label = ./dataset/label.npy
[GBuilder]
inputs=./model/input.bin
simulator=aipu_simulator_z1
outputs=inceptionV1.bin
profile= True
target=Z1_0701
4.simulator执行的输入输出结果(mobilenet)
#拷贝测试图片 如下图
cp dataset/img/ILSVRC2012_val_00000004.JPEG ./model/1.jpg
#生成对应图片的input.bin
cd model
python gen_inputbin.py
#run
cd ..
./run_sim.sh
#解析bin
python quant_predict.py
结论
可能由于校验数据太少,精度还有点问题,几张demo图中就这个碗有点效果;后续更换自己数据模型精度可能会正常。
7.16补充inception_v1结果
这模型精度比较正常了。。。换个图再测试下: