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 bc0a4b3b0e05e6c607a132f9801f3f9ac041e3e9..1c4624fe3e0605d2493817cd4b8cfda21ca66478 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 ``` @@ -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% | 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 d55ebad700a99ba4d4ad76c70908546637d9ed22..2307ea44d81e6405e8a12c3339314f534a737b1f 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 ``` @@ -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% | 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 e02318847207963d20a5de7218df4c4003c7fbcd..9d972dac69730ac4e126751941232b0c106d679c 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}'` 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 e3cc4e5509523f84f6c11bfc0d92d9dd1d1ac95b..ed789d6083e81f7e4da915608792033ecb9b305c 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,"{}.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 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 225e00b4c1bca8985cc4a72abdbbec5eaf271e13..5d839bb5a818290bab2c40deaca94c0a965ec0ad 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,17 +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(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 ############### - 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)