diff --git a/ACL_TensorFlow/built-in/cv/Advanced_East_for_ACL/README.md b/ACL_TensorFlow/built-in/cv/Advanced_East_for_ACL/README.md index 48e6bbbd44134e68c2df2efa994d6d782918be85..a9a0d229f442e613da8fa222c91aabb2884f67a8 100644 --- a/ACL_TensorFlow/built-in/cv/Advanced_East_for_ACL/README.md +++ b/ACL_TensorFlow/built-in/cv/Advanced_East_for_ACL/README.md @@ -1,35 +1,37 @@ +中文|[English](README_EN.md) + # Advanced_East_for_ACL -This repository provides a script and recipe to Inference the Advanced_East model. +此存储库提供了推断Advanced_East模型的脚本和方法。 -## 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/Advanced_East_for_ACL ``` -### 2. Download and preprocess the dataset tianchi ICPR MTWI 2018 +### 2. 下载并预处理数据集ICPR MTWI 2018 -1. Download the dataset by yourself +1. 自行下载数据集 ``` tianchi ICPR MTWI 2018 ``` -2. Executing the Preprocessing Script +2. 执行预处理脚本 ``` python3 script/preprocess.py @@ -41,26 +43,22 @@ cd Modelzoo-TensorFlow/ACL_TensorFlow/built-in/cv/Advanced_East_for_ACL ``` -### 3. Offline Inference +### 3. 离线推理 -- 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 h5 to pb +- 环境变量设置 + + 请参考[说明](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模型转换为h5模型 ``` python3 h5_to_pb.py ``` -2. Convert pb to om +2. Pb模型转换为om模型 - [pb download link]() + [pb模型下载链接]() ``` atc --model=model.pb --input_shape="input_img:1,736,736,3" --framework=3 --output=Advanced_East --soc_version=Ascend310 --input_format=NHWC @@ -68,29 +66,29 @@ cd Modelzoo-TensorFlow/ACL_TensorFlow/built-in/cv/Advanced_East_for_ACL ``` -- Build the program +- 编译程序 ``` bash build.sh ``` -- Run the program: +- 开始运行: ``` bash benchmark_tf.sh --batchSize=1 --modelPath=../../model/Advanced_East.om --dataPath=../../datasets/ --modelType=Advanced_East --imgType=rgb ``` -## Performance +## 推理结果 -### Result +### 结果 -Our result were obtained by running the applicable inference script. To achieve the same results, follow the steps in the Quick Start Guide. +本结果是通过运行上面适配的推理脚本获得的。要获得相同的结果,请按照《快速指南》中的步骤操作。 ``` python3 predict.py ``` -#### Inference accuracy results +#### 推理精度结果 | model | **data** | precision | recall | heamn | | :---------------: | :-------: | :-------------: | :-------------: | :-------------: | diff --git a/ACL_TensorFlow/built-in/cv/Advanced_East_for_ACL/README_EN.md b/ACL_TensorFlow/built-in/cv/Advanced_East_for_ACL/README_EN.md new file mode 100644 index 0000000000000000000000000000000000000000..65a45bb10aa8b0a9582b09fc554e70d9914b8f8e --- /dev/null +++ b/ACL_TensorFlow/built-in/cv/Advanced_East_for_ACL/README_EN.md @@ -0,0 +1,94 @@ +English|[中文](README.md) + +# Advanced_East_for_ACL +This repository provides a script and recipe to Inference the Advanced_East 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/Advanced_East_for_ACL +``` + +### 2. Download and preprocess the dataset tianchi ICPR MTWI 2018 + +1. Download the dataset by yourself + ``` + tianchi ICPR MTWI 2018 + + ``` + +2. Executing the Preprocessing Script + + ``` + python3 script/preprocess.py + + ``` + ``` + python3 script/image2bin.py + + ``` + + +### 3. Offline Inference + +- 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 h5 to pb + + ``` + python3 h5_to_pb.py + + ``` +2. Convert pb to om + + [pb download link]() + + ``` + atc --model=model.pb --input_shape="input_img:1,736,736,3" --framework=3 --output=Advanced_East --soc_version=Ascend310 --input_format=NHWC + + ``` + + +- Build the program + + ``` + bash build.sh + ``` + +- Run the program: + + ``` + bash benchmark_tf.sh --batchSize=1 --modelPath=../../model/Advanced_East.om --dataPath=../../datasets/ --modelType=Advanced_East --imgType=rgb + + ``` +## Performance + +### Result + +Our result were obtained by running the applicable inference script. To achieve the same results, follow the steps in the Quick Start Guide. + ``` + python3 predict.py + + ``` + +#### Inference accuracy results + +| model | **data** | precision | recall | heamn | +| :---------------: | :-------: | :-------------: | :-------------: | :-------------: | +| offline Inference | 1000 images | 84.91% | 55.54% | 63.57% | +## diff --git a/ACL_TensorFlow/built-in/cv/SSD-Resnet34_for_ACL/README.md b/ACL_TensorFlow/built-in/cv/SSD-Resnet34_for_ACL/README.md index e8c661baf73c3a83ed7eef7828324d4040eb30aa..1be6517744c462a03fa43a7eccde61eb541d7d07 100644 --- a/ACL_TensorFlow/built-in/cv/SSD-Resnet34_for_ACL/README.md +++ b/ACL_TensorFlow/built-in/cv/SSD-Resnet34_for_ACL/README.md @@ -1,53 +1,46 @@ +中文|[English](README_EN.md) +# SSD Resnet34 TensorFlow离线推理 -# SSD Resnet34 Inference for Tensorflow +此链接提供Vgg16 TensorFlow模型在NPU上离线推理的脚本和方法 -This repository provides a script and recipe to Inference the SSD Resnet34 model. +## 注意 +**此案例仅为您学习Ascend软件栈提供参考,不用于商业目的。** -## 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' | +| 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/SSD-Resnet34_for_ACL ``` -### 2. Download and preprocess the dataset +### 2. 下载数据集和预处理 -1. Download the COCO2017 dataset by yourself +1. 请自行下载COCO2017测试数据集 -### 3. Offline Inference +### 3. 离线推理 -**Convert pb to om.** +**离线模型转换** -- configure the env +- 环境变量设置 - ``` - #Please modify the environment settings as needed - 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/SSD_Resnet34_for_ACL.zip) + [pb模型下载链接](https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/003_Atc_Models/modelzoo/Official/cv/SSD_Resnet34_for_ACL.zip) For Ascend310: ``` @@ -58,7 +51,7 @@ cd Modelzoo-TensorFlow/ACL_TensorFlow/built-in/cv/SSD-Resnet34_for_ACL atc --model=ssdresnet34_1batch_tf.pb --framework=3 --output=ssdresnet34_1batch_tf_aipp --output_type=FP32 --soc_version=Ascend310P3 --input_shape="input:1,300,300,3" --log=info --insert_op_conf=ssdresnet34_tf_aipp.cfg ``` -- Build the program +- 编译程序 For Ascend310: ``` @@ -71,7 +64,7 @@ cd Modelzoo-TensorFlow/ACL_TensorFlow/built-in/cv/SSD-Resnet34_for_ACL bash build.sh ``` -- Run the program: +- 开始运行: ``` cd scripts @@ -80,13 +73,13 @@ cd Modelzoo-TensorFlow/ACL_TensorFlow/built-in/cv/SSD-Resnet34_for_ACL -## Performance +## 推理结果 -### Result +### 结果 -Our result were obtained by running the applicable inference script. To achieve the same results, follow the steps in the Quick Start Guide. +本结果是通过运行上面适配的推理脚本获得的。要获得相同的结果,请按照《快速指南》中的步骤操作。 -#### Inference accuracy results +#### 推理精度结果 | model | SOC | **data** | mAP | | :---------------:|:-------:|:-------: | :-------------: | diff --git a/ACL_TensorFlow/built-in/cv/SSD-Resnet34_for_ACL/README_EN.md b/ACL_TensorFlow/built-in/cv/SSD-Resnet34_for_ACL/README_EN.md new file mode 100644 index 0000000000000000000000000000000000000000..1bf16632172486655129fa6bb1363fcd84297e29 --- /dev/null +++ b/ACL_TensorFlow/built-in/cv/SSD-Resnet34_for_ACL/README_EN.md @@ -0,0 +1,88 @@ +English|[中文](README.md) + +# SSD Resnet34 Inference for Tensorflow + +This repository provides a script and recipe to Inference the SSD Resnet34 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/SSD-Resnet34_for_ACL +``` + +### 2. Download and preprocess the dataset + +1. Download the COCO2017 dataset by yourself + + + +### 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/Official/cv/SSD_Resnet34_for_ACL.zip) + + For Ascend310: + ``` + atc --model=ssdresnet34_1batch_tf.pb --framework=3 --output=ssdresnet34_1batch_tf_aipp --output_type=FP32 --soc_version=Ascend310 --input_shape="input:1,300,300,3" --log=info --insert_op_conf=ssdresnet34_tf_aipp.cfg + ``` + For Ascend310P3: + ``` + atc --model=ssdresnet34_1batch_tf.pb --framework=3 --output=ssdresnet34_1batch_tf_aipp --output_type=FP32 --soc_version=Ascend310P3 --input_shape="input:1,300,300,3" --log=info --insert_op_conf=ssdresnet34_tf_aipp.cfg + ``` + +- Build the program + + For Ascend310: + ``` + unset ASCEND310P3_DVPP + bash build.sh + ``` + For Ascend310P3: + ``` + export ASCEND310P3_DVPP=1 + bash build.sh + ``` + +- Run the program: + + ``` + cd scripts + bash benchmark_tf.sh --batchSize=1 --modelType=ssdresnet34 --imgType=raw --precision=fp16 --outputType=fp32 --useDvpp=1 --deviceId=0 --modelPath=ssdresnet34_1batch_tf_aipp.om --dataPath=COCO2017/val2017 --trueValuePath=instances_val2017.json + ``` + + + +## Performance + +### Result + +Our result were obtained by running the applicable inference script. To achieve the same results, follow the steps in the Quick Start Guide. + +#### Inference accuracy results + +| model | SOC | **data** | mAP | +| :---------------:|:-------:|:-------: | :-------------: | +| offline Inference| Ascend310 | 5K images | 24.6% | +| offline Inference| Ascend310P3 | 5K images | 24.9% | + diff --git a/ACL_TensorFlow/built-in/cv/SSD_Resnet50_FPN_for_ACL/README.md b/ACL_TensorFlow/built-in/cv/SSD_Resnet50_FPN_for_ACL/README.md index e90dc3cc3a2b03a47aa0b959d0dced782983836f..8983eacdca676c4df7f8b55e36838f52389ad492 100644 --- a/ACL_TensorFlow/built-in/cv/SSD_Resnet50_FPN_for_ACL/README.md +++ b/ACL_TensorFlow/built-in/cv/SSD_Resnet50_FPN_for_ACL/README.md @@ -1,82 +1,78 @@ -# SSD-RESNET50FPN inference for Tensorflow +中文|[English](README_EN.md) -This repository provides a script and recipe to Inference the +# SSD-RESNET50FPN TensorFlow离线推理 -## Notice -**This sample only provides reference for you to learn the Ascend software stack and is not for commercial purposes.** +此链接提供Vgg16 TensorFlow模型在NPU上离线推理的脚本和方法 -Before starting, please pay attention to the following adaptation conditions. If they do not match, may leading in failure. +## 注意 +**此案例仅为您学习Ascend软件栈提供参考,不用于商业目的。** + +在开始之前,请注意以下适配条件。如果不匹配,可能导致运行失败。 | 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/SSD_Resnet50_FPN_for_ACL ``` -### 2. Download and preprocess the dataset +### 2. 下载数据集和预处理 -1. Download the coco2014 dataset by yourself +1. 请自行下载coco2014测试数据集。 -2. Executing the Preprocessing Script +2. 执行预处理脚本 ``` python3 scripts/ssd_dataPrepare.py --input_file_path=Path of the image --output_file_path=Binary path for inference --crop_width=Width of the image cropping --crop_height=height of the image cropping --save_conf_path=Image configuration file path ``` -3. Download gt labels +3. 下载gt标签 [instances_minival2014.json](https://obs-9be7.obs.cn-east-2.myhuaweicloud.com:443/010_Offline_Inference/Official/cv/ID1654_ssd_resnet50fpn/scripts/instances_minival2014.json?AccessKeyId=APWPYQJZOXDROK0SPPNG&Expires=1656057065&Signature=ydPmdux71bGzs38Q/xV7USQIdCg%3D) - put json file to **'scripts'** + 将json文件放到 **'scripts'** -### 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/SSD_Resnet50_FPN_for_ACL.zip) + [pb模型下载链接](https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/003_Atc_Models/modelzoo/Official/cv/SSD_Resnet50_FPN_for_ACL.zip) ``` atc --model=model/ssd-resnet50fpn_tf.pb --framework=3 --output=model/ssd_resnet50_fpn --output_type=FP16 --soc_version=Ascend310P3 --input_shape="image_tensor:1,640,640,3" "input_name1:image_tensor" --enable_scope_fusion_passes=ScopeBatchMultiClassNMSPass,ScopeDecodeBboxV2Pass,ScopeNormalizeBBoxPass,ScopeToAbsoluteBBoxPass ``` -- Build the program +- 编译程序 ``` bash build.sh ``` -- Run the program: +- 开始运行: ``` bash benchmark_tf.sh --batchSize=1 --modelPath=../../model/ssd_resnet50_fpn.om --dataPath=../../datasets/ --modelType=ssd_resnet50_fpn --imgType=rgb --trueValuePath=../../scripts/instances_minival2014.json ``` -## Performance +## 推理结果 -### Result +### 结果 -Our result were 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 | | :---------------: | :---------: | :---------: | diff --git a/ACL_TensorFlow/built-in/cv/SSD_Resnet50_FPN_for_ACL/README_EN.md b/ACL_TensorFlow/built-in/cv/SSD_Resnet50_FPN_for_ACL/README_EN.md new file mode 100644 index 0000000000000000000000000000000000000000..606d4191f9add7a7f3580f5b408f0fb9b1370747 --- /dev/null +++ b/ACL_TensorFlow/built-in/cv/SSD_Resnet50_FPN_for_ACL/README_EN.md @@ -0,0 +1,79 @@ +English|[中文](README.md) +# SSD-RESNET50FPN inference for Tensorflow + +This repository provides a script and recipe to Inference the + +## 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/SSD_Resnet50_FPN_for_ACL +``` + +### 2. Download and preprocess the dataset + +1. Download the coco2014 dataset by yourself + +2. Executing the Preprocessing Script + ``` + python3 scripts/ssd_dataPrepare.py --input_file_path=Path of the image --output_file_path=Binary path for inference --crop_width=Width of the image cropping --crop_height=height of the image cropping --save_conf_path=Image configuration file path + + ``` +3. Download gt labels + [instances_minival2014.json](https://obs-9be7.obs.cn-east-2.myhuaweicloud.com:443/010_Offline_Inference/Official/cv/ID1654_ssd_resnet50fpn/scripts/instances_minival2014.json?AccessKeyId=APWPYQJZOXDROK0SPPNG&Expires=1656057065&Signature=ydPmdux71bGzs38Q/xV7USQIdCg%3D) + + put json file to **'scripts'** + +### 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/Official/cv/SSD_Resnet50_FPN_for_ACL.zip) + + ``` + atc --model=model/ssd-resnet50fpn_tf.pb --framework=3 --output=model/ssd_resnet50_fpn --output_type=FP16 --soc_version=Ascend310P3 --input_shape="image_tensor:1,640,640,3" "input_name1:image_tensor" --enable_scope_fusion_passes=ScopeBatchMultiClassNMSPass,ScopeDecodeBboxV2Pass,ScopeNormalizeBBoxPass,ScopeToAbsoluteBBoxPass + ``` + +- Build the program + + ``` + bash build.sh + ``` + +- Run the program: + + ``` + bash benchmark_tf.sh --batchSize=1 --modelPath=../../model/ssd_resnet50_fpn.om --dataPath=../../datasets/ --modelType=ssd_resnet50_fpn --imgType=rgb --trueValuePath=../../scripts/instances_minival2014.json + ``` + +## Performance + +### Result + +Our result were 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 | 37.8% | + diff --git a/ACL_TensorFlow/built-in/cv/ShuffleNetv1_for_ACL/README.md b/ACL_TensorFlow/built-in/cv/ShuffleNetv1_for_ACL/README.md index fd7bdbbbc651997c4372161981cf162cb1d2f9ce..de3c484bb97ee50e6a1990d62d188acb2647df7e 100644 --- a/ACL_TensorFlow/built-in/cv/ShuffleNetv1_for_ACL/README.md +++ b/ACL_TensorFlow/built-in/cv/ShuffleNetv1_for_ACL/README.md @@ -1,34 +1,34 @@ +中文|[English](README_EN.md) +# ShuffleNetv1 TensorFlow离线推理 -# ShuffleNetv1 Inference for Tensorflow +此链接提供ShuffleNetv1 TensorFlow模型在NPU上离线推理的脚本和方法 -This repository provides a script and recipe to Inference of the ShuffleNetv1 model. +## 注意 +**此案例仅为您学习Ascend软件栈提供参考,不用于商业目的。** -## 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' | +| 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/ShuffleNetv1_for_ACL ``` -### 2. Download and preprocess the dataset +### 2. 下载数据集和预处理 -1. Download the ImageNet2012 Validation dataset by yourself which includes 50000 JPEGS. +1. 请自行下载ImageNet2012测试数据集 -2. Move **ILSVRC2012val** to **'scripts/'** +2. 移动 **ILSVRC2012val** 到 **'scripts/'** ``` ———scripts |————ILSVRC2012val @@ -39,64 +39,57 @@ cd Modelzoo-TensorFlow/ACL_TensorFlow/built-in/cv/ShuffleNetv1_for_ACL |————... ``` -3. Images Preprocess: +3. 图像预处理: ``` cd scripts mkdir input_bins python3 imagenet_preprocessing.py --src_path ./ILSVRC2012val/ ``` -The jpeg pictures will be preprocessed to bin fils. - -### 3. Offline Inference +jpeg图片将被预处理为bin-fils。 +### 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模型 - Download pb model of shufflenetv1 which was trained by this repo: [Repo of train](https://gitee.com/ascend/ModelZoo-TensorFlow/tree/master/TensorFlow/contrib/cv/shufflenetv1/ShuffleNet_ID0184_for_TensorFlow) + 下载本报告训练的shuffenetv1的pb模型: [Repo of train](https://gitee.com/ascend/ModelZoo-TensorFlow/tree/master/TensorFlow/contrib/cv/shufflenetv1/ShuffleNet_ID0184_for_TensorFlow) - [Pb Download Link](https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/003_Atc_Models/modelzoo/Official/cv/ShuffleNetv1_for_ACL.zip) + [pb模型下载链接](https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/003_Atc_Models/modelzoo/Official/cv/ShuffleNetv1_for_ACL.zip) - Because of batchsize was fixed to **96** by the trained checkpoint, atc input shape need to set **"input:96,224,224,3"** + 由于经过训练的检查点将批量大小固定为**96**,因此atc输入形状需要设置**“输入:96224224.3”** ``` atc --model=shufflenetv1.pb --framework=3 --output=shufflenetv1_tf_96batch --output_type=FP32 --soc_version=Ascend310 --input_shape="input:96,224,224,3" --out_nodes="classifier/BiasAdd:0" --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 | 59.9 %/ 83.4% | -## Reference +## 参考 https://gitee.com/ascend/ModelZoo-TensorFlow/tree/master/TensorFlow/contrib/cv/shufflenetv1/ShuffleNet_ID0184_for_TensorFlow diff --git a/ACL_TensorFlow/built-in/cv/ShuffleNetv1_for_ACL/README_EN.md b/ACL_TensorFlow/built-in/cv/ShuffleNetv1_for_ACL/README_EN.md new file mode 100644 index 0000000000000000000000000000000000000000..5f0702cf5740ab81a26c90893c696b9aa7c9cea6 --- /dev/null +++ b/ACL_TensorFlow/built-in/cv/ShuffleNetv1_for_ACL/README_EN.md @@ -0,0 +1,96 @@ +English|[中文](README.md) + +# ShuffleNetv1 Inference for Tensorflow + +This repository provides a script and recipe to Inference of the ShuffleNetv1 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/ShuffleNetv1_for_ACL +``` + +### 2. Download and preprocess the dataset + +1. Download the ImageNet2012 Validation dataset by yourself which includes 50000 JPEGS. + +2. Move **ILSVRC2012val** to **'scripts/'** +``` +———scripts + |————ILSVRC2012val + |————ILSVRC2012_val_00000001.JPEG + |————ILSVRC2012_val_00000002.JPEG + |————ILSVRC2012_val_00000003.JPEG + |————ILSVRC2012_val_00000004.JPEG + |————... +``` + +3. Images Preprocess: +``` +cd scripts +mkdir input_bins +python3 imagenet_preprocessing.py --src_path ./ILSVRC2012val/ +``` +The jpeg pictures will be preprocessed to bin fils. + +### 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 + + Download pb model of shufflenetv1 which was trained by this repo: [Repo of train](https://gitee.com/ascend/ModelZoo-TensorFlow/tree/master/TensorFlow/contrib/cv/shufflenetv1/ShuffleNet_ID0184_for_TensorFlow) + + [Pb Download Link](https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/003_Atc_Models/modelzoo/Official/cv/ShuffleNetv1_for_ACL.zip) + + Because of batchsize was fixed to **96** by the trained checkpoint, atc input shape need to set **"input:96,224,224,3"** + ``` + atc --model=shufflenetv1.pb --framework=3 --output=shufflenetv1_tf_96batch --output_type=FP32 --soc_version=Ascend310 --input_shape="input:96,224,224,3" --out_nodes="classifier/BiasAdd:0" --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 | 59.9 %/ 83.4% | + + +## Reference +https://gitee.com/ascend/ModelZoo-TensorFlow/tree/master/TensorFlow/contrib/cv/shufflenetv1/ShuffleNet_ID0184_for_TensorFlow diff --git a/ACL_TensorFlow/built-in/cv/ShuffleNetv2_for_ACL/README.md b/ACL_TensorFlow/built-in/cv/ShuffleNetv2_for_ACL/README.md index d38b1df46fb83c49a900a9c060010a339a27d17c..0ce537bc1727fcb095b1a84501928dcf0f407ced 100644 --- a/ACL_TensorFlow/built-in/cv/ShuffleNetv2_for_ACL/README.md +++ b/ACL_TensorFlow/built-in/cv/ShuffleNetv2_for_ACL/README.md @@ -1,34 +1,34 @@ +中文|[English](README_EN.md) +# ShuffleNetv2 TensorFlow离线推理 -# ShuffleNetv2 Inference for Tensorflow +此链接提供ShuffleNetv2 TensorFlow模型在NPU上离线推理的脚本和方法 -This repository provides a script and recipe to Inference of the ShuffleNetv2 model. +## 注意 +**此案例仅为您学习Ascend软件栈提供参考,不用于商业目的。** -## 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' | +| 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/ShuffleNetv2_for_ACL ``` -### 2. Download and preprocess the dataset +### 2. 下载数据集和预处理 -1. Download the ImageNet2012 Validation dataset by yourself which includes 50000 JPEGS. +1. 请自行下载ImageNet2012测试数据集,其中包括50000 JPEGS。 -2. Move **ILSVRC2012val** to **'scripts/'** +2. 移动 **ILSVRC2012val** 到 **'scripts/'** ``` ———scripts |————ILSVRC2012val @@ -39,63 +39,58 @@ cd Modelzoo-TensorFlow/ACL_TensorFlow/built-in/cv/ShuffleNetv2_for_ACL |————... ``` -3. Images Preprocess: +3. 图像预处理: ``` cd scripts mkdir input_bins python3 imagenet_preprocessing.py --src_path ./ILSVRC2012val/ ``` -The jpeg pictures will be preprocessed to bin fils. +jpeg图片将被预处理为bin fils. -### 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模型 - Download pb model of shufflenetv2 which was trained by this repo: [Repo of train](https://gitee.com/ascend/ModelZoo-TensorFlow/tree/master/TensorFlow/contrib/cv/shufflenetv2/shufflenetv2_ID0185_for_TensorFlow/Offline_shufflenetv2_tf_uestclzx) - [Pb Download Link](https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/003_Atc_Models/modelzoo/Official/cv/ShuffleNetv2_for_ACL.zip) + 下载本报告训练的shuffenetv2的pb模型: [Repo of train](https://gitee.com/ascend/ModelZoo-TensorFlow/tree/master/TensorFlow/contrib/cv/shufflenetv2/shufflenetv2_ID0185_for_TensorFlow/Offline_shufflenetv2_tf_uestclzx) + [pb模型下载链接](https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/003_Atc_Models/modelzoo/Official/cv/ShuffleNetv2_for_ACL.zip) ``` atc --model=shufflenetv2.pb --framework=3 --output=shufflenetv2_tf_1batch --output_type=FP32 --soc_version=Ascend310 --input_shape="input:1,224,224,3" --out_nodes="classifier/BiasAdd:0" --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 | 61.4 %/ 82.9% | -## Reference +## 参考 https://gitee.com/ascend/ModelZoo-TensorFlow/tree/master/TensorFlow/contrib/cv/shufflenetv2/shufflenetv2_ID0185_for_TensorFlow diff --git a/ACL_TensorFlow/built-in/cv/ShuffleNetv2_for_ACL/README_EN.md b/ACL_TensorFlow/built-in/cv/ShuffleNetv2_for_ACL/README_EN.md new file mode 100644 index 0000000000000000000000000000000000000000..7eed2461fd13c53140612239cf3112a9f85cd04f --- /dev/null +++ b/ACL_TensorFlow/built-in/cv/ShuffleNetv2_for_ACL/README_EN.md @@ -0,0 +1,95 @@ +English|[中文](README.md) + +# ShuffleNetv2 Inference for Tensorflow + +This repository provides a script and recipe to Inference of the ShuffleNetv2 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/ShuffleNetv2_for_ACL +``` + +### 2. Download and preprocess the dataset + +1. Download the ImageNet2012 Validation dataset by yourself which includes 50000 JPEGS. + +2. Move **ILSVRC2012val** to **'scripts/'** +``` +———scripts + |————ILSVRC2012val + |————ILSVRC2012_val_00000001.JPEG + |————ILSVRC2012_val_00000002.JPEG + |————ILSVRC2012_val_00000003.JPEG + |————ILSVRC2012_val_00000004.JPEG + |————... +``` + +3. Images Preprocess: +``` +cd scripts +mkdir input_bins +python3 imagenet_preprocessing.py --src_path ./ILSVRC2012val/ +``` +The jpeg pictures will be preprocessed to bin fils. + +### 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 + + Download pb model of shufflenetv2 which was trained by this repo: [Repo of train](https://gitee.com/ascend/ModelZoo-TensorFlow/tree/master/TensorFlow/contrib/cv/shufflenetv2/shufflenetv2_ID0185_for_TensorFlow/Offline_shufflenetv2_tf_uestclzx) + [Pb Download Link](https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/003_Atc_Models/modelzoo/Official/cv/ShuffleNetv2_for_ACL.zip) + + ``` + atc --model=shufflenetv2.pb --framework=3 --output=shufflenetv2_tf_1batch --output_type=FP32 --soc_version=Ascend310 --input_shape="input:1,224,224,3" --out_nodes="classifier/BiasAdd:0" --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 | 61.4 %/ 82.9% | + + +## Reference +https://gitee.com/ascend/ModelZoo-TensorFlow/tree/master/TensorFlow/contrib/cv/shufflenetv2/shufflenetv2_ID0185_for_TensorFlow + diff --git a/ACL_TensorFlow/contrib/audio/TDNN_for_ACL/README.md b/ACL_TensorFlow/contrib/audio/TDNN_for_ACL/README.md index 198c616dc7a4a74852b3d965ad6ede7f441f8a5b..3872f0aac4466181a4194e4b1fb83b0bea5454b0 100644 --- a/ACL_TensorFlow/contrib/audio/TDNN_for_ACL/README.md +++ b/ACL_TensorFlow/contrib/audio/TDNN_for_ACL/README.md @@ -1,83 +1,75 @@ +中文|[English](README_EN.md) +# TDNN TensorFlow离线推理 -# TDNN Inference for Tensorflow +此链接提供Vgg16 TensorFlow模型在NPU上离线推理的脚本和方法。 -This repository provides a script and recipe to Inference of the TDNN model. +## 注意 +**此案例仅为您学习Ascend软件栈提供参考,不用于商业目的。** -## 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' | +| 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/contrib/audio/TDNN_for_ACL ``` -### 2. Generate random test dataset - -1. Because of this is not a well trained model we test the model with random test dataset - -2. Generate random test dataset: +### 2. 生成随机测试数据集 +1. 由于这不是一个经过良好训练的模型,我们使用随机测试数据集测试模型 +2. 生成随机测试数据集: ``` cd scripts mkdir input_bins python3 generate_random_data.py --path=./input_bins/ --nums=32 ``` -There will random testdata bin fils under *input_bins/*. +将有随机的测试数据的bin文件生成在 *input_bins/*下面. -### 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/Research/audio/TDNN_for_ACL.zip) + [**pb模型下载链接**](https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/003_Atc_Models/modelzoo/Research/audio/TDNN_for_ACL.zip) ``` atc --model=tdnn_tf.pb --framework=3 --output=tdnn_tf_1batch --output_type=FP32 --soc_version=Ascend310 --input_shape="input:1,1000,40" --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** | Mean CosineSimilarity | | :---------------: | :-------: | :-------------: | diff --git a/ACL_TensorFlow/contrib/audio/TDNN_for_ACL/README_EN.md b/ACL_TensorFlow/contrib/audio/TDNN_for_ACL/README_EN.md new file mode 100644 index 0000000000000000000000000000000000000000..e5f249c7ac99c7a40d040c92da4887872bba1edc --- /dev/null +++ b/ACL_TensorFlow/contrib/audio/TDNN_for_ACL/README_EN.md @@ -0,0 +1,79 @@ +English|[中文](README.md) + +# TDNN Inference for Tensorflow + +This repository provides a script and recipe to Inference of the TDNN 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/contrib/audio/TDNN_for_ACL +``` + +### 2. Generate random test dataset + +1. Because of this is not a well trained model we test the model with random test dataset + +2. Generate random test dataset: +``` +cd scripts +mkdir input_bins +python3 generate_random_data.py --path=./input_bins/ --nums=32 +``` +There will random testdata bin fils under *input_bins/*. + +### 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/Research/audio/TDNN_for_ACL.zip) + + ``` + atc --model=tdnn_tf.pb --framework=3 --output=tdnn_tf_1batch --output_type=FP32 --soc_version=Ascend310 --input_shape="input:1,1000,40" --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** | Mean CosineSimilarity | +| :---------------: | :-------: | :-------------: | +| offline Inference | random data | 100.0% | + diff --git a/ACL_TensorFlow/contrib/cv/SSD_InceptionV2_for_ACL/README.md b/ACL_TensorFlow/contrib/cv/SSD_InceptionV2_for_ACL/README.md index db320352ee19389d2468ad295eb3800d783183f4..ad52c7faef0b73e09ad70392fac70d98f248e6ed 100644 --- a/ACL_TensorFlow/contrib/cv/SSD_InceptionV2_for_ACL/README.md +++ b/ACL_TensorFlow/contrib/cv/SSD_InceptionV2_for_ACL/README.md @@ -1,90 +1,85 @@ -# SSD_InceptionV2 Inference for Tensorflow +中文|[English](README_EN.md) +# SSD_InceptionV2 TensorFlow离线推理 -This repository provides a script and recipe to Inference of SSD_InceptionV2 model. +此链接提供SSD_InceptionV2 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/contrib/cv/SSD_InceptionV2_for_ACL ``` -### 2. Download and preprocess the dataset +### 2. 下载数据集和预处理 -1. Download the coco2014 test dataset by yourself +1. 请自行下载coco2014测试数据集。 -2. Executing the Preprocessing Script +2. 执行预处理脚本 ``` cd scripts mkdir input_bins python3 scripts/ssd_dataPrepare.py --input_file_path=Path of the image --output_file_path=./input_bins --crop_width=640 --crop_height=640 --save_conf_path=./img_info ``` -3. Download gt labels +3. 下载gt标签 [instances_minival2014.json](https://obs-9be7.obs.cn-east-2.myhuaweicloud.com:443/010_Offline_Inference/Official/cv/ID1654_ssd_resnet50fpn/scripts/instances_minival2014.json?AccessKeyId=APWPYQJZOXDROK0SPPNG&Expires=1656057065&Signature=ydPmdux71bGzs38Q/xV7USQIdCg%3D) - put json file to **'scripts'** + 将json文件放到**'scripts'** -### 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/Research/cv/SSD_for_ACL/ssd_inceptionv2_tf.pb) + [pb模型下载链接](https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/003_Atc_Models/modelzoo/Research/cv/SSD_for_ACL/ssd_inceptionv2_tf.pb) ``` atc --model=model/ssd_inceptionv2_tf.pb --framework=3 --output=model/ssd_inceptionv2 --output_type=FP16 --soc_version=Ascend310P3 --input_shape="image_tensor:1,640,640,3" --out_nodes="detection_boxes:0;detection_scores:0;num_detections:0;detection_classes:0" ``` -- Build the program +- 编译程序 ``` bash build.sh ``` -- Run the program: +- 开始运行: ``` bash benchmark.sh ``` -## Performance +## 推理结果 -### Result +### 结果 -Our result were 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 | 27.8% | -## Reference +## 参考 [1] https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf1_detection_zoo.md diff --git a/ACL_TensorFlow/contrib/cv/SSD_InceptionV2_for_ACL/README_EN.md b/ACL_TensorFlow/contrib/cv/SSD_InceptionV2_for_ACL/README_EN.md new file mode 100644 index 0000000000000000000000000000000000000000..ed10d686108314e4c429f6998f9a5ec6c76c7da0 --- /dev/null +++ b/ACL_TensorFlow/contrib/cv/SSD_InceptionV2_for_ACL/README_EN.md @@ -0,0 +1,85 @@ +English|[中文](README.md) +# SSD_InceptionV2 Inference for Tensorflow + +This repository provides a script and recipe to Inference of SSD_InceptionV2 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/contrib/cv/SSD_InceptionV2_for_ACL +``` + +### 2. Download and preprocess the dataset + +1. Download the coco2014 test dataset by yourself + +2. Executing the Preprocessing Script + ``` + cd scripts + mkdir input_bins + python3 scripts/ssd_dataPrepare.py --input_file_path=Path of the image --output_file_path=./input_bins --crop_width=640 --crop_height=640 --save_conf_path=./img_info + + ``` +3. Download gt labels + [instances_minival2014.json](https://obs-9be7.obs.cn-east-2.myhuaweicloud.com:443/010_Offline_Inference/Official/cv/ID1654_ssd_resnet50fpn/scripts/instances_minival2014.json?AccessKeyId=APWPYQJZOXDROK0SPPNG&Expires=1656057065&Signature=ydPmdux71bGzs38Q/xV7USQIdCg%3D) + + put json file to **'scripts'** + +### 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/Research/cv/SSD_for_ACL/ssd_inceptionv2_tf.pb) + + ``` + atc --model=model/ssd_inceptionv2_tf.pb --framework=3 --output=model/ssd_inceptionv2 --output_type=FP16 --soc_version=Ascend310P3 --input_shape="image_tensor:1,640,640,3" --out_nodes="detection_boxes:0;detection_scores:0;num_detections:0;detection_classes:0" + ``` + +- Build the program + + ``` + bash build.sh + ``` + +- Run the program: + + ``` + bash benchmark.sh + ``` + +## Performance + +### Result + +Our result were 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 | 27.8% | + +## Reference + +[1] https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf1_detection_zoo.md + diff --git a/ACL_TensorFlow/contrib/cv/SSD_MobileNetV1_FPN_for_ACL/README.md b/ACL_TensorFlow/contrib/cv/SSD_MobileNetV1_FPN_for_ACL/README.md index 8bd5b8457737bf317b71000ab47d1bdac082e0f6..b5c767074194eff3805c887bd139a9ad5c3748d5 100644 --- a/ACL_TensorFlow/contrib/cv/SSD_MobileNetV1_FPN_for_ACL/README.md +++ b/ACL_TensorFlow/contrib/cv/SSD_MobileNetV1_FPN_for_ACL/README.md @@ -1,90 +1,85 @@ -# SSD_MobileNetV1_FPN Inference for Tensorflow +中文|[English](README_EN.md) -This repository provides a script and recipe to Inference of SSD_MobileNetV1_FPN model. +# SSD_MobileNetV1_FPN TensorFlow离线推理 -## Notice -**This sample only provides reference for you to learn the Ascend software stack and is not for commercial purposes.** +此链接提供Vgg16 TensorFlow模型在NPU上离线推理的脚本和方法。 -Before starting, please pay attention to the following adaptation conditions. If they do not match, may leading in failure. +## 注意 +**此案例仅为您学习Ascend软件栈提供参考,不用于商业目的。** + +在开始之前,请注意以下适配条件。如果不匹配,可能导致运行失败。 | 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/contrib/cv/SSD_MobileNetV1_FPN_for_ACL ``` -### 2. Download and preprocess the dataset - -1. Download the coco2014 test dataset by yourself +### 2. 下载数据集和预处理 -2. Executing the Preprocessing Script +1. 请自行下载coco2014测试数据集。 +2. 执行预处理脚本 ``` cd scripts mkdir input_bins python3 scripts/ssd_dataPrepare.py --input_file_path=Path of the image --output_file_path=./input_bins --crop_width=640 --crop_height=640 --save_conf_path=./img_info ``` -3. Download gt labels +3. 下载gt标签 [instances_minival2014.json](https://obs-9be7.obs.cn-east-2.myhuaweicloud.com:443/010_Offline_Inference/Official/cv/ID1654_ssd_resnet50fpn/scripts/instances_minival2014.json?AccessKeyId=APWPYQJZOXDROK0SPPNG&Expires=1656057065&Signature=ydPmdux71bGzs38Q/xV7USQIdCg%3D) - put json file to **'scripts'** + 将json文件放到 **'scripts'** -### 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/Research/cv/SSD_for_ACL/ssd_mobilenetv1_fpn_tf.pb) + [pb模型下载链接](https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/003_Atc_Models/modelzoo/Research/cv/SSD_for_ACL/ssd_mobilenetv1_fpn_tf.pb) ``` atc --model=model/ssd_mobilenetv1_fpn_tf.pb --framework=3 --output=model/ssd_mobilenetv1_fpn --output_type=FP16 --soc_version=Ascend310P3 --input_shape="image_tensor:1,640,640,3" --out_nodes="detection_boxes:0;detection_scores:0;num_detections:0;detection_classes:0" ``` -- Build the program +- 编译程序 ``` bash build.sh ``` -- Run the program: +- 开始运行: ``` bash benchmark.sh ``` -## Performance +## 推理结果 -### Result +### 结果 -Our result were 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 | 34.8% | -## Reference +## 参考 [1] https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf1_detection_zoo.md diff --git a/ACL_TensorFlow/contrib/cv/SSD_MobileNetV1_FPN_for_ACL/README_EN.md b/ACL_TensorFlow/contrib/cv/SSD_MobileNetV1_FPN_for_ACL/README_EN.md new file mode 100644 index 0000000000000000000000000000000000000000..c05e377edb11763fd6d48ec2459cf913508f9b8a --- /dev/null +++ b/ACL_TensorFlow/contrib/cv/SSD_MobileNetV1_FPN_for_ACL/README_EN.md @@ -0,0 +1,85 @@ +English|[中文](README.md) +# SSD_MobileNetV1_FPN Inference for Tensorflow + +This repository provides a script and recipe to Inference of SSD_MobileNetV1_FPN 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/contrib/cv/SSD_MobileNetV1_FPN_for_ACL +``` + +### 2. Download and preprocess the dataset + +1. Download the coco2014 test dataset by yourself + +2. Executing the Preprocessing Script + ``` + cd scripts + mkdir input_bins + python3 scripts/ssd_dataPrepare.py --input_file_path=Path of the image --output_file_path=./input_bins --crop_width=640 --crop_height=640 --save_conf_path=./img_info + + ``` +3. Download gt labels + [instances_minival2014.json](https://obs-9be7.obs.cn-east-2.myhuaweicloud.com:443/010_Offline_Inference/Official/cv/ID1654_ssd_resnet50fpn/scripts/instances_minival2014.json?AccessKeyId=APWPYQJZOXDROK0SPPNG&Expires=1656057065&Signature=ydPmdux71bGzs38Q/xV7USQIdCg%3D) + + put json file to **'scripts'** + +### 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/Research/cv/SSD_for_ACL/ssd_mobilenetv1_fpn_tf.pb) + + ``` + atc --model=model/ssd_mobilenetv1_fpn_tf.pb --framework=3 --output=model/ssd_mobilenetv1_fpn --output_type=FP16 --soc_version=Ascend310P3 --input_shape="image_tensor:1,640,640,3" --out_nodes="detection_boxes:0;detection_scores:0;num_detections:0;detection_classes:0" + ``` + +- Build the program + + ``` + bash build.sh + ``` + +- Run the program: + + ``` + bash benchmark.sh + ``` + +## Performance + +### Result + +Our result were 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 | 34.8% | + +## Reference + +[1] https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf1_detection_zoo.md + diff --git a/ACL_TensorFlow/contrib/cv/SegdecNet_for_ACL/README.md b/ACL_TensorFlow/contrib/cv/SegdecNet_for_ACL/README.md index 184eb0f7ab2ff1ca29ab392b42bac39b6ade164f..7ceecdb65a47a4d6ca33a94ce0fe46151853ce0b 100644 --- a/ACL_TensorFlow/contrib/cv/SegdecNet_for_ACL/README.md +++ b/ACL_TensorFlow/contrib/cv/SegdecNet_for_ACL/README.md @@ -1,67 +1,62 @@ +中文|[English](README_EN.md) +# SegdecNet TensorFlow离线推理 -# SegdecNet Inference for Tensorflow +此链接提供SegdecNet TensorFlow模型在NPU上离线推理的脚本和方法 -This repository provides a script and recipe to Inference of the SegdecNet model. +## 注意 +**此案例仅为您学习Ascend软件栈提供参考,不用于商业目的。** -## 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' | +| 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/contrib/cv/SegdecNet_for_ACL ``` -### 2. Download and preprocess the dataset +### 2. 下载数据集和预处理 -1. Download the KolektorSDD Validation dataset by yourself. +1. 自行下载KolektorSDD验证数据集。 -2. You should split the dataset into three folds to perform 3-fold cross validation.[split](./scripts/db/README.md) +2. 你应该将数据集分成三个部分来执行三个部分的交叉验证。[split](./scripts/db/README.md) -3. Images Preprocess: +3. 图像预处理: ``` cd scripts bash run_preprocess.sh ``` -The images bin files is stored in output/images/ -The labels bin files is stored in output/labels/ +图像bin文件存储在 output/images/ +标签bin文件存储在 output/labels/ -### 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/Research/cv/SEGDEC-NET_for_ACL.zip) + [**pb模型下载链接**](https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/003_Atc_Models/modelzoo/Research/cv/SEGDEC-NET_for_ACL.zip) ``` atc --model=./output/SEGDEC-NET_tf.pb --framework=3 --output=./output/SEGDEC-NET_tf --output_type=FP32 --soc_version=Ascend310 --input_shape="images:1,1408,512,1" --log=info ``` -- Build the program +- 编译程序 ``` cd ../ @@ -75,24 +70,24 @@ The labels bin files is stored in output/labels/ bash benchmark_tf.sh ``` -- Postprocess: +- 开始运行: ``` bash run_postprocess.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 | AP of CPU | AP of NPU | | :---------------: | :-------: | :-------: | | SegdecNet | 0.9536 | 0.9528 | -## Reference +## 参考 [1] https://github.com/skokec/segdec-net-jim2019 diff --git a/ACL_TensorFlow/contrib/cv/SegdecNet_for_ACL/README_EN.md b/ACL_TensorFlow/contrib/cv/SegdecNet_for_ACL/README_EN.md new file mode 100644 index 0000000000000000000000000000000000000000..6fc159103adfd40e5759f38daab5e95d1c94c3aa --- /dev/null +++ b/ACL_TensorFlow/contrib/cv/SegdecNet_for_ACL/README_EN.md @@ -0,0 +1,92 @@ +English|[中文](README.md) + +# SegdecNet Inference for Tensorflow + +This repository provides a script and recipe to Inference of the SegdecNet 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/contrib/cv/SegdecNet_for_ACL +``` + +### 2. Download and preprocess the dataset + +1. Download the KolektorSDD Validation dataset by yourself. + +2. You should split the dataset into three folds to perform 3-fold cross validation.[split](./scripts/db/README.md) + +3. Images Preprocess: +``` +cd scripts +bash run_preprocess.sh +``` +The images bin files is stored in output/images/ +The labels bin files is stored in output/labels/ + + +### 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/Research/cv/SEGDEC-NET_for_ACL.zip) + + ``` + atc --model=./output/SEGDEC-NET_tf.pb --framework=3 --output=./output/SEGDEC-NET_tf --output_type=FP32 --soc_version=Ascend310 --input_shape="images:1,1408,512,1" --log=info + ``` + +- Build the program + + ``` + cd ../ + bash build.sh + ``` + +- Run the program: + + ``` + cd scripts + bash benchmark_tf.sh + ``` + +- Postprocess: + + ``` + bash run_postprocess.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 | AP of CPU | AP of NPU | +| :---------------: | :-------: | :-------: | +| SegdecNet | 0.9536 | 0.9528 | + + +## Reference +[1] https://github.com/skokec/segdec-net-jim2019 diff --git a/ACL_TensorFlow/contrib/cv/TransNet_for_ACL/README_EN.md b/ACL_TensorFlow/contrib/cv/TransNet_for_ACL/README_EN.md new file mode 100644 index 0000000000000000000000000000000000000000..532b121bd5771e34f140675252bc14f7e98808bf --- /dev/null +++ b/ACL_TensorFlow/contrib/cv/TransNet_for_ACL/README_EN.md @@ -0,0 +1,96 @@ +English|[中文](README.md) + +# TransNet Inference for Tensorflow + +This repository provides a script and recipe to Inference of the TransNet model for fast detection of common shot transitions. + +## 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/contrib/cv/TransNet_for_ACL +``` + +### 2. Setup Environment + +```shell +apt install ffmpeg +pip3 install -r requirements.txt +``` + +### 3. Download demo video + +1. Download a demo video of **'BigBuckBunny.mp4'** [Download Link](https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/Dataset/BigBuckBunny.mp4) + +2. Move video file to **'scripts'** and convert it to bin files: +``` +cd scripts +mkdir input_bins +python3 video_pre_postprocess.py --video_path BigBuckBunny.mp4 --output_path input_bins --mode preprocess +``` +The video file will be converted to bin fils under **input_bins/**. + +### 4. 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/Research/cv/TransNet_for_ACL.zip) + + ``` + atc --model=transnet_tf.pb --framework=3 --output=transnet_tf_1batch --output_type=FP32 --soc_version=Ascend310 --input_shape="TransNet/inputs:1,100,27,48,3" --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 results + +Shot transitions frame id of demo video: +``` +[1 37] +[41 284] +[285 377] +[378 552] +[553 1144] +[1145 1345] +[1346 1441] +``` + +## Reference +[1] https://github.com/soCzech/TransNet diff --git a/ACL_TensorFlow/contrib/nlp/RoBERTa_for_ACL/README.md b/ACL_TensorFlow/contrib/nlp/RoBERTa_for_ACL/README.md index c26215e711b3034494a7b625b087416a90660e80..c79d4afb287aa53f6cbd06a6e30067c82a2274f8 100644 --- a/ACL_TensorFlow/contrib/nlp/RoBERTa_for_ACL/README.md +++ b/ACL_TensorFlow/contrib/nlp/RoBERTa_for_ACL/README.md @@ -1,71 +1,66 @@ +中文|[English](README_EN.md) # -# RoBERTa DownStream Inference for TensorFlow +# RoBERTa TensorFlow离线推理 *** -This repository provides a script and recipe to Inference the RoBERTa DownStream Inference +此链接提供RoBERTa TensorFlow模型在NPU上离线推理的脚本和方法 -* [x] RoBERTa DownStream Inference, based on [RoBERTa](https://github.com/brightmart/roberta_zh) +* [x] RoBERTa 离线推理的连接 [RoBERTa](https://github.com/brightmart/roberta_zh) *** -## 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.git cd Modelzoo-TensorFlow/ACL_TensorFlow/contrib/nlp/RoBERTa_for_ACL ``` -### 2. Download and preprocess the dataset +### 2. 下载数据集和预处理 -Download the dataset by yourself, more details see: [data](./data) -Download the vocab.txt and bert_config.json by yourself, more details see: [config](./config/README.md) +请自行下载数据, 更多详细信息请参见: [data](./data) +请自行下载vocab.txt 和 bert_config.json 文件, 更多详细信息请参见: [config](./config/README.md) -### 3. Obtain the fine-tuned checkpoint files or pb model +### 3. 获取微调的检查点文件或pb模型 -Obtain the fine-tuned checkpoint files or pb model, more details see: [ckpt](./save/ckpt/README.md) or [models](./save/model/README.md) +获取微调的检查点文件或pb模型, 更多详细信息请参见: [ckpt](./save/ckpt/README.md) or [models](./save/model/README.md) -### 4. Build the program -Build the inference application, more details see: [xacl_fmk](./xacl_fmk/README.md) -Put xacl to the current dictory. +### 4. 编译程序 +编译推理应用程序, 更多详细信息请参见: [xacl_fmk](./xacl_fmk/README.md) +将xacl放在当前字典中 -### 5. Offline Inference +### 5. 离线推理 **RoBERTa** *** -* RoBERTa use roberta for model_name parameter, each downstream task name for task_name -* RoBERTa support lcqmc task -* Change the parameters for different tasks -* Only RoBERTa Base has been tested +* RoBERTa将roberta用作model_name参数,将每个下游任务名称用作task_name +* RoBERTa支持lcqmc任务 +* 更改不同任务的参数 +* 仅对RoBERTa Base进行了测试 *** -**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 -``` - -**PreProcess** -* Change --data_dir to the real path of each downstream task dataset, and make sure the **predict** file under the path such as 'dev.tsv' -* Change --output_dir to the same with --data_dir, and preprocess script will convert text to bin files under this path -* Keep the --vocab_file, --bert_config_file, --do_lower_case, --max_seq_length, --doc_stride, etc. the same with fine-tuning parameters -* Keep the --model_name=roberta when do the RoBERTa tasks -* Change --task_name to the downstream task you want to do, only support lcqmc tasks -* More datasets and tasks details like download link see README.md in each datasets' path +**环境变量设置** +请参考[说明](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),设置环境变量 + +**预处理** +* 将--data_dir更改为每个下游任务数据集的实际路径,并确保路径下的**predict**文件,如“dev.tsv” +* 将--output_dir更改为与--data_dir相同,预处理脚本将把文本转换为该路径下的bin文件 +* 通过微调参数使--vocab_file、--bert_config_file和--do_lower_case、--max_seq_length、--doc_stride等保持不变 +* 执行roberta任务时保留--model_name=roberta +* 将--task_name更改为要执行的下游任务,仅支持lcqmc任务 +* 更多数据集和任务详细信息,如下载链接,请参阅自述文件。每个数据集路径中的readme.md ```Bash python3 xnlp_fmk.py \ --data_dir=./data/LCQMC \ @@ -79,12 +74,12 @@ python3 xnlp_fmk.py \ ``` -**Freeze pb model** -* Change --output_dir to the real path, and freeze script will convert checkpoint files to pb model file under this path -* Change --checkpoint_dir to the real path of checkpoint files, include 'checkpoint', 'ckpt.data', 'ckpt.index' and 'ckpt.meta' -* Rename --pb_model_file to the real pb model file name -* Change --predict_batch_size to the real batch size, or give 'None' for dynamic batch -* Keep other parameters the same as the previous step +**固定pb模型** +* 将--output_dir更改为实际路径,冻结脚本将把检查点文件转换为该路径下的pb模型文件 +* 将--checkpoint_dir更改为检查点文件的实际路径,包括“checkpoint”、“ckpt”。数据','ckpt。索引'和'ckpt.meta' +* 将--pb_model_file重命名为真正的pb模型文件名 +* 将--predict_batch_size更改为实际批次大小,或为动态批次指定“无” +* 保持其他参数与上一步相同 ```Bash python3 xnlp_fmk.py \ --output_dir=./save/model \ @@ -97,12 +92,12 @@ python3 xnlp_fmk.py \ ``` -**Convert pb to om** -* Rename --om_model_file to the real om model file name -* Change the --soc_version, --in_nodes, --out_nodes according to the actual situation -* Add additional atc parameters if you need, e.g., --precision_mode -* Change --predict_batch_size to the real batch size, currently only support static batch size -* Keep other parameters the same as the previous step +**将pb转换为om** +* 将--om_model_file重命名为实际的om模型文件名 +* 根据实际情况更改--soc_version、--in_nodes、--out_nodes +* 如果需要,可以添加其他atc参数,例如--precision_mode +* 将--predict_batch_size更改为实际批量大小,当前仅支持静态批量大小 +* 保持其他参数与上一步相同 ```Bash python3 xnlp_fmk.py \ --output_dir=./save/model \ @@ -118,10 +113,10 @@ python3 xnlp_fmk.py \ ``` -**Run the inference** -* Change --output_dir to the real path and script will save the output bin file under this path -* Build the inference application and put it under current path, more details see: [xacl_fmk](./xacl_fmk/README.md) -* Keep other parameters the same as the previous step +**运行推断** +* 将--output_dir更改为实际路径,脚本将在该路径下保存输出bin文件 +* 构建推理应用程序并将其置于当前路径下,更多详细信息请参见:[xacl_fmk](./xacl_5mk/README.md) +* 保持其他参数与上一步相同 ```Bash python3 xnlp_fmk.py \ --data_dir=./data/LCQMC \ @@ -134,9 +129,9 @@ python3 xnlp_fmk.py \ ``` -**PostProcess** -* Change --output_dir to the real path and script will save the precision result file under this path -* Keep other parameters the same as the previous step +**后期处理** +* 将--output_dir更改为实际路径,脚本将在此路径下保存精度结果文件 +* 保持其他参数与上一步相同 ```Bash python3 xnlp_fmk.py \ --data_dir=./data/LCQMC \ @@ -151,11 +146,11 @@ python3 xnlp_fmk.py \ ``` -## Other Usages -**Convert pb to pbtxt** -* Change --output_dir to the real path, and convert script will convert pb model file to pbtxt model file under this path -* Rename --pb_model_file to the real pb model file name -* Keep other parameters the same as the previous step +## 其他用途 +**将pb转换为pbtxt** +* 将--output_dir更改为实际路径,convert脚本将在此路径下将pb模型文件转换为pbtxt模型文件 +* 将--pb_model_file重命名为真正的pb模型文件名 +* 保持其他参数与上一步相同 ```Bash python3 xnlp_fmk.py \ --output_dir=./save/model \ @@ -166,9 +161,9 @@ python3 xnlp_fmk.py \ ``` -**Run the inference by pb model** -* Change the --in_nodes, --out_nodes according to the actual situation -* Keep other parameters the same as the previous step +**通过pb模型运行推断** +* 根据实际情况更改--in_nodes、--out_nodes +* 保持其他参数与上一步相同 ```Bash python3 xnlp_fmk.py \ --data_dir=./data/GAD \ @@ -183,7 +178,7 @@ python3 xnlp_fmk.py \ ``` -## Reference +## 参考 [1] https://arxiv.org/abs/1810.04805 diff --git a/ACL_TensorFlow/contrib/nlp/RoBERTa_for_ACL/README_EN.md b/ACL_TensorFlow/contrib/nlp/RoBERTa_for_ACL/README_EN.md new file mode 100644 index 0000000000000000000000000000000000000000..dc04b194fb2e422088471b19a2d21b8a886efbf0 --- /dev/null +++ b/ACL_TensorFlow/contrib/nlp/RoBERTa_for_ACL/README_EN.md @@ -0,0 +1,212 @@ +English|[中文](README.md) + +# + +# RoBERTa DownStream Inference for TensorFlow + +*** +This repository provides a script and recipe to Inference the RoBERTa DownStream Inference + +* [x] RoBERTa DownStream Inference, based on [RoBERTa](https://github.com/brightmart/roberta_zh) + +*** + +## 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.git +cd Modelzoo-TensorFlow/ACL_TensorFlow/contrib/nlp/RoBERTa_for_ACL +``` + +### 2. Download and preprocess the dataset + +Download the dataset by yourself, more details see: [data](./data) +Download the vocab.txt and bert_config.json by yourself, more details see: [config](./config/README.md) + +### 3. Obtain the fine-tuned checkpoint files or pb model + +Obtain the fine-tuned checkpoint files or pb model, more details see: [ckpt](./save/ckpt/README.md) or [models](./save/model/README.md) + +### 4. Build the program +Build the inference application, more details see: [xacl_fmk](./xacl_fmk/README.md) +Put xacl to the current dictory. + +### 5. Offline Inference + +**RoBERTa** +*** +* RoBERTa use roberta for model_name parameter, each downstream task name for task_name +* RoBERTa support lcqmc task +* Change the parameters for different tasks +* Only RoBERTa Base has been tested +*** +**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 + +**PreProcess** +* Change --data_dir to the real path of each downstream task dataset, and make sure the **predict** file under the path such as 'dev.tsv' +* Change --output_dir to the same with --data_dir, and preprocess script will convert text to bin files under this path +* Keep the --vocab_file, --bert_config_file, --do_lower_case, --max_seq_length, --doc_stride, etc. the same with fine-tuning parameters +* Keep the --model_name=roberta when do the RoBERTa tasks +* Change --task_name to the downstream task you want to do, only support lcqmc tasks +* More datasets and tasks details like download link see README.md in each datasets' path +```Bash +python3 xnlp_fmk.py \ + --data_dir=./data/LCQMC \ + --output_dir=./data/LCQMC \ + --vocab_file=./config/roberta_large/vocab.txt \ + --bert_config_file=./config/roberta_large/bert_config_large.json \ + --do_lower_case=True \ + --model_name=roberta \ + --task_name=lcqmc \ + --action_type=preprocess + +``` + +**Freeze pb model** +* Change --output_dir to the real path, and freeze script will convert checkpoint files to pb model file under this path +* Change --checkpoint_dir to the real path of checkpoint files, include 'checkpoint', 'ckpt.data', 'ckpt.index' and 'ckpt.meta' +* Rename --pb_model_file to the real pb model file name +* Change --predict_batch_size to the real batch size, or give 'None' for dynamic batch +* Keep other parameters the same as the previous step +```Bash +python3 xnlp_fmk.py \ + --output_dir=./save/model \ + --bert_config_file=./config/roberta_large/bert_config_large.json \ + --pb_model_file=./save/model/ROBERTA_LARGE_LCQMC_BatchSize_None.pb \ + --checkpoint_dir=./save/ckpt/roberta_large_lcqmc \ + --model_name=roberta \ + --task_name=lcqmc \ + --action_type=freeze + +``` + +**Convert pb to om** +* Rename --om_model_file to the real om model file name +* Change the --soc_version, --in_nodes, --out_nodes according to the actual situation +* Add additional atc parameters if you need, e.g., --precision_mode +* Change --predict_batch_size to the real batch size, currently only support static batch size +* Keep other parameters the same as the previous step +```Bash +python3 xnlp_fmk.py \ + --output_dir=./save/model \ + --pb_model_file=./save/model/ROBERTA_LARGE_LCQMC_BatchSize_None.pb \ + --om_model_file=./save/model/ROBERTA_LARGE_LCQMC_BatchSize_1.om \ + --predict_batch_size=1 \ + --soc_version="Ascend310" \ + --in_nodes="\"input_ids:1,128;input_mask:1,128;segment_ids:1,128\"" \ + --out_nodes="\"logits:0\"" \ + --model_name=roberta \ + --task_name=lcqmc \ + --action_type=atc + +``` + +**Run the inference** +* Change --output_dir to the real path and script will save the output bin file under this path +* Build the inference application and put it under current path, more details see: [xacl_fmk](./xacl_fmk/README.md) +* Keep other parameters the same as the previous step +```Bash +python3 xnlp_fmk.py \ + --data_dir=./data/LCQMC \ + --output_dir=./save/output \ + --om_model_file=./save/model/ROBERTA_LARGE_LCQMC_BatchSize_1.om \ + --predict_batch_size=1 \ + --model_name=roberta \ + --task_name=lcqmc \ + --action_type=npu + +``` + +**PostProcess** +* Change --output_dir to the real path and script will save the precision result file under this path +* Keep other parameters the same as the previous step +```Bash +python3 xnlp_fmk.py \ + --data_dir=./data/LCQMC \ + --output_dir=./save/output \ + --vocab_file=./config/roberta_large/vocab.txt \ + --om_model_file=./save/model/ROBERTA_LARGE_LCQMC_BatchSize_1.om \ + --predict_batch_size=1 \ + --do_lower_case=True \ + --model_name=roberta \ + --task_name=lcqmc \ + --action_type=postprocess + +``` + +## Other Usages +**Convert pb to pbtxt** +* Change --output_dir to the real path, and convert script will convert pb model file to pbtxt model file under this path +* Rename --pb_model_file to the real pb model file name +* Keep other parameters the same as the previous step +```Bash +python3 xnlp_fmk.py \ + --output_dir=./save/model \ + --pb_model_file=./save/model/ROBERTA_LARGE_LCQMC_BatchSize_1.pb \ + --model_name=roberta \ + --task_name=lcqmc \ + --action_type=pbtxt + +``` + +**Run the inference by pb model** +* Change the --in_nodes, --out_nodes according to the actual situation +* Keep other parameters the same as the previous step +```Bash +python3 xnlp_fmk.py \ + --data_dir=./data/GAD \ + --output_dir=./save/output \ + --pb_model_file=./save/model/ROBERTA_LARGE_LCQMC_BatchSize_1.pb \ + --predict_batch_size=1 \ + --in_nodes="\"input_ids:1,128;input_mask:1,128;segment_ids:1,128\"" \ + --out_nodes="\"logits:0\"" \ + --model_name=roberta \ + --task_name=lcqmc \ + --action_type=cpu + +``` + +## Reference + +[1] https://arxiv.org/abs/1810.04805 + +[2] https://github.com/google-research/bert + +[3] https://github.com/kyzhouhzau/BERT-NER + +[4] https://github.com/zjy-ucas/ChineseNER + +[5] https://github.com/hanxiao/bert-as-service + +[6] https://github.com/macanv/BERT-BiLSTM-CRF-NER + +[7] https://github.com/tensorflow/tensor2tensor + +[8] https://github.com/google-research/albert + +[9] https://github.com/brightmart/albert_zh + +[10] https://github.com/HqWei/Sentiment-Analysis + +[11] https://gitee.com/wang-bain/xacl_fmk + +[12] https://github.com/brightmart/roberta_zh + +[13] https://github.com/dmis-lab/biobert + +[14] https://github.com/Songweiping/GRU4Rec_TensorFlow + +# diff --git a/ACL_TensorFlow/contrib/nlp/Siamese_for_ACL/README.md b/ACL_TensorFlow/contrib/nlp/Siamese_for_ACL/README.md index 0e07b9238686b973355ac648c6606b32b7d64681..e11e47717e63be88ff4441914798516bf2fa3683 100644 --- a/ACL_TensorFlow/contrib/nlp/Siamese_for_ACL/README.md +++ b/ACL_TensorFlow/contrib/nlp/Siamese_for_ACL/README.md @@ -1,40 +1,40 @@ +中文|[English](README_EN.md) +# Siamese TensorFlow离线推理 -# Siamese Inference for Tensorflow - -This repository provides a script and recipe to Inference the Siamese model. Original train implement please follow this link: [Siamese_for_Tensorflow](https://github.com/dhwajraj/deep-siamese-text-similarity) +此存储库提供了推断模型的脚本和方法。原始训练推理实施请遵循以下链接:[Siamese_for_Tensorflow](https://github.com/dhwajraj/deep-siamese-text-similarity) and in this repo we trained a model for **Phrase Similarity**. -## 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/contrib/cv/Siamese_for_ACL ``` -### 2. Preprocess of the dataset +### 2. 下载数据集和预处理 -1. When the train steps finished, **validation.txt0** and **vocab** under **runs/xxxx/checkpoints/** will be generated. Copy them to **scripts/dataset** path. +1. 当训练完成, **validation.txt0** 和 **vocab** 在 **runs/xxxx/checkpoints/** 下面生成. 复制到这个路径 **scripts/dataset** 。 -2. Preprocess of the validation datasets: +2. 验证数据集的预处理: ``` cd scripts python3 data_preprocess.py ``` -and it will generate **input_x1**, **input_x2**, **ground_truth** directories with batchsize **128**: +将生成 **input_x1**, **input_x2**, **ground_truth** directories with batchsize **128**: ``` input_x1 |___000000.bin @@ -52,34 +52,28 @@ ground_truth ... ``` -### 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:$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模型 ``` atc --model=siamese_tf.pb --framework=3 --output=siamese_tf_128batch --output_type=FP32 --soc_version=Ascend310 --input_shape="input_x1:128,15;input_x2:128,15" --log=info --precision_mode=allow_fp32_to_fp16 ``` -- Build the program +- 编译程序 ``` bash build.sh ``` - An executable file **benchmark** will be generated under the path: **Benchmark/output/** + 将在路径下生成可执行文件 **benchmark** : **Benchmark/output/** -- Run the program: +- 开始运行: ``` cd scripts @@ -88,17 +82,17 @@ ground_truth -## Performance +## 推理结果 -### Result +### 结果 -Our result were obtained by running the applicable training script. To achieve the same results, follow the steps in the Quick Start Guide. +本结果是通过运行上面适配的推理脚本获得的。要获得相同的结果,请按照《快速指南》中的步骤操作。 -#### Inference accuracy results: +#### 推理精度结果 | Test Dataset | Accuracy | |--------------|-------------------| | vocab | 94.9% | -## Reference +## 参考 [1] https://github.com/dhwajraj/deep-siamese-text-similarity diff --git a/ACL_TensorFlow/contrib/nlp/Siamese_for_ACL/README_EN.md b/ACL_TensorFlow/contrib/nlp/Siamese_for_ACL/README_EN.md new file mode 100644 index 0000000000000000000000000000000000000000..a1d10dd184df6f77990624cd5b09f62f73df3b36 --- /dev/null +++ b/ACL_TensorFlow/contrib/nlp/Siamese_for_ACL/README_EN.md @@ -0,0 +1,98 @@ +English|[中文](README.md) + +# Siamese Inference for Tensorflow + +This repository provides a script and recipe to Inference the Siamese model. Original train implement please follow this link: [Siamese_for_Tensorflow](https://github.com/dhwajraj/deep-siamese-text-similarity) +and in this repo we trained a model for **Phrase Similarity**. + +## 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/contrib/cv/Siamese_for_ACL +``` + +### 2. Preprocess of the dataset + +1. When the train steps finished, **validation.txt0** and **vocab** under **runs/xxxx/checkpoints/** will be generated. Copy them to **scripts/dataset** path. + +2. Preprocess of the validation datasets: +``` +cd scripts +python3 data_preprocess.py +``` +and it will generate **input_x1**, **input_x2**, **ground_truth** directories with batchsize **128**: +``` +input_x1 +|___000000.bin +|___000001.bin +... + +input_x2 +|___000000.bin +|___000001.bin +... + +ground_truth +|___000000.txt +|___000001.txt +... +``` + +### 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 + + ``` + atc --model=siamese_tf.pb --framework=3 --output=siamese_tf_128batch --output_type=FP32 --soc_version=Ascend310 --input_shape="input_x1:128,15;input_x2:128,15" --log=info --precision_mode=allow_fp32_to_fp16 + ``` + +- Build the program + + ``` + bash build.sh + ``` + An executable file **benchmark** will be generated under the path: **Benchmark/output/** + +- Run the program: + + ``` + cd scripts + bash benchmark_tf.sh + ``` + + + +## Performance + +### Result + +Our result were obtained by running the applicable training script. To achieve the same results, follow the steps in the Quick Start Guide. + +#### Inference accuracy results: + +| Test Dataset | Accuracy | +|--------------|-------------------| +| vocab | 94.9% | + +## Reference +[1] https://github.com/dhwajraj/deep-siamese-text-similarity diff --git a/ACL_TensorFlow/contrib/nlp/Transformer_for_ACL/README.md b/ACL_TensorFlow/contrib/nlp/Transformer_for_ACL/README.md index 640c045242d0d9d8d3479bfd8272ec2027118874..00e7aaf42cfded0bb727439b23afda6a92115a3e 100644 --- a/ACL_TensorFlow/contrib/nlp/Transformer_for_ACL/README.md +++ b/ACL_TensorFlow/contrib/nlp/Transformer_for_ACL/README.md @@ -1,63 +1,58 @@ # +中文|[English](README_EN.md) -# Transformer Translation Inference for TensorFlow +# Transformer Translation TensorFlow离线推理 *** -This repository provides a script and recipe to Inference the Transformer Translation Inference +此链接提供Transformer Translation TensorFlow模型在NPU上离线推理的脚本和方法 -* [x] Transformer Translation Inference, Based on [Tensor2Tensor](https://github.com/tensorflow/tensor2tensor/tree/master/tensor2tensor) +* [x] Transformer Translation 推理, 基于 [Tensor2Tensor](https://github.com/tensorflow/tensor2tensor/tree/master/tensor2tensor) *** -## 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/contrib/nlp/Transformer_for_ACL ``` -### 2. Download and preprocess the dataset +### 2. 下载数据集和预处理 -Download the dataset by yourself, more details see: [data](./data/WMT32K/README.md) -Obtain the vocab.translate_ende_wmt32k.subwords by yourself, more details see: [config](./config/README.md) +请自行下载数据集, 更多详细信息请参见: [data](./data/WMT32K/README.md) +请自行获取vocab.translate_ende_wmt32k.subwords, 更多详细信息请参见: [config](./config/README.md) -### 3. Obtain the pb model +### 3. 获取pb模型 -Obtain the pb model in Ascend ModelZoo: [Transformer](https://www.hiascend.com/zh/software/modelzoo/detail/1/4aa974b3f2fb4e02a84abbf16b56f032) +在Ascend ModelZoo中获取pb模型: [Transformer](https://www.hiascend.com/zh/software/modelzoo/detail/1/4aa974b3f2fb4e02a84abbf16b56f032) -### 4. Build the program -Build the inference application, more details see: [xacl_fmk](./xacl_fmk/README.md) -Put xacl to the current dictory. +### 4. 编译程序 +构建推理应用程序,并将其放至当前路径下,更多详细信息请参见: [xacl_fmk](./xacl_fmk/README.md) -### 5. Offline Inference + +### 5. 离线推理 **Transformer** *** -* Transformer use transformer for model_name parameter, translation for task_name -* Change the parameters for different tasks +* Transformer将Transformer用于model_name参数,转换为task_name +* 更改不同任务的参数 *** -**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),设置环境变量 -**PreProcess** +**预处理** ```Bash python3 xnlp_fmk.py \ --data_dir=./data/WMT32K \ @@ -69,7 +64,7 @@ python3 xnlp_fmk.py \ ``` -**Convert pb to om** +**Pb模型转换为om模型** ```Bash python3 xnlp_fmk.py \ --output_dir=./save/model \ @@ -88,7 +83,7 @@ python3 xnlp_fmk.py \ ``` -**Run the inference** +**运行推理** ```Bash python3 xnlp_fmk.py \ --data_dir=./data/WMT32K \ @@ -101,7 +96,7 @@ python3 xnlp_fmk.py \ ``` -**PostProcess** +**后期处理** ```Bash python3 xnlp_fmk.py \ --data_dir=./data/WMT32K \ @@ -115,8 +110,8 @@ python3 xnlp_fmk.py \ ``` -## Other Usages -**Convert pb to pbtxt** +## 其他用途 +**将pb转换为pbtxt** ```Bash python3 xnlp_fmk.py \ --output_dir=./save/model \ @@ -127,7 +122,7 @@ python3 xnlp_fmk.py \ ``` -**Run the inference by pb model** +**通过pb模型运行推理** ```Bash python3 xnlp_fmk.py \ --data_dir=./data/GAD \ @@ -142,7 +137,7 @@ python3 xnlp_fmk.py \ ``` -## Reference +## 参考 [1] https://arxiv.org/abs/1810.04805 diff --git a/ACL_TensorFlow/contrib/nlp/Transformer_for_ACL/README_EN.md b/ACL_TensorFlow/contrib/nlp/Transformer_for_ACL/README_EN.md new file mode 100644 index 0000000000000000000000000000000000000000..ee663d7485fe0119c39b8e222ad4c7a021e24c0a --- /dev/null +++ b/ACL_TensorFlow/contrib/nlp/Transformer_for_ACL/README_EN.md @@ -0,0 +1,170 @@ +# +English|[中文](README.md) + +# Transformer Translation Inference for TensorFlow + +*** +This repository provides a script and recipe to Inference the Transformer Translation Inference + +* [x] Transformer Translation Inference, Based on [Tensor2Tensor](https://github.com/tensorflow/tensor2tensor/tree/master/tensor2tensor) + +*** + +## 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/contrib/nlp/Transformer_for_ACL +``` + +### 2. Download and preprocess the dataset + +Download the dataset by yourself, more details see: [data](./data/WMT32K/README.md) +Obtain the vocab.translate_ende_wmt32k.subwords by yourself, more details see: [config](./config/README.md) + +### 3. Obtain the pb model + +Obtain the pb model in Ascend ModelZoo: [Transformer](https://www.hiascend.com/zh/software/modelzoo/detail/1/4aa974b3f2fb4e02a84abbf16b56f032) + +### 4. Build the program +Build the inference application, more details see: [xacl_fmk](./xacl_fmk/README.md) +Put xacl to the current dictory. + +### 5. Offline Inference + +**Transformer** +*** +* Transformer use transformer for model_name parameter, translation for task_name +* Change the parameters for different tasks +*** +**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 + +**PreProcess** +```Bash +python3 xnlp_fmk.py \ + --data_dir=./data/WMT32K \ + --output_dir=./data/WMT32K \ + --vocab_file=./config/translate_ende_wmt32k/vocab.translate_ende_wmt32k.32768.subwords \ + --model_name=transformer \ + --task_name=translation \ + --action_type=preprocess + +``` + +**Convert pb to om** +```Bash +python3 xnlp_fmk.py \ + --output_dir=./save/model \ + --vocab_file=./config/translate_ende_wmt32k/vocab.translate_ende_wmt32k.32768.subwords \ + --pb_model_file=./save/model/TRANSFORMER_TRANSLATION_BatchSize_1.pb \ + --om_model_file=./save/model/TRANSFORMER_TRANSLATION_BatchSize_1.om \ + --predict_batch_size=1 \ + --soc_version="Ascend310" \ + --in_nodes="\"input:1,128\"" \ + --out_nodes="\"transformer/strided_slice_11:0\"" \ + --precision_mode="allow_mix_precision" \ + --op_select_implmode="high_precision" \ + --model_name=transformer \ + --task_name=translation \ + --action_type=atc + +``` + +**Run the inference** +```Bash +python3 xnlp_fmk.py \ + --data_dir=./data/WMT32K \ + --output_dir=./save/output \ + --om_model_file=./save/model/TRANSFORMER_TRANSLATION_BatchSize_1.om \ + --predict_batch_size=1 \ + --model_name=transformer \ + --task_name=translation \ + --action_type=npu + +``` + +**PostProcess** +```Bash +python3 xnlp_fmk.py \ + --data_dir=./data/WMT32K \ + --output_dir=./save/output \ + --vocab_file=./config/translate_ende_wmt32k/vocab.translate_ende_wmt32k.32768.subwords \ + --om_model_file=./save/model/TRANSFORMER_TRANSLATION_BatchSize_1.om \ + --predict_batch_size=1 \ + --model_name=transformer \ + --task_name=translation \ + --action_type=postprocess + +``` + +## Other Usages +**Convert pb to pbtxt** +```Bash +python3 xnlp_fmk.py \ + --output_dir=./save/model \ + --pb_model_file=./save/model/BIOBERT_BASE_RE_BatchSize_None.pb \ + --model_name=biobert \ + --task_name=re \ + --action_type=pbtxt + +``` + +**Run the inference by pb model** +```Bash +python3 xnlp_fmk.py \ + --data_dir=./data/GAD \ + --output_dir=./save/output \ + --pb_model_file=./save/model/BIOBERT_BASE_RE_BatchSize_None.pb \ + --predict_batch_size=1 \ + --in_nodes="\"input_ids:1,128;input_mask:1,128;segment_ids:1,128\"" \ + --out_nodes="\"logits:0\"" \ + --model_name=biobert \ + --task_name=re \ + --action_type=cpu + +``` + +## Reference + +[1] https://arxiv.org/abs/1810.04805 + +[2] https://github.com/google-research/bert + +[3] https://github.com/kyzhouhzau/BERT-NER + +[4] https://github.com/zjy-ucas/ChineseNER + +[5] https://github.com/hanxiao/bert-as-service + +[6] https://github.com/macanv/BERT-BiLSTM-CRF-NER + +[7] https://github.com/tensorflow/tensor2tensor + +[8] https://github.com/google-research/albert + +[9] https://github.com/brightmart/albert_zh + +[10] https://github.com/HqWei/Sentiment-Analysis + +[11] https://gitee.com/wang-bain/xacl_fmk + +[12] https://github.com/brightmart/roberta_zh + +[13] https://github.com/dmis-lab/biobert + +[14] https://github.com/Songweiping/GRU4Rec_TensorFlow + +# diff --git a/ACL_TensorFlow/contrib/recommendation/DIEN_for_ACL/README.md b/ACL_TensorFlow/contrib/recommendation/DIEN_for_ACL/README.md index e94f9c4e105dffa0a10ba3c1030e3641d4fc5a21..e408c30109bf9c9179811acda1edff7dba561bd7 100644 --- a/ACL_TensorFlow/contrib/recommendation/DIEN_for_ACL/README.md +++ b/ACL_TensorFlow/contrib/recommendation/DIEN_for_ACL/README.md @@ -1,32 +1,32 @@ +中文|[English](README_EN.md) +# DIEN TensorFlow离线推理 -# DIEN Inference for Tensorflow +此链接提供Vgg16 TensorFlow模型在NPU上离线推理的脚本和方法 -This repository provides a script and recipe to Inference of the DIEN model. +## 注意 +**此案例仅为您学习Ascend软件栈提供参考,不用于商业目的。** -## 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| 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/contrib/recommendation/DIEN_for_ACL ``` -### 2. Generate random test dataset +### 2. 生成随机测试数据集 -1. Follow the [train repo](https://github.com/mouna99/dien), download dataset and unzip it to use: +1. 使用这个连接 [train repo](https://github.com/mouna99/dien), 下载数据集并解压缩以使用: ``` tar -jxvf data.tar.gz mv data/* scripts @@ -35,7 +35,7 @@ mv data1/* scripts tar -jxvf data2.tar.gz mv data2/* scripts ``` -and you will get files below: +你会得到下面的文件: - cat_voc.pkl - mid_voc.pkl - uid_voc.pkl @@ -44,60 +44,54 @@ and you will get files below: - reviews-info - item-info -2. Generate test dataset: +2. 生成测试数据集: ``` cd scripts python3 generate_data.py --batchsize=128 ``` -There will testdata bin fils under *input_bins/*. +测试数据集会在这个目录下面 *input_bins/*. -### 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://modelzoo-train-atc.obs.cn-north-4.myhuaweicloud.com/003_Atc_Models/modelzoo/Research/recommendation/DIEN_for_ACL/DIEN.pb) + [**pb模型下载链接**](https://modelzoo-train-atc.obs.cn-north-4.myhuaweicloud.com/003_Atc_Models/modelzoo/Research/recommendation/DIEN_for_ACL/DIEN.pb) ``` export batch_size=128 atc --model=./DIEN.pb --framework=3 --output=./DIEN_${batch_size}batch --soc_version=Ascend310P3 --input_shape="Inputs/mid_his_batch_ph:${batch_size},100;Inputs/cat_his_batch_ph:${batch_size},100;Inputs/uid_batch_ph:${batch_size};Inputs/mid_batch_ph:${batch_size};Inputs/cat_batch_ph:${batch_size};Inputs/mask:${batch_size},100;Inputs/seq_len_ph:${batch_size}" --out_nodes="final_output:0" --precision_mode="allow_fp32_to_fp16" --customize_dtypes="./customize_dtypes.txt" ``` -- 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** | MeanAccuracy | | :---------------: | :-------: | :-------------: | | offline Inference | Amazon ProductGraph | 78.5% | -## Reference +## 参考 [1] https://github.com/mouna99/dien diff --git a/ACL_TensorFlow/contrib/recommendation/DIEN_for_ACL/README_EN.md b/ACL_TensorFlow/contrib/recommendation/DIEN_for_ACL/README_EN.md new file mode 100644 index 0000000000000000000000000000000000000000..09b27d1dc4834aab47f6b3cd3ae023ae5740db36 --- /dev/null +++ b/ACL_TensorFlow/contrib/recommendation/DIEN_for_ACL/README_EN.md @@ -0,0 +1,97 @@ +English|[中文](README.md) + +# DIEN Inference for Tensorflow + +This repository provides a script and recipe to Inference of the DIEN 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| 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/contrib/recommendation/DIEN_for_ACL +``` + +### 2. Generate random test dataset + +1. Follow the [train repo](https://github.com/mouna99/dien), download dataset and unzip it to use: +``` +tar -jxvf data.tar.gz +mv data/* scripts +tar -jxvf data1.tar.gz +mv data1/* scripts +tar -jxvf data2.tar.gz +mv data2/* scripts +``` +and you will get files below: +- cat_voc.pkl +- mid_voc.pkl +- uid_voc.pkl +- local_train_splitByUser +- local_test_splitByUser +- reviews-info +- item-info + +2. Generate test dataset: +``` +cd scripts +python3 generate_data.py --batchsize=128 +``` +There will testdata bin fils under *input_bins/*. + +### 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://modelzoo-train-atc.obs.cn-north-4.myhuaweicloud.com/003_Atc_Models/modelzoo/Research/recommendation/DIEN_for_ACL/DIEN.pb) + + ``` + export batch_size=128 + atc --model=./DIEN.pb --framework=3 --output=./DIEN_${batch_size}batch --soc_version=Ascend310P3 --input_shape="Inputs/mid_his_batch_ph:${batch_size},100;Inputs/cat_his_batch_ph:${batch_size},100;Inputs/uid_batch_ph:${batch_size};Inputs/mid_batch_ph:${batch_size};Inputs/cat_batch_ph:${batch_size};Inputs/mask:${batch_size},100;Inputs/seq_len_ph:${batch_size}" --out_nodes="final_output:0" --precision_mode="allow_fp32_to_fp16" --customize_dtypes="./customize_dtypes.txt" + ``` + +- 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** | MeanAccuracy | +| :---------------: | :-------: | :-------------: | +| offline Inference | Amazon ProductGraph | 78.5% | + +## Reference +[1] https://github.com/mouna99/dien diff --git a/ACL_TensorFlow/contrib/recommendation/DIN_for_ACL/README.md b/ACL_TensorFlow/contrib/recommendation/DIN_for_ACL/README.md index fbf3c13a9fb9e4ca895959c81aa43c4d65dab614..021111a33997bbe435188fd0b1e061b456926780 100644 --- a/ACL_TensorFlow/contrib/recommendation/DIN_for_ACL/README.md +++ b/ACL_TensorFlow/contrib/recommendation/DIN_for_ACL/README.md @@ -1,32 +1,32 @@ +中文|[English](README_EN.md) +# DIN TensorFlow离线推理 -# DIN Inference for Tensorflow +此链接提供DIN TensorFlow模型在NPU上离线推理的脚本和方法 -This repository provides a script and recipe to Inference of the DIN model. +## 注意 +**此案例仅为您学习Ascend软件栈提供参考,不用于商业目的。** -## 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| 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/contrib/recommendation/DIN_for_ACL ``` -### 2. Generate random test dataset +### 2. 生成随机测试数据集 -1. Follow the [train repo](https://github.com/zhougr1993/DeepInterestNetwork) guide download amazon data +1. 根据这个链接 [train repo](https://github.com/zhougr1993/DeepInterestNetwork) 指导下载数据。 ``` step 1: cd ../raw_data @@ -42,62 +42,56 @@ step 3: cd din build_dataset.py ``` -get the dataset: dataset.pkl +获取数据集: dataset.pkl -2. Generate test dataset: +2. 生成测试数据集: ``` cd scripts python3 preprocess.py ``` -There will generate testdata bin fils under *input_bins/* and dataset_conf.txt. +在 *input_bins/* 和 dataset_conf.txt下生成测试数据集 -### 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://ascend-repo-modelzoo.obs.cn-east-2.myhuaweicloud.com/model/2022-09-24_tf/DIN_for_ACL/frozen_din.pb) + + [**pb模型下载链接**](https://ascend-repo-modelzoo.obs.cn-east-2.myhuaweicloud.com/model/2022-09-24_tf/DIN_for_ACL/frozen_din.pb) ``` export batch_size=512 atc --model=frozen_din.pb --framework=3 --soc_version=Ascend310P3 --output=din_${batch_size}batch_dynamic_shape --log=error --op_debug_level=3 --input_shape_range="Placeholder_1:[100~512];Placeholder_2:[100~512];Placeholder_4:[100~512,-1];Placeholder_5:[100~512]" ``` -- 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** | test_gauc | test_auc | | :---------------: | :-------: | :-----------: | :-----------: | | offline Inference | dataset.pkl | 0.6854 | 0.6836 | -## Reference +## 参考 [1] https://github.com/AustinMaster/DeepInterestNetwork/tree/master/din diff --git a/ACL_TensorFlow/contrib/recommendation/DIN_for_ACL/README_EN.md b/ACL_TensorFlow/contrib/recommendation/DIN_for_ACL/README_EN.md new file mode 100644 index 0000000000000000000000000000000000000000..ca8c8bf8fa77273026a0df6dc477a1dfe4bf237a --- /dev/null +++ b/ACL_TensorFlow/contrib/recommendation/DIN_for_ACL/README_EN.md @@ -0,0 +1,97 @@ +English|[中文](README.md) + +# DIN Inference for Tensorflow + +This repository provides a script and recipe to Inference of the DIN 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| 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/contrib/recommendation/DIN_for_ACL +``` + +### 2. Generate random test dataset + +1. Follow the [train repo](https://github.com/zhougr1993/DeepInterestNetwork) guide download amazon data +``` +step 1: +cd ../raw_data +wget -c http://snap.stanford.edu/data/amazon/productGraph/categoryFiles/reviews_Electronics_5.json.gz +gzip -d reviews_Electronics_5.json.gz +wget -c http://snap.stanford.edu/data/amazon/productGraph/categoryFiles/meta_Electronics.json.gz +gzip -d meta_Electronics.json.gz +step 2: +cd utils +python 1_convert_pd.py; +python 2_remap_id.py +step 3: +cd din +build_dataset.py +``` +get the dataset: dataset.pkl + +2. Generate test dataset: +``` +cd scripts +python3 preprocess.py +``` +There will generate testdata bin fils under *input_bins/* and dataset_conf.txt. + +### 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://ascend-repo-modelzoo.obs.cn-east-2.myhuaweicloud.com/model/2022-09-24_tf/DIN_for_ACL/frozen_din.pb) + + ``` + export batch_size=512 + atc --model=frozen_din.pb --framework=3 --soc_version=Ascend310P3 --output=din_${batch_size}batch_dynamic_shape --log=error --op_debug_level=3 --input_shape_range="Placeholder_1:[100~512];Placeholder_2:[100~512];Placeholder_4:[100~512,-1];Placeholder_5:[100~512]" + ``` + +- 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** | test_gauc | test_auc | +| :---------------: | :-------: | :-----------: | :-----------: | +| offline Inference | dataset.pkl | 0.6854 | 0.6836 | + +## Reference +[1] https://github.com/AustinMaster/DeepInterestNetwork/tree/master/din diff --git a/ACL_TensorFlow/contrib/recommendation/WideDeep_for_ACL/README.md b/ACL_TensorFlow/contrib/recommendation/WideDeep_for_ACL/README.md index d736338f85cd9bb4c06fbcdd74483a85684b56c5..e6c5f6f898ca4f41e091f2faadd06b47e015119c 100644 --- a/ACL_TensorFlow/contrib/recommendation/WideDeep_for_ACL/README.md +++ b/ACL_TensorFlow/contrib/recommendation/WideDeep_for_ACL/README.md @@ -1,90 +1,84 @@ +中文|[English](README_EN.md) +# Wide&Deep TensorFlow离线推理 -# Wide&Deep Inference for Tensorflow +此链接提供Wide&Deep TensorFlow模型在NPU上离线推理的脚本和方法。 -This repository provides a script and recipe to Inference of the Wide&Deep model. +## 注意 +**此案例仅为您学习Ascend软件栈提供参考,不用于商业目的。** -## 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| 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/contrib/recommendation/WideDeep_for_ACL ``` -### 2. Generate random test dataset +### 2. 生成随机测试数据集 -1. Follow the [train repo](https://github.com/NVIDIA/DeepLearningExamples/tree/master/TensorFlow/Recommendation/WideAndDeep) guide download outbrain dataset +1. 按照连接 [train repo](https://github.com/NVIDIA/DeepLearningExamples/tree/master/TensorFlow/Recommendation/WideAndDeep) 下载outbrain数据集 and preprocess to TFRecords, then move 'outbrain/tfrecords' to './scripts' -2. Generate test dataset: +2. 生成测试数据集: ``` cd scripts python3 generate_data.py --path=./outbrain/tfrecords --batchsize=1024 ``` -There will generate testdata bin fils under *input_bins/*. +在目录 *input_bins/*下生成测试集的bin文件 -### 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://modelzoo-train-atc.obs.cn-north-4.myhuaweicloud.com/003_Atc_Models/modelzoo/Research/recommendation/WideDeep_for_ACL/widedeep_npu.pb) + [**pb模型下载链接**](https://modelzoo-train-atc.obs.cn-north-4.myhuaweicloud.com/003_Atc_Models/modelzoo/Research/recommendation/WideDeep_for_ACL/widedeep_npu.pb) ``` export batch_size=1024 atc --model=widedeep_npu.pb --framework=3 --soc_version=Ascend310P3 --output=widedeep_${batch_size}batch --log=error --op_debug_level=3 --input_shape="ad_advertiser:${batch_size},1;ad_id:${batch_size},1;ad_views_log_01scaled:${batch_size},1;doc_ad_category_id:${batch_size},3;doc_ad_days_since_published_log_01scaled:${batch_size},1;doc_ad_entity_id:${batch_size},6;doc_ad_publisher_id:${batch_size},1;doc_ad_source_id:${batch_size},1;doc_ad_topic_id:${batch_size},3;doc_event_category_id:${batch_size},3;doc_event_days_since_published_log_01scaled:${batch_size},1;doc_event_doc_ad_sim_categories_log_01scaled:${batch_size},1;doc_event_doc_ad_sim_entities_log_01scaled:${batch_size},1;doc_event_doc_ad_sim_topics_log_01scaled:${batch_size},1;doc_event_entity_id:${batch_size},6;doc_event_hour_log_01scaled:${batch_size},1;doc_event_id:${batch_size},1;doc_event_publisher_id:${batch_size},1;doc_event_source_id:${batch_size},1;doc_event_topic_id:${batch_size},3;doc_id:${batch_size},1;doc_views_log_01scaled:${batch_size},1;event_country:${batch_size},1;event_country_state:${batch_size},1;event_geo_location:${batch_size},1;event_hour:${batch_size},1;event_platform:${batch_size},1;event_weekend:${batch_size},1;pop_ad_id_conf:${batch_size},1;pop_ad_id_log_01scaled:${batch_size},1;pop_advertiser_id_conf:${batch_size},1;pop_advertiser_id_log_01scaled:${batch_size},1;pop_campain_id_conf_multipl_log_01scaled:${batch_size},1;pop_campain_id_log_01scaled:${batch_size},1;pop_category_id_conf:${batch_size},1;pop_category_id_log_01scaled:${batch_size},1;pop_document_id_conf:${batch_size},1;pop_document_id_log_01scaled:${batch_size},1;pop_entity_id_conf:${batch_size},1;pop_entity_id_log_01scaled:${batch_size},1;pop_publisher_id_conf:${batch_size},1;pop_publisher_id_log_01scaled:${batch_size},1;pop_source_id_conf:${batch_size},1;pop_source_id_log_01scaled:${batch_size},1;pop_topic_id_conf:${batch_size},1;pop_topic_id_log_01scaled:${batch_size},1;traffic_source:${batch_size},1;user_doc_ad_sim_categories_conf:${batch_size},1;user_doc_ad_sim_categories_log_01scaled:${batch_size},1;user_doc_ad_sim_entities_log_01scaled:${batch_size},1;user_doc_ad_sim_topics_conf:${batch_size},1;user_doc_ad_sim_topics_log_01scaled:${batch_size},1;user_has_already_viewed_doc:${batch_size},1;user_views_log_01scaled:${batch_size},1" --out_nodes=eval_predictions:0 ``` -- 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** | Accuracy | | :---------------: | :-------: | :-------------: | | offline Inference | out brain test | 64.9% | -## Reference +## 参考 [1] https://github.com/NVIDIA/DeepLearningExamples/tree/master/TensorFlow/Recommendation/WideAndDeep diff --git a/ACL_TensorFlow/contrib/recommendation/WideDeep_for_ACL/README_EN.md b/ACL_TensorFlow/contrib/recommendation/WideDeep_for_ACL/README_EN.md new file mode 100644 index 0000000000000000000000000000000000000000..1f64456156a15cf80c730dc186e6cf85ab74e22f --- /dev/null +++ b/ACL_TensorFlow/contrib/recommendation/WideDeep_for_ACL/README_EN.md @@ -0,0 +1,84 @@ +English|[中文](README.md) + +# Wide&Deep Inference for Tensorflow + +This repository provides a script and recipe to Inference of the Wide&Deep 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| 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/contrib/recommendation/WideDeep_for_ACL +``` + +### 2. Generate random test dataset + +1. Follow the [train repo](https://github.com/NVIDIA/DeepLearningExamples/tree/master/TensorFlow/Recommendation/WideAndDeep) guide download outbrain dataset + +and preprocess to TFRecords, then move 'outbrain/tfrecords' to './scripts' + + +2. Generate test dataset: +``` +cd scripts +python3 generate_data.py --path=./outbrain/tfrecords --batchsize=1024 +``` +There will generate testdata bin fils under *input_bins/*. + +### 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://modelzoo-train-atc.obs.cn-north-4.myhuaweicloud.com/003_Atc_Models/modelzoo/Research/recommendation/WideDeep_for_ACL/widedeep_npu.pb) + + ``` + export batch_size=1024 + atc --model=widedeep_npu.pb --framework=3 --soc_version=Ascend310P3 --output=widedeep_${batch_size}batch --log=error --op_debug_level=3 --input_shape="ad_advertiser:${batch_size},1;ad_id:${batch_size},1;ad_views_log_01scaled:${batch_size},1;doc_ad_category_id:${batch_size},3;doc_ad_days_since_published_log_01scaled:${batch_size},1;doc_ad_entity_id:${batch_size},6;doc_ad_publisher_id:${batch_size},1;doc_ad_source_id:${batch_size},1;doc_ad_topic_id:${batch_size},3;doc_event_category_id:${batch_size},3;doc_event_days_since_published_log_01scaled:${batch_size},1;doc_event_doc_ad_sim_categories_log_01scaled:${batch_size},1;doc_event_doc_ad_sim_entities_log_01scaled:${batch_size},1;doc_event_doc_ad_sim_topics_log_01scaled:${batch_size},1;doc_event_entity_id:${batch_size},6;doc_event_hour_log_01scaled:${batch_size},1;doc_event_id:${batch_size},1;doc_event_publisher_id:${batch_size},1;doc_event_source_id:${batch_size},1;doc_event_topic_id:${batch_size},3;doc_id:${batch_size},1;doc_views_log_01scaled:${batch_size},1;event_country:${batch_size},1;event_country_state:${batch_size},1;event_geo_location:${batch_size},1;event_hour:${batch_size},1;event_platform:${batch_size},1;event_weekend:${batch_size},1;pop_ad_id_conf:${batch_size},1;pop_ad_id_log_01scaled:${batch_size},1;pop_advertiser_id_conf:${batch_size},1;pop_advertiser_id_log_01scaled:${batch_size},1;pop_campain_id_conf_multipl_log_01scaled:${batch_size},1;pop_campain_id_log_01scaled:${batch_size},1;pop_category_id_conf:${batch_size},1;pop_category_id_log_01scaled:${batch_size},1;pop_document_id_conf:${batch_size},1;pop_document_id_log_01scaled:${batch_size},1;pop_entity_id_conf:${batch_size},1;pop_entity_id_log_01scaled:${batch_size},1;pop_publisher_id_conf:${batch_size},1;pop_publisher_id_log_01scaled:${batch_size},1;pop_source_id_conf:${batch_size},1;pop_source_id_log_01scaled:${batch_size},1;pop_topic_id_conf:${batch_size},1;pop_topic_id_log_01scaled:${batch_size},1;traffic_source:${batch_size},1;user_doc_ad_sim_categories_conf:${batch_size},1;user_doc_ad_sim_categories_log_01scaled:${batch_size},1;user_doc_ad_sim_entities_log_01scaled:${batch_size},1;user_doc_ad_sim_topics_conf:${batch_size},1;user_doc_ad_sim_topics_log_01scaled:${batch_size},1;user_has_already_viewed_doc:${batch_size},1;user_views_log_01scaled:${batch_size},1" --out_nodes=eval_predictions:0 + ``` + +- 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** | Accuracy | +| :---------------: | :-------: | :-------------: | +| offline Inference | out brain test | 64.9% | + +## Reference +[1] https://github.com/NVIDIA/DeepLearningExamples/tree/master/TensorFlow/Recommendation/WideAndDeep