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 dfa83df9155133b7111fd6236d773b6fe1afa8cc..48aecc6bc00b4e3b7bc4f486063b76fb8b77b20f 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-TensorFlow.git -cd Modelzoo-TensorFlow/ACL_TensorFlow/built-in/cv/MobileNetv1_ID0093_for_ACL +cd Modelzoo-TensorFlow/ACL_TensorFlow/built-in/cv/MobileNetv1_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 0000000000000000000000000000000000000000..e9faee8059dbb043377791dde9216bfe3936ec01 --- /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 aa683b57c8724fd97a462d9036fa032b84181e05..1399b4dd8f6e73729fc5f73e50ff9f76c00444e8 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()