-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheval.py
More file actions
36 lines (29 loc) · 1.14 KB
/
Copy patheval.py
File metadata and controls
36 lines (29 loc) · 1.14 KB
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
import json
from argparse import ArgumentParser
if __name__ == "__main__":
parser = ArgumentParser()
parser.add_argument("--ground_truth",
type = str,
default = "./data/circo/annotations/test.json")
parser.add_argument("--predict",
type = str,
default = "./output/circo_large/circo_results.json")
args = parser.parse_args()
# Read json file circo/annotations/test.json
with open(args.ground_truth, 'r') as file:
data = json.load(file)
# New data from beforehand data with the keys as the id and the values as the reference_img_id
new_data = {}
for i in data:
new_data[i['id']] = i['reference_img_id']
# Read json file circo_base/circo_results.json
with open(args.predict, 'r') as file:
results = json.load(file)
# Change the keys in results to int
results = {int(k): v for k, v in results.items()}
# Check if the reference_img_id is the same as the corresponding list in the results
correct = 0
for i in new_data.keys():
if new_data[i] in results[i]:
correct += 1
print(correct/len(new_data))