Skip to content
Snippets Groups Projects
Commit aaa62dc8 authored by tgupta6's avatar tgupta6
Browse files

count_objects_in_vqa

parent 15aa9fc0
No related branches found
No related tags found
No related merge requests found
import ujson
import nltk
import os
import constants
if __name__=='__main__':
with open(constants.vqa_train_anno) as file:
vqa_train_anno = ujson.load(file)
with open(constants.vqa_train_subset_qids) as file:
train_subset_qids = ujson.load(file)
with open(constants.object_labels_json) as file:
object_labels = ujson.load(file)
freq = dict()
for label in object_labels.keys():
freq[label] = 0
for qid in train_subset_qids:
for noun in vqa_train_anno[qid]['question_nouns']:
if noun in freq:
freq[noun] += 1
break
for noun in vqa_train_anno[qid]['multiple_choice_answer'].split():
if noun in freq:
freq[noun] += 1
break
freq_filename = os.path.join(
'/home/ssd/VisualGenome/restructured',
'object_label_freq_in_vqa_train_subset.json')
with open(freq_filename,'w') as file:
ujson.dump(freq, file)
print freq
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment