From 556b01eb3b9ed541eedc9043ab5e04a30d51187b Mon Sep 17 00:00:00 2001 From: alexcheng88 Date: Tue, 29 Mar 2022 16:38:40 +0800 Subject: [PATCH 1/3] Add aipp cfg for mobilenetv1 --- .../built-in/cv/MobileNetv1_for_ACL/README.md | 6 +++--- .../cv/MobileNetv1_for_ACL/mobilenetv1_tf_aipp.cfg | 14 ++++++++++++++ .../scripts/mobilenetv1_preprocessing.py | 5 +++++ 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 ACL_TensorFlow/built-in/cv/MobileNetv1_for_ACL/mobilenetv1_tf_aipp.cfg diff --git a/ACL_TensorFlow/built-in/cv/MobileNetv1_for_ACL/README.md b/ACL_TensorFlow/built-in/cv/MobileNetv1_for_ACL/README.md index dfa83df91..0ea4807e0 100644 --- a/ACL_TensorFlow/built-in/cv/MobileNetv1_for_ACL/README.md +++ b/ACL_TensorFlow/built-in/cv/MobileNetv1_for_ACL/README.md @@ -20,8 +20,8 @@ Before starting, please pay attention to the following adaptation conditions. If ### 1. Clone the respository ```shell -git clone https://gitee.com/ascend/ModelZoo-TensorFlow.git -cd Modelzoo-TensorFlow/ACL_TensorFlow/built-in/cv/MobileNetv1_ID0093_for_ACL +git clone https://gitee.com/ascend/modelzoo.git +cd modelzoo/built-in/ACL_TensorFlow/Official/cv/MobileNetv1_ID0093_for_ACL ``` ### 2. Download and preprocess the dataset @@ -57,7 +57,7 @@ The jpegs pictures will be preprocessed to bin fils. - convert pb to om ``` - atc --model=mobilenetv1_tf.pb --framework=3 --output=mobilenetv1_tf_1batch --output_type=FP32 --soc_version=Ascend310 --input_shape="input:1,224,224,3" --log=info + atc --model=mobilenetv1_tf.pb --framework=3 --output=mobilenetv1_tf_1batch --output_type=FP32 --soc_version=Ascend310 --input_shape="input:1,224,224,3" --log=info --insert_op_conf=mobilenetv1_tf_aipp.cfg --enable_small_channle=1 ``` - Build the program diff --git a/ACL_TensorFlow/built-in/cv/MobileNetv1_for_ACL/mobilenetv1_tf_aipp.cfg b/ACL_TensorFlow/built-in/cv/MobileNetv1_for_ACL/mobilenetv1_tf_aipp.cfg new file mode 100644 index 000000000..e9faee805 --- /dev/null +++ b/ACL_TensorFlow/built-in/cv/MobileNetv1_for_ACL/mobilenetv1_tf_aipp.cfg @@ -0,0 +1,14 @@ +aipp_op { + aipp_mode: static + input_format : RGB888_U8 + src_image_size_w : 224 + src_image_size_h : 224 + mean_chn_0 : 128 + mean_chn_1 : 128 + mean_chn_2 : 128 + var_reci_chn_0 : 0.00781 + var_reci_chn_1 : 0.00781 + var_reci_chn_2 : 0.00781 +} + + diff --git a/ACL_TensorFlow/built-in/cv/MobileNetv1_for_ACL/scripts/mobilenetv1_preprocessing.py b/ACL_TensorFlow/built-in/cv/MobileNetv1_for_ACL/scripts/mobilenetv1_preprocessing.py index aa683b57c..1399b4dd8 100644 --- a/ACL_TensorFlow/built-in/cv/MobileNetv1_for_ACL/scripts/mobilenetv1_preprocessing.py +++ b/ACL_TensorFlow/built-in/cv/MobileNetv1_for_ACL/scripts/mobilenetv1_preprocessing.py @@ -372,6 +372,8 @@ def preprocess(src_path, save_path): in_files = os.listdir(src_path) in_files.sort() resize_shape = [224, 224, 3] + sqz_mean = np.array([127.5, 127.5, 127.5], np.float32) + img_std = np.array([[0.5*255, 0.5*255, 0.5*255]], np.float32) if os.path.isdir(save_path): shutil.rmtree(save_path) os.makedirs(save_path) @@ -387,6 +389,9 @@ def preprocess(src_path, save_path): is_training=False, use_grayscale=False) img = img.eval() + img = img * img_std + img = img + sqz_mean + img = img.astype(np.uint8, copy=False) img.tofile(os.path.join(save_path, file.split('.')[0]+".bin")) tf.reset_default_graph() -- Gitee From 9c7aed8093876f969376270c1dd9c5930b50c5ff Mon Sep 17 00:00:00 2001 From: alexcheng88 Date: Tue, 29 Mar 2022 16:42:03 +0800 Subject: [PATCH 2/3] Add aipp cfg --- ACL_TensorFlow/built-in/cv/MobileNetv1_for_ACL/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ACL_TensorFlow/built-in/cv/MobileNetv1_for_ACL/README.md b/ACL_TensorFlow/built-in/cv/MobileNetv1_for_ACL/README.md index 0ea4807e0..b27a336de 100644 --- a/ACL_TensorFlow/built-in/cv/MobileNetv1_for_ACL/README.md +++ b/ACL_TensorFlow/built-in/cv/MobileNetv1_for_ACL/README.md @@ -21,7 +21,7 @@ Before starting, please pay attention to the following adaptation conditions. If ```shell git clone https://gitee.com/ascend/modelzoo.git -cd modelzoo/built-in/ACL_TensorFlow/Official/cv/MobileNetv1_ID0093_for_ACL +cd Modelzoo-TensorFlow/ACL_TensorFlow/built-in/cv/MobileNetv1_for_ACL ``` ### 2. Download and preprocess the dataset -- Gitee From 757b56d30632d2831282999160a67504993f28f2 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 29 Mar 2022 08:45:54 +0000 Subject: [PATCH 3/3] update ACL_TensorFlow/built-in/cv/MobileNetv1_for_ACL/README.md. --- ACL_TensorFlow/built-in/cv/MobileNetv1_for_ACL/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ACL_TensorFlow/built-in/cv/MobileNetv1_for_ACL/README.md b/ACL_TensorFlow/built-in/cv/MobileNetv1_for_ACL/README.md index b27a336de..48aecc6bc 100644 --- a/ACL_TensorFlow/built-in/cv/MobileNetv1_for_ACL/README.md +++ b/ACL_TensorFlow/built-in/cv/MobileNetv1_for_ACL/README.md @@ -20,7 +20,7 @@ Before starting, please pay attention to the following adaptation conditions. If ### 1. Clone the respository ```shell -git clone https://gitee.com/ascend/modelzoo.git +git clone https://gitee.com/ascend/ModelZoo-TensorFlow.git cd Modelzoo-TensorFlow/ACL_TensorFlow/built-in/cv/MobileNetv1_for_ACL ``` -- Gitee