From 6ef451f694659be910ed4634423f09e77d9eb651 Mon Sep 17 00:00:00 2001 From: lrving <2415912278@qq.com> Date: Wed, 19 Oct 2022 03:07:55 +0000 Subject: [PATCH 01/17] add ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README_EN. Signed-off-by: lrving <2415912278@qq.com> --- ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README_EN.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README_EN.md diff --git a/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README_EN.md b/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README_EN.md new file mode 100644 index 000000000..e69de29bb -- Gitee From 9d42af26e83a4b2db7058dcda963e1d2394357d4 Mon Sep 17 00:00:00 2001 From: lrving <2415912278@qq.com> Date: Wed, 19 Oct 2022 03:09:39 +0000 Subject: [PATCH 02/17] update ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README_EN.md. Signed-off-by: lrving <2415912278@qq.com> --- .../built-in/cv/Vgg19_for_ACL/README_EN.md | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README_EN.md b/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README_EN.md index e69de29bb..41b657481 100644 --- a/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README_EN.md +++ b/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README_EN.md @@ -0,0 +1,89 @@ + + +# Vgg19 Inference for Tensorflow + +This repository provides a script and recipe to Inference of the Vgg19 model. + +## Notice +**This sample only provides reference for you to learn the Ascend software stack and is not for commercial purposes.** + +Before starting, please pay attention to the following adaptation conditions. If they do not match, may leading in failure. + +| Conditions | Need | +| --- | --- | +| CANN Version | >=5.0.3 | +| Chip Platform| Ascend310/Ascend310P3 | +| 3rd Party Requirements| Please follow the 'requirements.txt' | + +## Quick Start Guide + +### 1. Clone the respository + +```shell +git clone https://gitee.com/ascend/ModelZoo-TensorFlow.git +cd Modelzoo-TensorFlow/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL +``` + +### 2. Download and preprocess the dataset + +1. Download the ImageNet2012 Validation dataset by yourself. You can get the validation pictures(50000 JPEGS and a ILSVRC2012val-label-index.txt) + +2. Put JPEGS to **'scripts/ILSVRC2012val'** and label text to **'scripts/'** + +3. Images Preprocess: +``` +cd scripts +mkdir input_bins +python3 vgg19_preprocessing.py ./ILSVRC2012val/ ./input_bins/ +``` +The jpegs pictures will be preprocessed to bin fils. + +### 3. Offline Inference + +**Convert pb to om.** + +- configure the env + + ``` + export install_path=/usr/local/Ascend + export PATH=/usr/local/python3.7.5/bin:${install_path}/atc/ccec_compiler/bin:${install_path}/atc/bin:$PATH + export PYTHONPATH=${install_path}/atc/python/site-packages:${install_path}/atc/python/site-packages/auto_tune.egg/auto_tune:${install_path}/atc/python/site-packages/schedule_search.egg:$PYTHONPATH + export LD_LIBRARY_PATH=${install_path}/atc/lib64:${install_path}/acllib/lib64:$LD_LIBRARY_PATH + export ASCEND_OPP_PATH=${install_path}/opp + ``` + +- convert pb to om + + [pb download link](https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/003_Atc_Models/modelzoo/Official/cv/Vgg19_for_ACL.zip) + + ``` + atc --model=vgg19_tf.pb --framework=3 --output=vgg19_tf_1batch --output_type=FP32 --soc_version=Ascend310 --input_shape="input:1,224,224,3" --insert_op_conf=vgg19_tf_aipp.cfg --enable_small_channel=1 --log=info + ``` + +- Build the program + + ``` + bash build.sh + ``` + +- Run the program: + + ``` + cd scripts + bash benchmark_tf.sh + ``` + +## Performance + +### Result + +Our result was obtained by running the applicable inference script. To achieve the same results, follow the steps in the Quick Start Guide. + +#### Inference accuracy results + +| model | **data** | Top1/Top5 | +| :---------------: | :-------: | :-------------: | +| offline Inference | 50000 images | 71.0 %/ 89.8% | + +## Reference +[1] https://github.com/tensorflow/models/tree/master/research/slim \ No newline at end of file -- Gitee From b8bd04f2d13f4f245e68f9344f01741ac4430311 Mon Sep 17 00:00:00 2001 From: lrving <2415912278@qq.com> Date: Wed, 19 Oct 2022 03:22:44 +0000 Subject: [PATCH 03/17] update ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md. Signed-off-by: lrving <2415912278@qq.com> --- .../built-in/cv/Vgg19_for_ACL/README.md | 57 +++++++------------ 1 file changed, 21 insertions(+), 36 deletions(-) diff --git a/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md b/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md index 41b657481..f552a372b 100644 --- a/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md +++ b/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md @@ -1,13 +1,13 @@ +中文|[English](README_EN.md) +# Vgg19 TensorFlow离线推理 -# Vgg19 Inference for Tensorflow - -This repository provides a script and recipe to Inference of the Vgg19 model. +此链接提供Vgg19 TensorFlow模型在NPU上离线推理的脚本和方法 ## Notice -**This sample only provides reference for you to learn the Ascend software stack and is not for commercial purposes.** +**此案例仅为您学习Ascend软件堆栈提供参考,不用于商业目的。** -Before starting, please pay attention to the following adaptation conditions. If they do not match, may leading in failure. +在开始之前,请注意以下适配条件。如果不匹配,可能导致运行失败。 | Conditions | Need | | --- | --- | @@ -15,44 +15,29 @@ Before starting, please pay attention to the following adaptation conditions. If | Chip Platform| Ascend310/Ascend310P3 | | 3rd Party Requirements| Please follow the 'requirements.txt' | -## Quick Start Guide +## 快速指南 -### 1. Clone the respository +### 1. 拷贝代码 ```shell git clone https://gitee.com/ascend/ModelZoo-TensorFlow.git cd Modelzoo-TensorFlow/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL ``` -### 2. Download and preprocess the dataset - -1. Download the ImageNet2012 Validation dataset by yourself. You can get the validation pictures(50000 JPEGS and a ILSVRC2012val-label-index.txt) - -2. Put JPEGS to **'scripts/ILSVRC2012val'** and label text to **'scripts/'** +### 2. 下载数据集和预处理 -3. Images Preprocess: -``` -cd scripts -mkdir input_bins -python3 vgg19_preprocessing.py ./ILSVRC2012val/ ./input_bins/ -``` -The jpegs pictures will be preprocessed to bin fils. +1. 请自行下载ImageNet2012测试数据集 -### 3. Offline Inference +### 3. 离线推理 -**Convert pb to om.** +**离线模型转换** -- configure the env +- 环境变量设置 - ``` - export install_path=/usr/local/Ascend - export PATH=/usr/local/python3.7.5/bin:${install_path}/atc/ccec_compiler/bin:${install_path}/atc/bin:$PATH - export PYTHONPATH=${install_path}/atc/python/site-packages:${install_path}/atc/python/site-packages/auto_tune.egg/auto_tune:${install_path}/atc/python/site-packages/schedule_search.egg:$PYTHONPATH - export LD_LIBRARY_PATH=${install_path}/atc/lib64:${install_path}/acllib/lib64:$LD_LIBRARY_PATH - export ASCEND_OPP_PATH=${install_path}/opp + 请参考[说明](https://gitee.com/ascend/ModelZoo-TensorFlow/wikis/02.%E7%A6%BB%E7%BA%BF%E6%8E%A8%E7%90%86%E6%A1%88%E4%BE%8B/Ascend%E5%B9%B3%E5%8F%B0%E6%8E%A8%E7%90%86%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%E8%AE%BE%E7%BD%AE?sort_id=6458719),设置环境变量 ``` -- convert pb to om +- Pb模型转换为om模型 [pb download link](https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/003_Atc_Models/modelzoo/Official/cv/Vgg19_for_ACL.zip) @@ -60,30 +45,30 @@ The jpegs pictures will be preprocessed to bin fils. atc --model=vgg19_tf.pb --framework=3 --output=vgg19_tf_1batch --output_type=FP32 --soc_version=Ascend310 --input_shape="input:1,224,224,3" --insert_op_conf=vgg19_tf_aipp.cfg --enable_small_channel=1 --log=info ``` -- Build the program +- 编译程序 ``` bash build.sh ``` -- Run the program: +- 开始运行: ``` cd scripts bash benchmark_tf.sh ``` -## Performance +## 推理结果 -### Result +### 结果 -Our result was obtained by running the applicable inference script. To achieve the same results, follow the steps in the Quick Start Guide. +本结果是通过运行上面适配的推理脚本获得的。要获得相同的结果,请按照《快速入门指南》中的步骤操作。 -#### Inference accuracy results +#### 推理精度结果 | model | **data** | Top1/Top5 | | :---------------: | :-------: | :-------------: | | offline Inference | 50000 images | 71.0 %/ 89.8% | -## Reference +## 参考 [1] https://github.com/tensorflow/models/tree/master/research/slim \ No newline at end of file -- Gitee From 2c6f9bf616e15bddf5a0d080797acf8a0470327d Mon Sep 17 00:00:00 2001 From: lrving <2415912278@qq.com> Date: Wed, 19 Oct 2022 03:26:12 +0000 Subject: [PATCH 04/17] update ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md. Signed-off-by: lrving <2415912278@qq.com> --- ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md b/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md index f552a372b..ba9f04f2e 100644 --- a/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md +++ b/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md @@ -35,7 +35,6 @@ cd Modelzoo-TensorFlow/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL - 环境变量设置 请参考[说明](https://gitee.com/ascend/ModelZoo-TensorFlow/wikis/02.%E7%A6%BB%E7%BA%BF%E6%8E%A8%E7%90%86%E6%A1%88%E4%BE%8B/Ascend%E5%B9%B3%E5%8F%B0%E6%8E%A8%E7%90%86%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%E8%AE%BE%E7%BD%AE?sort_id=6458719),设置环境变量 - ``` - Pb模型转换为om模型 -- Gitee From 31da376560f8f88fe6e40d6fdab0be6cc48f3ca7 Mon Sep 17 00:00:00 2001 From: lrving <2415912278@qq.com> Date: Wed, 19 Oct 2022 03:33:45 +0000 Subject: [PATCH 05/17] update ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md. Signed-off-by: lrving <2415912278@qq.com> --- .../built-in/cv/Vgg19_for_ACL/README.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md b/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md index ba9f04f2e..8e1849000 100644 --- a/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md +++ b/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md @@ -5,7 +5,7 @@ 此链接提供Vgg19 TensorFlow模型在NPU上离线推理的脚本和方法 ## Notice -**此案例仅为您学习Ascend软件堆栈提供参考,不用于商业目的。** +**此案例仅为您学习Ascend软件栈提供参考,不用于商业目的。** 在开始之前,请注意以下适配条件。如果不匹配,可能导致运行失败。 @@ -39,14 +39,23 @@ cd Modelzoo-TensorFlow/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL - Pb模型转换为om模型 [pb download link](https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/003_Atc_Models/modelzoo/Official/cv/Vgg19_for_ACL.zip) - + For Ascend310: ``` atc --model=vgg19_tf.pb --framework=3 --output=vgg19_tf_1batch --output_type=FP32 --soc_version=Ascend310 --input_shape="input:1,224,224,3" --insert_op_conf=vgg19_tf_aipp.cfg --enable_small_channel=1 --log=info ``` - + For Ascend310P3: + ``` + atc --model=vgg19_tf.pb --framework=3 --output=vgg19_tf_1batch --output_type=FP32 --soc_version=Ascend310P3 --input_shape="input:1,224,224,3" --insert_op_conf=vgg19_tf_aipp.cfg --enable_small_channel=1 --log=info + ``` - 编译程序 - + For Ascend310: + ``` + unset ASCEND310P3_DVPP + bash build.sh + ``` + For Ascend310P3: ``` + export ASCEND310P3_DVPP=1 bash build.sh ``` -- Gitee From 683b8ceab2eb648e4c4bc34688de3b4678cbee52 Mon Sep 17 00:00:00 2001 From: lrving <2415912278@qq.com> Date: Wed, 19 Oct 2022 03:37:59 +0000 Subject: [PATCH 06/17] update ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md. Signed-off-by: lrving <2415912278@qq.com> --- ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md b/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md index 8e1849000..8b1c592cd 100644 --- a/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md +++ b/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md @@ -39,6 +39,7 @@ cd Modelzoo-TensorFlow/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL - Pb模型转换为om模型 [pb download link](https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/003_Atc_Models/modelzoo/Official/cv/Vgg19_for_ACL.zip) + For Ascend310: ``` atc --model=vgg19_tf.pb --framework=3 --output=vgg19_tf_1batch --output_type=FP32 --soc_version=Ascend310 --input_shape="input:1,224,224,3" --insert_op_conf=vgg19_tf_aipp.cfg --enable_small_channel=1 --log=info @@ -48,6 +49,7 @@ cd Modelzoo-TensorFlow/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL atc --model=vgg19_tf.pb --framework=3 --output=vgg19_tf_1batch --output_type=FP32 --soc_version=Ascend310P3 --input_shape="input:1,224,224,3" --insert_op_conf=vgg19_tf_aipp.cfg --enable_small_channel=1 --log=info ``` - 编译程序 + For Ascend310: ``` unset ASCEND310P3_DVPP -- Gitee From c33711acfe25a21debdbd647d455047a0d1cb9bd Mon Sep 17 00:00:00 2001 From: lrving <2415912278@qq.com> Date: Wed, 19 Oct 2022 03:38:47 +0000 Subject: [PATCH 07/17] update ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md. Signed-off-by: lrving <2415912278@qq.com> --- ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md b/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md index 8b1c592cd..6f8fd7cab 100644 --- a/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md +++ b/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md @@ -44,7 +44,7 @@ cd Modelzoo-TensorFlow/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL ``` atc --model=vgg19_tf.pb --framework=3 --output=vgg19_tf_1batch --output_type=FP32 --soc_version=Ascend310 --input_shape="input:1,224,224,3" --insert_op_conf=vgg19_tf_aipp.cfg --enable_small_channel=1 --log=info ``` - For Ascend310P3: + For Ascend310P3: ``` atc --model=vgg19_tf.pb --framework=3 --output=vgg19_tf_1batch --output_type=FP32 --soc_version=Ascend310P3 --input_shape="input:1,224,224,3" --insert_op_conf=vgg19_tf_aipp.cfg --enable_small_channel=1 --log=info ``` -- Gitee From e6e9d60d060b474d6e65c3d06b778e6c678b25ba Mon Sep 17 00:00:00 2001 From: lrving <2415912278@qq.com> Date: Wed, 19 Oct 2022 03:39:52 +0000 Subject: [PATCH 08/17] update ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md. Signed-off-by: lrving <2415912278@qq.com> --- ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md b/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md index 6f8fd7cab..903f2f4b4 100644 --- a/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md +++ b/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md @@ -45,7 +45,7 @@ cd Modelzoo-TensorFlow/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL atc --model=vgg19_tf.pb --framework=3 --output=vgg19_tf_1batch --output_type=FP32 --soc_version=Ascend310 --input_shape="input:1,224,224,3" --insert_op_conf=vgg19_tf_aipp.cfg --enable_small_channel=1 --log=info ``` For Ascend310P3: - ``` + ``` atc --model=vgg19_tf.pb --framework=3 --output=vgg19_tf_1batch --output_type=FP32 --soc_version=Ascend310P3 --input_shape="input:1,224,224,3" --insert_op_conf=vgg19_tf_aipp.cfg --enable_small_channel=1 --log=info ``` - 编译程序 -- Gitee From dcd2c8c482949b6c9bb04ec844fc5004ad27590f Mon Sep 17 00:00:00 2001 From: lrving <2415912278@qq.com> Date: Wed, 19 Oct 2022 03:41:00 +0000 Subject: [PATCH 09/17] update ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md. Signed-off-by: lrving <2415912278@qq.com> --- ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md b/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md index 903f2f4b4..de13d518e 100644 --- a/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md +++ b/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md @@ -4,7 +4,7 @@ 此链接提供Vgg19 TensorFlow模型在NPU上离线推理的脚本和方法 -## Notice +## 注意 **此案例仅为您学习Ascend软件栈提供参考,不用于商业目的。** 在开始之前,请注意以下适配条件。如果不匹配,可能导致运行失败。 -- Gitee From 6b090f2e4ad84271379d28727aa86888ce078690 Mon Sep 17 00:00:00 2001 From: lrving <2415912278@qq.com> Date: Wed, 19 Oct 2022 03:42:39 +0000 Subject: [PATCH 10/17] update ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README_EN.md. Signed-off-by: lrving <2415912278@qq.com> --- ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README_EN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README_EN.md b/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README_EN.md index 41b657481..e0d153920 100644 --- a/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README_EN.md +++ b/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README_EN.md @@ -1,4 +1,4 @@ - +English|[中文](README.md) # Vgg19 Inference for Tensorflow -- Gitee From d2b1735d278986fd145570a470a277247016c2ad Mon Sep 17 00:00:00 2001 From: lrving <2415912278@qq.com> Date: Wed, 19 Oct 2022 03:44:31 +0000 Subject: [PATCH 11/17] update ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md. Signed-off-by: lrving <2415912278@qq.com> --- ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md b/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md index de13d518e..14a16cca2 100644 --- a/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md +++ b/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README.md @@ -72,7 +72,7 @@ cd Modelzoo-TensorFlow/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL ### 结果 -本结果是通过运行上面适配的推理脚本获得的。要获得相同的结果,请按照《快速入门指南》中的步骤操作。 +本结果是通过运行上面适配的推理脚本获得的。要获得相同的结果,请按照《快速指南》中的步骤操作。 #### 推理精度结果 -- Gitee From 44a9217753df6862a71bb097ae70db59e88b8983 Mon Sep 17 00:00:00 2001 From: lrving <2415912278@qq.com> Date: Wed, 19 Oct 2022 03:53:23 +0000 Subject: [PATCH 12/17] update ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README_EN.md. Signed-off-by: lrving <2415912278@qq.com> --- ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README_EN.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README_EN.md b/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README_EN.md index e0d153920..a949ceaff 100644 --- a/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README_EN.md +++ b/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README_EN.md @@ -44,13 +44,7 @@ The jpegs pictures will be preprocessed to bin fils. - configure the env - ``` - export install_path=/usr/local/Ascend - export PATH=/usr/local/python3.7.5/bin:${install_path}/atc/ccec_compiler/bin:${install_path}/atc/bin:$PATH - export PYTHONPATH=${install_path}/atc/python/site-packages:${install_path}/atc/python/site-packages/auto_tune.egg/auto_tune:${install_path}/atc/python/site-packages/schedule_search.egg:$PYTHONPATH - export LD_LIBRARY_PATH=${install_path}/atc/lib64:${install_path}/acllib/lib64:$LD_LIBRARY_PATH - export ASCEND_OPP_PATH=${install_path}/opp - ``` + Please follow the guide to set the envs - convert pb to om -- Gitee From 9561be469c1191785f7ef7775d994110fddbcbe2 Mon Sep 17 00:00:00 2001 From: lrving <2415912278@qq.com> Date: Wed, 19 Oct 2022 03:54:37 +0000 Subject: [PATCH 13/17] update ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README_EN.md. Signed-off-by: lrving <2415912278@qq.com> --- ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README_EN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README_EN.md b/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README_EN.md index a949ceaff..c463bfe67 100644 --- a/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README_EN.md +++ b/ACL_TensorFlow/built-in/cv/Vgg19_for_ACL/README_EN.md @@ -44,7 +44,7 @@ The jpegs pictures will be preprocessed to bin fils. - configure the env - Please follow the guide to set the envs + Please follow the [guide](https://gitee.com/ascend/ModelZoo-TensorFlow/wikis/02.%E7%A6%BB%E7%BA%BF%E6%8E%A8%E7%90%86%E6%A1%88%E4%BE%8B/Ascend%E5%B9%B3%E5%8F%B0%E6%8E%A8%E7%90%86%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%E8%AE%BE%E7%BD%AE?sort_id=6458719) to set the envs - convert pb to om -- Gitee From ae7edcd284679f9c98d958fc07200e791436c021 Mon Sep 17 00:00:00 2001 From: lrving <2415912278@qq.com> Date: Wed, 19 Oct 2022 05:35:42 +0000 Subject: [PATCH 14/17] add ACL_TensorFlow/built-in/cv/YOLOv2_for_ACL/README_EN.md. Signed-off-by: lrving <2415912278@qq.com> --- .../built-in/cv/YOLOv2_for_ACL/README_EN.md | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 ACL_TensorFlow/built-in/cv/YOLOv2_for_ACL/README_EN.md diff --git a/ACL_TensorFlow/built-in/cv/YOLOv2_for_ACL/README_EN.md b/ACL_TensorFlow/built-in/cv/YOLOv2_for_ACL/README_EN.md new file mode 100644 index 000000000..89b4719d8 --- /dev/null +++ b/ACL_TensorFlow/built-in/cv/YOLOv2_for_ACL/README_EN.md @@ -0,0 +1,103 @@ +English|[中文](README.md) + +# YOLOv2 Inference for Tensorflow + +This repository provides a script and recipe to Inference of the YOLOv2 model. + +## Notice +**This sample only provides reference for you to learn the Ascend software stack and is not for commercial purposes.** + +Before starting, please pay attention to the following adaptation conditions. If they do not match, may leading in failure. + +| Conditions | Need | +| --- | --- | +| CANN Version | >=5.0.3 | +| Chip Platform| Ascend310/Ascend310P3 | +| 3rd Party Requirements| Please follow the 'requirements.txt' | + +## Quick Start Guide + +### 1. Clone the respository + +```shell +git clone https://gitee.com/ascend/ModelZoo-TensorFlow.git +cd Modelzoo-TensorFlow/ACL_TensorFlow/built-in/cv/YOLOv2_for_ACL +``` + +### 2. Download and preprocess the dataset + +1. Download the VOC2007 test dataset by yourself, then extract **VOCtest_06-Nov-2007.tar**. + +2. Move VOC2007 test dataset to **'scripts/VOC2007'** like this: +``` +VOC2007 +|----Annotations +|----ImageSets +|----JPEGImages +|----SegmentationClass +|----SegmentationObject +``` + +3. Images Preprocess: +``` +cd scripts +mkdir input_bins +python3 preprocess.py ./VOC2007/JPEGImages/ ./input_bins/ +``` + The pictures will be preprocessed to bin files. + + +4. Convert Groundtruth labels to text format +``` +python3 xml2txt.py ./VOC2007/Annotations/ ./yolov2_postprocess/groundtruths/ +``` + +### 3. Offline Inference + +**Convert pb to om.** + +- configure the env + Please follow the [guide](https://gitee.com/ascend/ModelZoo- +TensorFlow/wikis/02.%E7%A6%BB%E7%BA%BF%E6%8E%A8%E7%90%86%E6%A1%88%E4%BE%8B/Ascend%E5%B9%B3%E5% +8F%B0%E6%8E%A8%E7%90%86%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%E8%AE%BE%E7%BD%AE?sort_id=6458719) to set the envs + + +- convert pb to om + + [pb download link](https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/003_Atc_Models/modelzoo/yolov2_tf.pb) + + 以batcsize=1为例: + + ``` + atc --model=./yolov2.pb --input_shape='Placeholder:1,416,416,3' --input_format=NHWC --output=./yolov2_tf_1batch --soc_version=Ascend310 --framework=3 + ``` + +- Build the program + + ``` + bash build.sh + ``` + +- Run the program: + + ``` + cd scripts + bash benchmark_tf.sh + ``` + +## Performance + +### Result + +Our result was obtained by running the applicable inference script. To achieve the same results, follow the steps in the Quick Start Guide. + +#### Inference accuracy results + +| model | **data** | mAP | +| :---------------: | :-------: | :-------------: | +| offline Inference | 4952 images | 59.43% | + +## Reference +[1] https://github.com/KOD-Chen/YOLOv2-Tensorflow + + -- Gitee From d98d0d90646860f3bfec35f72673c1cd5e3a4e60 Mon Sep 17 00:00:00 2001 From: lrving <2415912278@qq.com> Date: Wed, 19 Oct 2022 05:36:47 +0000 Subject: [PATCH 15/17] update ACL_TensorFlow/built-in/cv/YOLOv2_for_ACL/README_EN.md. Signed-off-by: lrving <2415912278@qq.com> --- ACL_TensorFlow/built-in/cv/YOLOv2_for_ACL/README_EN.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ACL_TensorFlow/built-in/cv/YOLOv2_for_ACL/README_EN.md b/ACL_TensorFlow/built-in/cv/YOLOv2_for_ACL/README_EN.md index 89b4719d8..8a6824cf4 100644 --- a/ACL_TensorFlow/built-in/cv/YOLOv2_for_ACL/README_EN.md +++ b/ACL_TensorFlow/built-in/cv/YOLOv2_for_ACL/README_EN.md @@ -57,9 +57,9 @@ python3 xml2txt.py ./VOC2007/Annotations/ ./yolov2_postprocess/groundtruths/ **Convert pb to om.** - configure the env - Please follow the [guide](https://gitee.com/ascend/ModelZoo- -TensorFlow/wikis/02.%E7%A6%BB%E7%BA%BF%E6%8E%A8%E7%90%86%E6%A1%88%E4%BE%8B/Ascend%E5%B9%B3%E5% -8F%B0%E6%8E%A8%E7%90%86%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%E8%AE%BE%E7%BD%AE?sort_id=6458719) to set the envs + + Please follow the [guide](https://gitee.com/ascend/ModelZoo-TensorFlow/wikis/02.%E7%A6%BB%E7%BA%BF%E6%8E%A8%E7%90%86%E6%A1%88%E4%BE%8B/Ascend%E5%B9%B3%E5%8F%B0%E6%8E%A8%E7%90%86%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%E8%AE%BE%E7%BD%AE?sort_id=6458719) to set the envs + - convert pb to om -- Gitee From e1c7c5718af1a51df1e8208e950b105353c9dff4 Mon Sep 17 00:00:00 2001 From: lrving <2415912278@qq.com> Date: Wed, 19 Oct 2022 05:56:38 +0000 Subject: [PATCH 16/17] update ACL_TensorFlow/built-in/cv/YOLOv2_for_ACL/README.md. Signed-off-by: lrving <2415912278@qq.com> --- .../built-in/cv/YOLOv2_for_ACL/README.md | 92 ++++++++----------- 1 file changed, 37 insertions(+), 55 deletions(-) diff --git a/ACL_TensorFlow/built-in/cv/YOLOv2_for_ACL/README.md b/ACL_TensorFlow/built-in/cv/YOLOv2_for_ACL/README.md index a3f4ddad2..02fc84b41 100644 --- a/ACL_TensorFlow/built-in/cv/YOLOv2_for_ACL/README.md +++ b/ACL_TensorFlow/built-in/cv/YOLOv2_for_ACL/README.md @@ -1,106 +1,88 @@ +中文|[English](README_EN.md) -# YOLOv2 Inference for Tensorflow +# YOLOv2 TensorFlow离线推理 -This repository provides a script and recipe to Inference of the YOLOv2 model. +此链接提供OLOv2 TensorFlow模型在NPU上离线推理的脚本和方法 -## Notice -**This sample only provides reference for you to learn the Ascend software stack and is not for commercial purposes.** +## 注意 +**此案例仅为您学习Ascend软件栈提供参考,不用于商业目的。** -Before starting, please pay attention to the following adaptation conditions. If they do not match, may leading in failure. +在开始之前,请注意以下适配条件。如果不匹配,可能导致运行失败。 | Conditions | Need | | --- | --- | -| CANN Version | >=5.0.3 | -| Chip Platform| Ascend310/Ascend310P3 | -| 3rd Party Requirements| Please follow the 'requirements.txt' | +| CANN版本 | >=5.0.3 | +| 芯片平台| Ascend310/Ascend310P3 | +| 第三方依赖| 请参考 'requirements.txt' | -## Quick Start Guide +## 快速指南 -### 1. Clone the respository +### 1. 拷贝代码 ```shell git clone https://gitee.com/ascend/ModelZoo-TensorFlow.git cd Modelzoo-TensorFlow/ACL_TensorFlow/built-in/cv/YOLOv2_for_ACL ``` -### 2. Download and preprocess the dataset +### 2. 下载数据集和预处理 -1. Download the VOC2007 test dataset by yourself, then extract **VOCtest_06-Nov-2007.tar**. +1. 请自行下载ImageNet2012测试数据集 -2. Move VOC2007 test dataset to **'scripts/VOC2007'** like this: -``` -VOC2007 -|----Annotations -|----ImageSets -|----JPEGImages -|----SegmentationClass -|----SegmentationObject -``` - -3. Images Preprocess: -``` -cd scripts -mkdir input_bins -python3 preprocess.py ./VOC2007/JPEGImages/ ./input_bins/ -``` - The pictures will be preprocessed to bin files. - - -4. Convert Groundtruth labels to text format -``` -python3 xml2txt.py ./VOC2007/Annotations/ ./yolov2_postprocess/groundtruths/ -``` +### 3. 离线推理 -### 3. Offline Inference +**离线模型转换** -**Convert pb to om.** +- 环境变量设置 -- configure the env + 请参考[说明](https://gitee.com/ascend/ModelZoo-TensorFlow/wikis/02.%E7%A6%BB%E7%BA%BF%E6%8E%A8%E7%90%86%E6%A1%88%E4%BE%8B/Ascend%E5%B9%B3%E5%8F%B0%E6%8E%A8%E7%90%86%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%E8%AE%BE%E7%BD%AE?sort_id=6458719),设置环境变量 - ``` - export install_path=/usr/local/Ascend - export PATH=/usr/local/python3.7.5/bin:${install_path}/atc/ccec_compiler/bin:${install_path}/atc/bin:$PATH - export PYTHONPATH=${install_path}/atc/python/site-packages:${install_path}/atc/python/site-packages/auto_tune.egg/auto_tune:${install_path}/atc/python/site-packages/schedule_search.egg:$PYTHONPATH - export LD_LIBRARY_PATH=${install_path}/atc/lib64:${install_path}/acllib/lib64:$LD_LIBRARY_PATH - export ASCEND_OPP_PATH=${install_path}/opp - ``` - -- convert pb to om +- Pb模型转换为om模型 - [pb download link](https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/003_Atc_Models/modelzoo/yolov2_tf.pb) + [pb模型下载链接](https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/003_Atc_Models/modelzoo/yolov2_tf.pb) 以batcsize=1为例: + For Ascend310: ``` atc --model=./yolov2.pb --input_shape='Placeholder:1,416,416,3' --input_format=NHWC --output=./yolov2_tf_1batch --soc_version=Ascend310 --framework=3 ``` + For Ascend310P3: + ``` + atc --model=./yolov2.pb --input_shape='Placeholder:1,416,416,3' --input_format=NHWC --output=./yolov2_tf_1batch --soc_version=Ascend310P3 --framework=3 + ``` -- Build the program +- 编译程序 + For Ascend310: + ``` + bash build.sh + ``` + For Ascend310P3: ``` + export ASCEND310P3_DVPP=1 bash build.sh ``` -- Run the program: +- 开始运行: ``` cd scripts bash benchmark_tf.sh ``` -## Performance +## 推理结果 -### Result +### 结果 -Our result was obtained by running the applicable inference script. To achieve the same results, follow the steps in the Quick Start Guide. +本结果是通过运行上面适配的推理脚本获得的。要获得相同的结果,请按照《快速指南》中的步骤操作。 -#### Inference accuracy results +#### 推理精度结果 | model | **data** | mAP | | :---------------: | :-------: | :-------------: | | offline Inference | 4952 images | 59.43% | -## Reference +## 参考 [1] https://github.com/KOD-Chen/YOLOv2-Tensorflow -- Gitee From f5c2267de5bd77fb7e3639361886b0df37407f14 Mon Sep 17 00:00:00 2001 From: lrving <2415912278@qq.com> Date: Wed, 19 Oct 2022 05:58:30 +0000 Subject: [PATCH 17/17] update ACL_TensorFlow/built-in/cv/YOLOv2_for_ACL/README_EN.md. Signed-off-by: lrving <2415912278@qq.com> --- .../built-in/cv/YOLOv2_for_ACL/README_EN.md | 25 ++----------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/ACL_TensorFlow/built-in/cv/YOLOv2_for_ACL/README_EN.md b/ACL_TensorFlow/built-in/cv/YOLOv2_for_ACL/README_EN.md index 8a6824cf4..0abea07d4 100644 --- a/ACL_TensorFlow/built-in/cv/YOLOv2_for_ACL/README_EN.md +++ b/ACL_TensorFlow/built-in/cv/YOLOv2_for_ACL/README_EN.md @@ -26,31 +26,10 @@ cd Modelzoo-TensorFlow/ACL_TensorFlow/built-in/cv/YOLOv2_for_ACL ### 2. Download and preprocess the dataset -1. Download the VOC2007 test dataset by yourself, then extract **VOCtest_06-Nov-2007.tar**. - -2. Move VOC2007 test dataset to **'scripts/VOC2007'** like this: -``` -VOC2007 -|----Annotations -|----ImageSets -|----JPEGImages -|----SegmentationClass -|----SegmentationObject -``` - -3. Images Preprocess: -``` -cd scripts -mkdir input_bins -python3 preprocess.py ./VOC2007/JPEGImages/ ./input_bins/ -``` - The pictures will be preprocessed to bin files. +1. Download the ImageNet2012 dataset by yourself + -4. Convert Groundtruth labels to text format -``` -python3 xml2txt.py ./VOC2007/Annotations/ ./yolov2_postprocess/groundtruths/ -``` ### 3. Offline Inference -- Gitee