From d02bb2332c073aadb815be17ef8f63164f99d51f Mon Sep 17 00:00:00 2001 From: Ting-Jun Wang Date: Thu, 9 Nov 2023 20:34:22 +0800 Subject: [PATCH] fix: adversarial instruction summmary with REVERIE format --- adversarial_summary.py | 45 ++++++++++++++++++++++++++++++++++++++++++ run/agent.bash | 24 ++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 adversarial_summary.py create mode 100644 run/agent.bash diff --git a/adversarial_summary.py b/adversarial_summary.py new file mode 100644 index 0000000..c1e0eab --- /dev/null +++ b/adversarial_summary.py @@ -0,0 +1,45 @@ +import json +import os +import re + +def remove_non_ascii(text): + return re.sub(r'[^\x00-\x7F]', ' ', text) + + + +for file in ['train', 'val_unseen', 'val_seen', 'test']: + 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['id'] + if instruction_id not in result: + result[instruction_id] = { + 'distance': float(i['distance']), + 'ix': int(i['ix']), + 'scan': i['scan'], + 'id': i['id'], + 'instructions_l': i['instructions_l'], + 'path_id': int(i['path_id']), + 'objId': i['objId'], + 'path': i['path'], + 'heading': float(i['heading']), + 'instructions': [ remove_non_ascii(i['instruction'])], + 'found': [ i['found'] ], + } + else: + result[instruction_id]['instructions'].append(remove_non_ascii(i['instruction'])) + result[instruction_id]['found'].append( i['found'] ) + + output = [] + for k, item in result.items(): + output.append(item) + else: + output = [] + + with open('data/adversarial/REVERIE_{}.json'.format(file), 'w') as fp: + json.dump(output, fp) diff --git a/run/agent.bash b/run/agent.bash new file mode 100644 index 0000000..143f74e --- /dev/null +++ b/run/agent.bash @@ -0,0 +1,24 @@ +name=reverie-v4.2.1 +flag="--description reverie-v4.2.1 + + --train listener + --features places365 + + --test_only 0 + --maxAction 15 + --maxInput 50 + --batchSize 4 + --feedback sample + --lr 1e-5 + --iters 200000 + --optim adamW + + --attn soft + --mlWeight 0.20 + --featdropout 0.4 + --angleFeatSize 128 + --subout max + --dropout 0.5" + +mkdir -p snap/$name +CUDA_VISIBLE_DEVICES=0 python3 r2r_src/train.py $flag --name $name