feat: REVERIE to R2R format
This commit is contained in:
parent
ab5010d32d
commit
a5db597de5
37
adversarial_summary.py
Normal file
37
adversarial_summary.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
|
for file in ['train', 'val_unseen', 'val_seen', 'train_seen', 'test', 'val_train_seen']:
|
||||||
|
print(file)
|
||||||
|
if os.path.isfile('data/adversarial/reverie_{}_fnf.json'.format(file)):
|
||||||
|
with open('data/adversarial/reverie_{}_fnf.json'.format(file)) as fp:
|
||||||
|
data = json.load(fp)
|
||||||
|
|
||||||
|
|
||||||
|
result = {}
|
||||||
|
for i in data:
|
||||||
|
instruction_id = i['path_id']
|
||||||
|
if instruction_id not in result:
|
||||||
|
result[instruction_id] = {
|
||||||
|
'distance': float(i['distance']),
|
||||||
|
'scan': i['scan'],
|
||||||
|
'path_id': int(i['path_id']),
|
||||||
|
'path': i['path'],
|
||||||
|
'heading': float(i['heading']),
|
||||||
|
'instructions': [ i['instruction'] ],
|
||||||
|
'swap': [ True if i['found'] else False ],
|
||||||
|
'id': i['id'],
|
||||||
|
'objId': i['objId']
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
result[instruction_id]['instructions'].append(i['instruction'])
|
||||||
|
result[instruction_id]['swap'].append( True if i['found'] else False)
|
||||||
|
|
||||||
|
output = []
|
||||||
|
for k, item in result.items():
|
||||||
|
output.append(item)
|
||||||
|
else:
|
||||||
|
output = []
|
||||||
|
|
||||||
|
with open('data/adversarial/R2R_{}.json'.format(file), 'w') as fp:
|
||||||
|
json.dump(output, fp)
|
||||||
Loading…
Reference in New Issue
Block a user