Skip to content

Commit

Permalink
Updated README and added check for results folder, create folder if d…
Browse files Browse the repository at this point in the history
…oesn't exist
  • Loading branch information
StephenHausler committed May 21, 2021
1 parent 44ebea5 commit 051127d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ python feature_match.py \
--index_file_path=pitts30k_imageNames_index.txt \
--query_input_features_dir patchnetvlad/output_features/pitts30k_query \
--index_input_features_dir patchnetvlad/output_features/pitts30k_index \
--ground_truth_path dataset_gt_files/pitts30k_test.npz \
--result_save_folder results/pitts30k
--ground_truth_path patchnetvlad/dataset_gt_files/pitts30k_test.npz \
--result_save_folder patchnetvlad/results/pitts30k
```

Note that providing `ground_truth_path` is optional.
Expand Down
5 changes: 5 additions & 0 deletions feature_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import argparse
import configparser
from os.path import join
from os.path import exists
import torch
import numpy as np
import faiss
Expand Down Expand Up @@ -70,6 +71,8 @@ def compute_recall(gt, predictions, numQ, n_values, recall_str=''):


def write_kapture_output(opt, eval_set, predictions, outfile_name):
if not exists(opt.result_save_folder):
os.mkdir(opt.result_save_folder)
with open(join(opt.result_save_folder, outfile_name), 'w') as kap_out:
kap_out.write('# kapture format: 1.0\n')
kap_out.write('# query_image, map_image\n')
Expand All @@ -82,6 +85,8 @@ def write_kapture_output(opt, eval_set, predictions, outfile_name):


def write_recalls_output(opt, recalls_netvlad, recalls_patchnetvlad, n_values):
if not exists(opt.result_save_folder):
os.mkdir(opt.result_save_folder)
with open(join(opt.result_save_folder, 'recalls.txt'), 'w') as rec_out:
for n in n_values:
rec_out.write("Recall {}@{}: {:.4f}\n".format('NetVLAD', n, recalls_netvlad[n]))
Expand Down

0 comments on commit 051127d

Please sign in to comment.