diff --git a/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/README.md b/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/README.md index 4b581197385b3ff6f90f2d11107275d2ccf33b53..348b9bcf73d500373cc18d4845e1cdda9f1e3320 100644 --- a/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/README.md +++ b/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/README.md @@ -50,7 +50,28 @@ python3 pb_to_pbtxt.py 20180408-102900.pb 1.删除第一个节点batch_size -2.第二个节点phase_train的op修改为const +2.第二个节点phase_train修改为: +node { + name: "phase_train" + op: "Const" + attr { + key: "dtype" + value { + type: DT_BOOL + } + } + attr { + key: "value" + value { + tensor { + dtype: DT_BOOL + tensor_shape { + } + bool_val: false + } + } + } +} 3.删除第三个节点batch_join/fifo_queue @@ -134,11 +155,11 @@ pip3 install amct_tensorflow-2.16.8-py3-none-linux_x86_64.tar.gz 2.重新导出一份原始数据集用于量化 -python3 pre_process_data_forquant.py Path_of_Data_after_face_alignment Outpath_of_Data_after_face_alignment --use_fixed_image_standardization --lfw_batch_size 1 --use_flipped_images +python3 pre_process_data_fp32.py Path_of_Data_after_face_alignment Outpath_of_Data_after_face_alignment --use_fixed_image_standardization --lfw_batch_size 1 --use_flipped_images 3.量化模型 -python3 amct_python.py ./facenet_20180408-102900.pb ./datasets_bin/data_image_bin_original ./quant +python3 amct_python.py ./facenet_20180408-102900.pb ./datasets_bin/data_image_bin_fp32 ./quant 4.pb转om diff --git a/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/script/preprocess_data.py b/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/script/preprocess_data.py index 5d839bb5a818290bab2c40deaca94c0a965ec0ad..0eedf0c7eed64693aee1ddcc94192fabcad8d6c7 100644 --- a/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/script/preprocess_data.py +++ b/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/script/preprocess_data.py @@ -149,7 +149,7 @@ def main(args): control_placeholder = tf.compat.v1.placeholder(tf.int32, shape=(None, 1), name='control') phase_train_placeholder = tf.compat.v1.placeholder(tf.bool, name='phase_train') - nrof_preprocess_threads = 4 + nrof_preprocess_threads = 1 image_size = (args.image_size, args.image_size) eval_input_queue = data_flow_ops.FIFOQueue(capacity=2000000, dtypes=[tf.string, tf.int32, tf.int32], diff --git a/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/script/preprocess_data_forquant.py b/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/script/preprocess_data_fp32.py similarity index 94% rename from ACL_TensorFlow/built-in/cv/Facenet_for_ACL/script/preprocess_data_forquant.py rename to ACL_TensorFlow/built-in/cv/Facenet_for_ACL/script/preprocess_data_fp32.py index 8563095c50cc224d5390af262ca4e61253925334..5c9b8be2bb5f4542cc8d026f8f98fdd5fa10ba7d 100644 --- a/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/script/preprocess_data_forquant.py +++ b/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/script/preprocess_data_fp32.py @@ -113,15 +113,15 @@ def evaluate(sess,output_path, enqueue_op,image_paths_placeholder,labels_placeho assert nrof_images % batch_size == 0, 'The number of LFW images must be an integer multiple of the LFW batch size' nrof_batches = nrof_images // batch_size print("#############nrof_batches",nrof_batches) - if not os.path.exists(os.path.join(output_path ,"data_image_bin_original/")): - os.makedirs(os.path.join(output_path ,"data_image_bin_original/")) - if not os.path.exists(os.path.join(output_path ,"data_label_bin_original/")): - os.makedirs(os.path.join(output_path ,"data_label_bin_original/")) + if not os.path.exists(os.path.join(output_path ,"data_image_bin_fp32/")): + os.makedirs(os.path.join(output_path ,"data_image_bin_fp32/")) + if not os.path.exists(os.path.join(output_path ,"data_label_bin_fp32/")): + os.makedirs(os.path.join(output_path ,"data_label_bin_fp32/")) for i in range(nrof_batches): ###########save bin ############### feed_dict2 = {batch_size_placeholder:batch_size} - bin_image2 = os.path.join(output_path,"data_image_bin_original/{}.bin".format(str(i).zfill(6))) - bin_label2 = os.path.join(output_path,"data_label_bin_original/{}.bin".format(str(i).zfill(6))) + bin_image2 = os.path.join(output_path,"data_image_bin_fp32/{}.bin".format(str(i).zfill(6))) + bin_label2 = os.path.join(output_path,"data_label_bin_fp32/{}.bin".format(str(i).zfill(6))) emb, lab = sess.run([image_batch,labels],feed_dict=feed_dict2) #emb.astype(np.uint8).tofile(bin_image2) emb.tofile(bin_image2) @@ -150,7 +150,7 @@ def main(args): control_placeholder = tf.compat.v1.placeholder(tf.int32, shape=(None, 1), name='control') phase_train_placeholder = tf.compat.v1.placeholder(tf.bool, name='phase_train') - nrof_preprocess_threads = 4 + nrof_preprocess_threads = 1 image_size = (args.image_size, args.image_size) eval_input_queue = data_flow_ops.FIFOQueue(capacity=2000000, dtypes=[tf.string, tf.int32, tf.int32],