From 0519c7582ad51ff71b63e55912168b50f59aa1c8 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 10 Mar 2023 02:34:53 +0000 Subject: [PATCH 1/9] update ACL_TensorFlow/built-in/cv/Facenet_for_ACL/README.md. Signed-off-by: alex --- ACL_TensorFlow/built-in/cv/Facenet_for_ACL/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 bc0a4b3b0..92b6eeb78 100644 --- a/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/README.md +++ b/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/README.md @@ -30,8 +30,8 @@ cd Modelzoo-TensorFlow/ACL_TensorFlow/built-in/cv/Facenet_for_ACL 2. 运行预处理脚本 ``` - python3 align/align_dataset_mtcnn.py $cur_dir/lfw $dataset - python3 preprocess_data.py Path_of_Data_after_face_alignment Outpath_of_Data_after_face_alignment --use_fixed_image_standardization --lfw_batch_size 1 + python3 align/align_dataset_mtcnn.py $cur_dir/lfw $dataset --image_size 160 --margin 32 --random_order + python3 preprocess_data.py Path_of_Data_after_face_alignment Outpath_of_Data_after_face_alignment --use_fixed_image_standardization --lfw_batch_size 1 --use_flipped_images ``` -- Gitee From f1583ccc663bc757606bf79e7c4321545d396daf Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 10 Mar 2023 02:35:39 +0000 Subject: [PATCH 2/9] update ACL_TensorFlow/built-in/cv/Facenet_for_ACL/README_EN.md. Signed-off-by: alex --- ACL_TensorFlow/built-in/cv/Facenet_for_ACL/README_EN.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/README_EN.md b/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/README_EN.md index d55ebad70..5908bc4ef 100644 --- a/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/README_EN.md +++ b/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/README_EN.md @@ -30,8 +30,8 @@ cd Modelzoo-TensorFlow/ACL_TensorFlow/built-in/cv/Facenet_for_ACL 2. Executing the Preprocessing Script ``` - python3 align/align_dataset_mtcnn.py $cur_dir/lfw $dataset - python3 preprocess_data.py Path_of_Data_after_face_alignment Outpath_of_Data_after_face_alignment --use_fixed_image_standardization --lfw_batch_size 1 + python3 align/align_dataset_mtcnn.py $cur_dir/lfw $dataset --image_size 160 --margin 32 --random_order + python3 preprocess_data.py Path_of_Data_after_face_alignment Outpath_of_Data_after_face_alignment --use_fixed_image_standardization --lfw_batch_size 1 --use_flipped_images ``` -- Gitee From ae9e4da41d229050b118d1fbc9118aa0dcfb4c70 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 10 Mar 2023 02:58:49 +0000 Subject: [PATCH 3/9] update ACL_TensorFlow/built-in/cv/Facenet_for_ACL/README.md. Signed-off-by: alex --- ACL_TensorFlow/built-in/cv/Facenet_for_ACL/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 92b6eeb78..1c4624fe3 100644 --- a/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/README.md +++ b/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/README.md @@ -76,6 +76,6 @@ cd Modelzoo-TensorFlow/ACL_TensorFlow/built-in/cv/Facenet_for_ACL | model | mode | ***data*** | Embeddings Accuracy | | :---------------:| :---------------: | :---------: | :---------: | -| pb(20180402)| offline Inference | 12000 images | 99.532% | -| pb(20180408)| offline Inference | 12000 images | 98.917% | +| pb(20180402)| offline Inference | 12000 images | 99.550% | +| pb(20180408)| offline Inference | 12000 images | 99.133% | -- Gitee From 8da631c99567d5c794a6e26c28a1de21ff28ae29 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 10 Mar 2023 03:00:42 +0000 Subject: [PATCH 4/9] update ACL_TensorFlow/built-in/cv/Facenet_for_ACL/README_EN.md. Signed-off-by: alex --- ACL_TensorFlow/built-in/cv/Facenet_for_ACL/README_EN.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/README_EN.md b/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/README_EN.md index 5908bc4ef..2307ea44d 100644 --- a/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/README_EN.md +++ b/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/README_EN.md @@ -76,6 +76,6 @@ Our result were obtained by running the applicable inference script. To achieve | model | mode | ***data*** | Embeddings Accuracy | | :---------------:| :---------------: | :---------: | :---------: | -| pb(20180402)| offline Inference | 12000 images | 99.532% | -| pb(20180408)| offline Inference | 12000 images | 98.917% | +| pb(20180402)| offline Inference | 12000 images | 99.550% | +| pb(20180408)| offline Inference | 12000 images | 99.133% | -- Gitee From ba8157acb3b2549768c0c776c5616deb0aa33543 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 10 Mar 2023 03:03:51 +0000 Subject: [PATCH 5/9] update ACL_TensorFlow/built-in/cv/Facenet_for_ACL/benchmark_tf.sh. Signed-off-by: alex --- .../built-in/cv/Facenet_for_ACL/benchmark_tf.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/benchmark_tf.sh b/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/benchmark_tf.sh index e02318847..9d972dac6 100644 --- a/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/benchmark_tf.sh +++ b/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/benchmark_tf.sh @@ -19,9 +19,9 @@ preprocess() fi cd $cur_dir/script export PYTHONPATH=$cur_dir/script - python3 align/align_dataset_mtcnn.py $cur_dir/lfw $dataset + python3 align/align_dataset_mtcnn.py $cur_dir/lfw $dataset --image_size 160 --margin 32 --random_order - python3 preprocess_data.py $dataset $dataset_bin --use_fixed_image_standardization --lfw_batch_size 1 + python3 preprocess_data.py $dataset $dataset_bin --use_fixed_image_standardization --lfw_batch_size 1 --use_flipped_images } infer_test() { @@ -34,7 +34,7 @@ infer_test() #/usr/local/Ascend/atc/bin/atc --framework=3 --model=./model/facenet_tf.pb --output=./model/facenet --soc_version=Ascend310 --insert_op_conf=./facenet_tensorflow.cfg --input_format=NHWC --input_shape=input:1,160,160,3 echo "$cur_dir/Benchmark/out/benchmark --dataDir $dataset_bin/data_image_bin --om $modelPath --batchSize $batchSize --modelType $modelType --imgType $imgType --deviceId $deviceId --framework $framework --useDvpp $useDvpp > $testcase_dir/performance.log" - $cur_dir/Benchmark/out/benchmark --dataDir $dataset_bin/data_image_bin --om $modelPath --batchSize $batchSize --modelType $modelType --imgType $imgType --deviceId $deviceId --framework $framework --useDvpp $useDvpp > $testcase_dir/performance.log + $cur_dir/Benchmark/out/benchmark --dataDir $dataset_bin/data_image_bin --om $modelPath --batchSize $batchSize --modelType $modelType --imgType $imgType --deviceId $deviceId --framework $framework --useDvpp $useDvpp > $testcase_dir/performance.log } collect_result() @@ -48,7 +48,7 @@ collect_result() echo "InferencePerformance: $AiModel_time ms/batch, $AiModel_throughput images/sec" >> $testcase_dir/performance_results.log echo "InferenceTotalTime: $InferenceEngine_total_time ms" >> $testcase_dir/performance_results.log cd $cur_dir/script - python3 afterprocess.py $dataset $cur_dir/results/${modelType}/ $dataset_bin/data_label_bin/ --lfw_batch_size 1 > $testcase_dir/file.log + python3 afterprocess.py $dataset $cur_dir/results/${modelType}/ $dataset_bin/data_label_bin/ --lfw_batch_size 1 --distance_metric 1 --use_flipped_images --subtract_mean > $testcase_dir/file.log Accu=`cat $testcase_dir/file.log |grep 'Accuracy' | awk '{print $2}'` -- Gitee From 7d78ea456bf907d4d97e02d5bad239b520a66499 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 10 Mar 2023 03:08:56 +0000 Subject: [PATCH 6/9] update ACL_TensorFlow/built-in/cv/Facenet_for_ACL/script/preprocess_data.py. Signed-off-by: alex --- .../built-in/cv/Facenet_for_ACL/script/preprocess_data.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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 225e00b4c..4556e7805 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 @@ -119,11 +119,9 @@ def evaluate(sess,output_path, enqueue_op,image_paths_placeholder,labels_placeho os.makedirs(output_path +"data_label_bin/") for i in range(nrof_batches): ###########save bin ############### - print(i,image_paths[i]) feed_dict2 = {batch_size_placeholder:batch_size} - mid_name = image_paths[i].split('.')[0].split('/')[-1] - bin_image2 = output_path +"data_image_bin/" + mid_name + '_'+str(i)+'_'+".bin" - bin_label2 = output_path +"data_label_bin/" + mid_name + '_'+str(i)+'_'+".bin" + bin_image2 = os.path.join(output_path,"data_image_bin/{}.bin".format(str(i).zfill(6))) + bin_label2 = os.path.join(output_path,"data_label_bin/{}.bin".format(str(i).zfill(6))) emb, lab = sess.run([image_batch,labels],feed_dict=feed_dict2) emb.astype(np.uint8).tofile(bin_image2) lab.tofile(bin_label2) -- Gitee From 053fe2c18a6f5899170abb64aa85dc4b536f75ac Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 10 Mar 2023 03:09:39 +0000 Subject: [PATCH 7/9] update ACL_TensorFlow/built-in/cv/Facenet_for_ACL/script/afterprocess.py. Signed-off-by: alex --- .../cv/Facenet_for_ACL/script/afterprocess.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/script/afterprocess.py b/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/script/afterprocess.py index e3cc4e550..a27c11a08 100644 --- a/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/script/afterprocess.py +++ b/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/script/afterprocess.py @@ -80,23 +80,23 @@ def main(args): #feed_dict = {phase_train_placeholder: False, batch_size_placeholder: batch_size} #emb, lab = sess.run([embeddings, labels], feed_dict=feed_dict) #读取image_bin和label_bin - print(paths[i]) - names = paths[i].split('/')[-1].split('.')[-2] - print(names) - out_image_name = args.input_dir + "davinci_"+names +'_' + str(i) + "__output0.bin" - print(out_image_name) + #print(paths[i]) + #names = paths[i].split('/')[-1].split('.')[-2] + #print(names) + out_image_name = os.path.join(args.input_dir,"davinci_{}_output0.bin".format(str(i).zfill(6))) + #print(out_image_name) emb = np.fromfile(out_image_name, dtype="float32").reshape(1, 512) - out_label_name = args.label_dir +names +'_' +str(i) + "_.bin" + out_label_name = os.path.join(args.label_dir,names +"{}.bin".format(str(i).zfill(6))) lab = np.fromfile(out_label_name, dtype="int32") - print(lab) + #print(lab) ########## lab_array[lab] = lab emb_array[lab, :] = emb if i % 10 == 9: print('.', end='') sys.stdout.flush() - print('') - print(lab_array) + #print('') + #print(lab_array) embeddings = np.zeros((nrof_embeddings, embedding_size * nrof_flips)) if use_flipped_images: # Concatenate embeddings for flipped and non flipped version of the images -- Gitee From 9f73ccf8204081ea412086ba271e1f26e44cf146 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 10 Mar 2023 04:30:52 +0000 Subject: [PATCH 8/9] update ACL_TensorFlow/built-in/cv/Facenet_for_ACL/script/preprocess_data.py. Signed-off-by: alex --- .../built-in/cv/Facenet_for_ACL/script/preprocess_data.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 4556e7805..5d839bb5a 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 @@ -113,10 +113,10 @@ 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(output_path +"data_image_bin/"): - os.makedirs(output_path +"data_image_bin/") - if not os.path.exists(output_path +"data_label_bin/"): - os.makedirs(output_path +"data_label_bin/") + if not os.path.exists(os.path.join(output_path ,"data_image_bin/")): + os.makedirs(os.path.join(output_path ,"data_image_bin/")) + if not os.path.exists(os.path.join(output_path ,"data_label_bin/")): + os.makedirs(os.path.join(output_path ,"data_label_bin/")) for i in range(nrof_batches): ###########save bin ############### feed_dict2 = {batch_size_placeholder:batch_size} -- Gitee From 3a3fa38d7f62812e41bb937268ccb1f3cc4d244f Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 10 Mar 2023 04:38:11 +0000 Subject: [PATCH 9/9] update ACL_TensorFlow/built-in/cv/Facenet_for_ACL/script/afterprocess.py. Signed-off-by: alex --- .../built-in/cv/Facenet_for_ACL/script/afterprocess.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/script/afterprocess.py b/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/script/afterprocess.py index a27c11a08..ed789d608 100644 --- a/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/script/afterprocess.py +++ b/ACL_TensorFlow/built-in/cv/Facenet_for_ACL/script/afterprocess.py @@ -86,7 +86,7 @@ def main(args): out_image_name = os.path.join(args.input_dir,"davinci_{}_output0.bin".format(str(i).zfill(6))) #print(out_image_name) emb = np.fromfile(out_image_name, dtype="float32").reshape(1, 512) - out_label_name = os.path.join(args.label_dir,names +"{}.bin".format(str(i).zfill(6))) + out_label_name = os.path.join(args.label_dir,"{}.bin".format(str(i).zfill(6))) lab = np.fromfile(out_label_name, dtype="int32") #print(lab) ########## -- Gitee