Michael杨 · 2021年07月19日

【周易AIPU 仿真】R329 + ubuntu20.04+ docker+ tf_vgg_16

提交notion_r329_example


  1. 准备:下载sdk,pull docker, 进入docker

    sudo docker pull zepan/zhouyi
    sudo docker run -i -t zepan/zhouyi  /bin/bash
  2. 验证docker

    cd ~/demos/tflite
    ./run_sim.sh
    python3 quant_predict.py
  3. 下载模型,转换模型

    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!
image.png

  1. 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
  2. build and run on SDK

    >> cd /root/demos/tflite/:
    >> aipubuild ./config/tf_vgg_16_run.cfg
  3. Analysis result
>> cd /root/demos/tflite/
>> python3 ./quant_predict.py output_vgg_16.bin

image.png

推荐阅读
关注数
7443
内容数
92
人工智能边缘计算软硬件解决方案,提供高性能、低成本、低功耗、易使用的硬件选型方案.
目录
极术微信服务号
关注极术微信号
实时接收点赞提醒和评论通知
安谋科技学堂公众号
关注安谋科技学堂
实时获取安谋科技及 Arm 教学资源
安谋科技招聘公众号
关注安谋科技招聘
实时获取安谋科技中国职位信息