-
Notifications
You must be signed in to change notification settings - Fork 8
/
table2.py
27 lines (20 loc) · 956 Bytes
/
table2.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
from utils import chair
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--annotation_path", type=str, default='coco/annotations')
args = parser.parse_args()
sentence_template = 'generated_sentences/%s.json'
table2_tags = [('FC', 'fc-robust_beam5_test'),
('att2in', 'att2in-robust_beam5_test'),
('TD', 'td-robust_beam5_test'),
('NBT', 'nbt-robust_beam5_test')]
_, imids, _ = chair.load_generated_captions(sentence_template %table2_tags[0][1])
evaluator = chair.CHAIR(imids, args.annotation_path)
evaluator.get_annotations()
print "\t\tCross Entropy\t\t\t"
print "Model\tSPICE\tMETEOR\tCIDEr\tCHAIRs\tCHAIRi"
for tag in table2_tags:
cap_dict = evaluator.compute_chair(sentence_template %tag[1])
metric_string = chair.print_metrics(cap_dict, True)
chair.save_hallucinated_words(sentence_template %tag[1], cap_dict)
print "%s\t%s\t" %(tag[0], metric_string)