diff --git a/ACL_TensorFlow/built-in/cv/Resnet18_for_ACL/README.md b/ACL_TensorFlow/built-in/cv/Resnet18_for_ACL/README.md index 2fa57cf9cc7d23df49f9ebdb582f93a62954fe3d..1d3489f2bfd1de22728b980c97994d17a2bfa477 100644 --- a/ACL_TensorFlow/built-in/cv/Resnet18_for_ACL/README.md +++ b/ACL_TensorFlow/built-in/cv/Resnet18_for_ACL/README.md @@ -66,7 +66,7 @@ The jpegs pictures will be preprocessed to bin fils. [pb download link](https://modelzoo-train-atc.obs.cn-north-4.myhuaweicloud.com/003_Atc_Models/modelzoo/resnet18_tf.pb) ``` - atc --model=resnet18_tf.pb --framework=3 --output=resnet18_tf_1batch --output_type=FP32 --soc_version=Ascend310 --input_shape="test_inputs:1,64,64,3" --log=info + atc --model=resnet18_tf.pb --framework=3 --output=resnet18_tf_1batch --output_type=FP32 --soc_version=Ascend310 --input_shape="test_inputs:1,64,64,3" --log=info --insert_op_conf=resnet18_tf_aipp.cfg --enable_small_channel=1 ``` - Build the program diff --git a/ACL_TensorFlow/built-in/cv/Resnet18_for_ACL/resnet18_tf_aipp.cfg b/ACL_TensorFlow/built-in/cv/Resnet18_for_ACL/resnet18_tf_aipp.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2e142c2b352a1e1947857b729b48033993de7de9 --- /dev/null +++ b/ACL_TensorFlow/built-in/cv/Resnet18_for_ACL/resnet18_tf_aipp.cfg @@ -0,0 +1,14 @@ +aipp_op { + aipp_mode: static + input_format : RGB888_U8 + src_image_size_w : 64 + src_image_size_h : 64 + mean_chn_0 : 112 + mean_chn_1 : 112 + mean_chn_2 : 112 + var_reci_chn_0 : 0.014285 + var_reci_chn_1 : 0.014285 + var_reci_chn_2 : 0.014285 +} + + diff --git a/ACL_TensorFlow/built-in/cv/Resnet18_for_ACL/scripts/imagenet_tiny_preprocessing.py b/ACL_TensorFlow/built-in/cv/Resnet18_for_ACL/scripts/imagenet_tiny_preprocessing.py index ed308f480e1f57ea64a9845d46298a0b6f50f7fe..99c00393dc881bd271073ec8aea9ce595225d59b 100644 --- a/ACL_TensorFlow/built-in/cv/Resnet18_for_ACL/scripts/imagenet_tiny_preprocessing.py +++ b/ACL_TensorFlow/built-in/cv/Resnet18_for_ACL/scripts/imagenet_tiny_preprocessing.py @@ -180,7 +180,8 @@ if __name__ == "__main__": output_dir = "./input_bins/" if not os.path.isdir(output_dir): os.mkdir(output_dir) - + sqz_mean = np.array([112, 112, 112], np.float32) + img_std = np.array([[70, 70, 70]], np.float32) train_x, train_y, test_x, test_y = load_tiny() with open('./imagenet_tiny_label.txt','w') as f: @@ -188,6 +189,9 @@ if __name__ == "__main__": print('start to process image: {}'.format(i)) index = i image = test_x[i] + image = image * img_std + image = image + sqz_mean + image = image.astype(np.uint8, copy=False) image.tofile(os.path.join(output_dir,'val_{}.bin'.format(index))) label = test_y[i] f.write('val_{}.JPEG {}\n'.format(index, np.argmax(label))) diff --git a/ACL_TensorFlow/built-in/cv/Resnet34_for_ACL/README.md b/ACL_TensorFlow/built-in/cv/Resnet34_for_ACL/README.md index 22131189dc8b6e525bf502d03fa33e28d8216763..2e3d741d5503bd19e71b33478866d1137fbc6aa8 100644 --- a/ACL_TensorFlow/built-in/cv/Resnet34_for_ACL/README.md +++ b/ACL_TensorFlow/built-in/cv/Resnet34_for_ACL/README.md @@ -66,7 +66,7 @@ The jpegs pictures will be preprocessed to bin fils. [pb download link](https://modelzoo-train-atc.obs.cn-north-4.myhuaweicloud.com/003_Atc_Models/modelzoo/resnet34_tf.pb) ``` - atc --model=resnet34_tf.pb --framework=3 --output=resnet34_tf_1batch --output_type=FP32 --soc_version=Ascend310 --input_shape="test_inputs:1,64,64,3" --log=info + atc --model=resnet34_tf.pb --framework=3 --output=resnet34_tf_1batch --output_type=FP32 --soc_version=Ascend310 --input_shape="test_inputs:1,64,64,3" --log=info --insert_op_conf=resnet34_tf_aipp.cfg --enable_small_channel=1 ``` - Build the program diff --git a/ACL_TensorFlow/built-in/cv/Resnet34_for_ACL/resnet34_tf_aipp.cfg b/ACL_TensorFlow/built-in/cv/Resnet34_for_ACL/resnet34_tf_aipp.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2e142c2b352a1e1947857b729b48033993de7de9 --- /dev/null +++ b/ACL_TensorFlow/built-in/cv/Resnet34_for_ACL/resnet34_tf_aipp.cfg @@ -0,0 +1,14 @@ +aipp_op { + aipp_mode: static + input_format : RGB888_U8 + src_image_size_w : 64 + src_image_size_h : 64 + mean_chn_0 : 112 + mean_chn_1 : 112 + mean_chn_2 : 112 + var_reci_chn_0 : 0.014285 + var_reci_chn_1 : 0.014285 + var_reci_chn_2 : 0.014285 +} + + diff --git a/ACL_TensorFlow/built-in/cv/Resnet34_for_ACL/scripts/imagenet_tiny_preprocessing.py b/ACL_TensorFlow/built-in/cv/Resnet34_for_ACL/scripts/imagenet_tiny_preprocessing.py index ed308f480e1f57ea64a9845d46298a0b6f50f7fe..99c00393dc881bd271073ec8aea9ce595225d59b 100644 --- a/ACL_TensorFlow/built-in/cv/Resnet34_for_ACL/scripts/imagenet_tiny_preprocessing.py +++ b/ACL_TensorFlow/built-in/cv/Resnet34_for_ACL/scripts/imagenet_tiny_preprocessing.py @@ -180,7 +180,8 @@ if __name__ == "__main__": output_dir = "./input_bins/" if not os.path.isdir(output_dir): os.mkdir(output_dir) - + sqz_mean = np.array([112, 112, 112], np.float32) + img_std = np.array([[70, 70, 70]], np.float32) train_x, train_y, test_x, test_y = load_tiny() with open('./imagenet_tiny_label.txt','w') as f: @@ -188,6 +189,9 @@ if __name__ == "__main__": print('start to process image: {}'.format(i)) index = i image = test_x[i] + image = image * img_std + image = image + sqz_mean + image = image.astype(np.uint8, copy=False) image.tofile(os.path.join(output_dir,'val_{}.bin'.format(index))) label = test_y[i] f.write('val_{}.JPEG {}\n'.format(index, np.argmax(label)))