forked from PyRetri/PyRetri
-
Notifications
You must be signed in to change notification settings - Fork 0
/
show_search_results.py
54 lines (38 loc) · 1.43 KB
/
show_search_results.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# -*- coding: utf-8 -*-
import os
import argparse
import json
import codecs
from utils.misc import save_to_csv, filter_by_keywords
def parse_args():
parser = argparse.ArgumentParser(description='A tool box for deep learning-based image retrieval')
parser.add_argument('opts', default=None, nargs=argparse.REMAINDER)
parser.add_argument('--results_json_path', '-r', default=None, type=str, help="path of the result json")
args = parser.parse_args()
return args
def show_results(results):
for i in range(len(results)):
print(results[i])
def main():
# init args
args = parse_args()
assert os.path.exists(args.results_json_path), 'the config file must be existed!'
with open(args.results_json_path, "r") as f:
results = json.load(f)
# save the search results in a csv format file.
csv_path = '/home/songrenjie/projects/RetrievalToolBox/test.csv'
save_to_csv(results, csv_path)
# define the keywords to be selected
keywords = {
'data_name': ['market'],
'pre_process_name': list(),
'model_name': list(),
'feature_map_name': list(),
'aggregator_name': list(),
'post_process_name': ['no_fea_process', 'l2_normalize', 'pca_whiten', 'pca_wo_whiten'],
}
# show search results according to the given keywords
results = filter_by_keywords(results, keywords)
show_results(results)
if __name__ == '__main__':
main()