首发极术社区
如对Arm相关技术感兴趣,欢迎私信aijishu20加入技术微信群。
- 准备:下载sdk,pull docker, 进入docker
sudo docker pull zepan/zhouyi
sudo docker run -i -t zepan/zhouyi /bin/bash
- 验证docker
cd ~/demos/tflite
./run_sim.sh
python3 quant_predict.py
- 下载模型,转换模型
wget http://download.tensorflow.org/models/vgg_16_2016_08_28.tar.gz
tar -xzvf vgg_16_2016_08_28.tar.gz
git clone https://github.com/tensorflow/models.git # dowbload tools
# Get Graph
python3 ./models/research/slim/export_inference_graph.py \
--alsologtostderr --model_name=vgg_16 \
--image_size=224 --labels_offset=0 \
--output_file=./vgg_16_inf.pb
# Frozen
python3 /usr/local/lib/python3.6/dist-packages/tensorflow_core/python/tools/freeze_graph.py \
--input_graph=./vgg_16_inf.pb \
--input_checkpoint=./vgg_16.ckpt \
--input_binary=true --output_graph=./vgg_16_frozen.pb \
--output_node_names=vgg_16/fc8/squeezed
4 To meet requirement, use SDK
>>pip3 uninstall AIPUBuilder
>>cd ~/Zhouyi_Compass/AI610-SDK-r0p0-00eac0/AI610-SDK-1003-r0p0-eac0#
>> source env_setup.sh
work, ignorm the same error in picture!
- gen a config
- /root/demos/tflite/config/tf_vgg_16_run.cfg
- example:
[Common]
mode = run
[Parser]
#model_type = tflite
model_name=vgg_16
detection_postprocess=
model_domain=image_classification
input_model=./vgg_16_frozen.pb
input=input
input_shape=[1, 224, 224, 3]
output=vgg_16/fc8/squeezed
output_dir=./
[AutoQuantizationTool]
quantize_method=SYMMETRIC
quant_precision=int8
ops_per_channel=DepthwiseConv
reverse_rgb=False
label_id_offset=0
dataset_name=
detection_postprocess=
anchor_generator=
log=False
calibration_data=./tflite/dataset/dataset.npy
calibration_label=./tflite/dataset/label.npy
[GBuilder]
inputs=./tflite/model/input.bin
simulator=./tflite/aipu_simulator_z1
outputs=./output_vgg_16.bin
profile=True
target=Z1_0701
- build and run on SDK
>> cd /root/demos/tflite/:
>> aipubuild ./config/tf_vgg_16_run.cfg
- Analysis result
>> cd /root/demos/tflite/
>> python3 ./quant_predict.py output_vgg_16.bin
相关阅读: