-
Notifications
You must be signed in to change notification settings - Fork 2
/
system_stats.py
35 lines (27 loc) · 1.12 KB
/
system_stats.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
from methods import sentences_from_file, system_stats, load_json, save_json, sentence_stats
train_data = load_json('./Data/COCO/Processed/tokenized_train2014.json')
train_descriptions = [entry['caption'] for entry in train_data['annotations']]
for folder in ['Dai-et-al-2017',
'Liu-et-al-2017',
'Mun-et-al-2017',
'Shetty-et-al-2016',
'Shetty-et-al-2017',
'Tavakoli-et-al-2017',
'Vinyals-et-al-2017',
'Wu-et-al-2016',
'Zhou-et-al-2017']:
print('Processing:', folder)
# Define source and target.
base = './Data/Systems/'
source = base + folder + '/Val/annotated.json'
target = base + folder + '/Val/stats.json'
# Load data.
sentences = sentences_from_file(source)
# Process data.
stats = system_stats(sentences)
# Get raw descriptions.
gen_descriptions = [entry['caption'] for entry in load_json(source)]
extra_stats = sentence_stats(train_descriptions, gen_descriptions)
stats.update(extra_stats)
# Save data.
save_json(stats, target)