13 Star 63 Fork 280

Ascend/ModelZoo-TensorFlow

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
.idea
ACL_TensorFlow
built-in
audio
cv
2D_Attention_Unet_for_ACL
3DUNET_for_ACL
Advanced_East_for_ACL
AlexNet_for_ACL
AlignedReID_for_ACL
CRNN_for_ACL
CTPN_for_ACL
DeepLabv3_for_ACL
DeepLabv3_plus_for_ACL
DenseNet121_for_ACL
Densenet24_for_ACL
EfficientNet_B0_for_ACL
EfficientNet_B8_for_ACL
Face_Resnet50_for_ACL
Facenet_for_ACL
GoogleNet_for_ACL
Inceptionv2_for_ACL
Inceptionv3_for_ACL
Inceptionv4_for_ACL
MobileNetv1_for_ACL
MobileNetv2_for_ACL
MobileNetv3_Large_for_ACL
OpenPose_for_ACL
PSPnet101_for_ACL
PixelLink_for_ACL
ResCNN_for_ACL
ResNext50_for_ACL
Resnet101_for_ACL
Resnet18_for_ACL
Resnet34_for_ACL
Resnet50_HC_for_ACL
Resnet50_TF_for_ACL
Resnet50v1.5_for_ACL
Resnet50v1_for_ACL
RetinaNet_for_ACL
SSD-Resnet34_for_ACL
SSD_Resnet50_FPN_for_ACL
ShuffleNetv1_for_ACL
ShuffleNetv2_for_ACL
Vgg16_for_ACL
Vgg19_for_ACL
Xception_for_ACL
YOLOv2_for_ACL
YOLOv3_for_ACL
Benchmark
scripts
LICENSE
README.md
README_EN.md
build.sh
coco.names
requirements.txt
yolov3_tf_aipp.cfg
YOLOv4_for_ACL
graph
nlp
recommendation
reinforcement_learning
contrib
.keep
TensorFlow
TensorFlow2
Tools/ascend_distribute
.gitignore
.gitmodules
LICENSE
NOTICE
README.CN.md
README.md
Third_Party_Open_Source_Software_Notice
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
3年前
Loading...
README

中文|English

Yolov3 TensorFlow离线推理

此链接提供Yolov3 TensorFlow模型在NPU上离线推理的脚本和方法

注意

此案例仅为您学习Ascend软件栈提供参考,不用于商业目的。

在开始之前,请注意以下适配条件。如果不匹配,可能导致运行失败。

Conditions Need
CANN版本 >=5.0.3
芯片平台 Ascend310/Ascend310P3
第三方依赖 请参考 'requirements.txt'

快速指南

1. 拷贝代码

git clone https://gitee.com/ascend/ModelZoo-TensorFlow.git
cd Modelzoo-TensorFlow/ACL_TensorFlow/built-in/cv/YOLOv3_for_ACL

2. 必要条件

opencv-python==4.2.0.34

3. 下载数据集和预处理

  1. 数据集 例如,与官方实施相比,我们使用 get_coco_dataset.sh 准备我们的数据集。

  2. 注释文件

    cd scripts

    Using script generate coco2014_minival.txt file. Modify the path in coco_minival_anns.py and 5k.txt, then execute:

    python3 coco_minival_anns.py
    

    One line for one image, in the format like image_index image_absolute_path img_width img_height box_1 box_2 ... box_n.
    Box_x format:

    • label_index x_min y_min x_max y_max. (The origin of coordinates is at the left top corner, left top => (xmin, ymin), right bottom => (xmax, ymax).)
    • image_index is the line index which starts from zero. label_index is in range [0, class_num - 1].

    例如:

    0 xxx/xxx/a.jpg 1920 1080 0 453 369 473 391 1 588 245 608 268
    1 xxx/xxx/b.jpg 1920 1080 1 466 403 485 422 2 793 300 809 320
    ...
    

3. 离线推理

离线模型转换

  • 环境变量设置

    请参考说明,设置环境变量

  • Pb模型转换为om模型

    pb模型下载链接

    For Ascend310:

    atc --model=yolov3_tf.pb --framework=3 --output=yolov3_tf_aipp --output_type=FP32 --soc_version=Ascend310 --input_shape="input:1,416,416,3" --log=info --insert_op_conf=yolov3_tf_aipp.cfg
    

    For Ascend310P3:

    atc --model=yolov3_tf.pb --framework=3 --output=yolov3_tf_aipp --output_type=FP32 --soc_version=Ascend310P3 --input_shape="input:1,416,416,3" --log=info --insert_op_conf=yolov3_tf_aipp.cfg
    
  • 编译程序

    For Ascend310:

    unset ASCEND310P3_DVPP
    bash build.sh
    

    For Ascend310P3:

    export ASCEND310P3_DVPP=1
    bash build.sh
    
  • 开始运行:

    cd scripts
    bash benchmark_tf.sh --batchSize=1 --modelType=yolov3 --imgType=raw --precision=fp16 --outputType=fp32 --useDvpp=1 --deviceId=0 --modelPath=yolov3_tf_aipp.om --trueValuePath=instance_val2014.json --imgInfoFile=coco2014_minival.txt --classNamePath=../../coco.names
    

推理结果

结果

本结果是通过运行上面适配的推理脚本获得的。要获得相同的结果,请按照《快速指南》中的步骤操作。

推理精度结果

IoU=0.5

model Npu_nums mAP
Yolov3 1 55.3%

参考

[1] https://gitee.com/ascend/ModelZoo-TensorFlow/tree/master/TensorFlow/built-in/cv/detection/YoloV3_ID0076_for_TensorFlow

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ascend/ModelZoo-TensorFlow.git
git@gitee.com:ascend/ModelZoo-TensorFlow.git
ascend
ModelZoo-TensorFlow
ModelZoo-TensorFlow
master

搜索帮助