From 42c94e31090ffc4701d6986d819adfbc6206f7cf Mon Sep 17 00:00:00 2001 From: anjus Date: Wed, 4 Dec 2024 10:11:21 -0500 Subject: [PATCH] Added comments to evaluation scripts --- benchmark_testing/README.md | 1 + benchmark_testing/run_bulk_upload.sh | 7 +++++-- benchmark_testing/run_face_find_accuracy.sh | 8 ++++++-- benchmark_testing/run_face_find_time.sh | 5 ++++- benchmark_testing/test_data_metrics.py | 6 +++++- benchmark_testing/test_data_setup.py | 19 +++++++++++++++---- 6 files changed, 36 insertions(+), 10 deletions(-) diff --git a/benchmark_testing/README.md b/benchmark_testing/README.md index 247388e..99ed27e 100644 --- a/benchmark_testing/README.md +++ b/benchmark_testing/README.md @@ -40,6 +40,7 @@ Note: One such pair of sample database and queries directories have already been > [!NOTE]\ > *All the code below should be executed from the `benchmark_testing` directory.* + > Make sure to execute all .sh files using git bash. 2. **Run Test Data Setup (Optional)** - Replace the directory names in the `test_data_setup.py` file with appropriate directory locations. diff --git a/benchmark_testing/run_bulk_upload.sh b/benchmark_testing/run_bulk_upload.sh index ce4fac6..ba5dc2d 100644 --- a/benchmark_testing/run_bulk_upload.sh +++ b/benchmark_testing/run_bulk_upload.sh @@ -13,8 +13,11 @@ sleep 10 # Start timer start_time=$(date +%s) -# Run your functions or any additional Python commands here -python ../src/Sample_Client/sample_bulk_upload_client.py --directory_paths "\path\to\input\directory" --database_name "sample_db" +# Call client script to upload images from to database (the code currently only accepts one directory at a time) +python ../src/Sample_Client/sample_bulk_upload_client.py --directory_paths "\\path\\to\\sample_database\\directory" --database_name "sample_db" + +# Sample directory path +# "\\LFWdataset\\sample_database" # Calculate total time taken end_time=$(date +%s) diff --git a/benchmark_testing/run_face_find_accuracy.sh b/benchmark_testing/run_face_find_accuracy.sh index 91b4158..fee03de 100644 --- a/benchmark_testing/run_face_find_accuracy.sh +++ b/benchmark_testing/run_face_find_accuracy.sh @@ -14,8 +14,12 @@ sleep 10 start_time=$(date +%s) # Define the directory containing the files and the output CSV file -input_directory="\path\to\input\directory" -output_csv="\path\to\output\csv" +input_directory="\\path\\to\\input\\directory" # Path to directory of query images +output_csv="\\path\\to\\output\\csv" # Path to csv file containing top-n matches + +# Sample directory path +# input_directory = "\\LFWdataset\\sample_queries" +# output_csv = "\\LFWdataset\\output.csv" # Initialize the CSV file with headers echo "filename,result" > "$output_csv" diff --git a/benchmark_testing/run_face_find_time.sh b/benchmark_testing/run_face_find_time.sh index 8218a64..6fb8012 100644 --- a/benchmark_testing/run_face_find_time.sh +++ b/benchmark_testing/run_face_find_time.sh @@ -13,9 +13,12 @@ sleep 10 # Start timer start_time=$(date +%s) -# Run your functions or any additional Python commands here +# Call client script to find match for an image (code currently only accepts one file_path at a time) python ../src/Sample_Client/sample_find_face_client.py --file_paths "\path\to\image" --database_name "sample_db" +# Sample file path +# "\\LFWdataset\\sample_queries\\image.jpg" + # Calculate total time taken end_time=$(date +%s) total_time=$((end_time - start_time)) diff --git a/benchmark_testing/test_data_metrics.py b/benchmark_testing/test_data_metrics.py index 2deee28..552e3ea 100644 --- a/benchmark_testing/test_data_metrics.py +++ b/benchmark_testing/test_data_metrics.py @@ -4,7 +4,11 @@ from sklearn.metrics import accuracy_score # Load the CSV file -file_path = "path\\to\\output\\csv" +file_path = "path\\to\\output\\csv" # Path to csv file containing top-n matches + +# Sample csv path +# file_path = "\\LFWdataset\\output.csv" + data = pd.read_csv(file_path) # Extract ground truth names (base names without numeric suffixes) diff --git a/benchmark_testing/test_data_setup.py b/benchmark_testing/test_data_setup.py index a05d7fa..fa084e8 100644 --- a/benchmark_testing/test_data_setup.py +++ b/benchmark_testing/test_data_setup.py @@ -47,10 +47,21 @@ def count_files(directory): ) -# Specify the root directory you want to start from -root_directory = "\\path\\to\\root\\directory" -upload_directory = "\\path\\to\\upload\\directory" -test_directory = "\\path\\to\\test\\directory" +# Edit the following paths to match your system's directories + +root_directory = "\\path\\to\\root\\directory" # Original dataset directory +upload_directory = "\\path\\to\\upload\\directory" # Directory where images to be uploaded to database will be stored +test_directory = ( + "\\path\\to\\test\\directory" # Directory where query images will be stored +) + +""" +Sample directories +root_directory = "\\LFWdataset\\lfw" +upload_directory = "\\LFWdataset\\sample_database" +test_directory = "\\LFWdataset\\sample_queries" +""" + process_directory(root_directory, upload_directory, test_directory) # Print the number of files in the test and verify directories