dariuscty's picture
Restore RSI-Anything inference resources and LabHorizon dataset
672ecc3 verified
Raw History Blame Contribute Delete
1.37 kB
import argparse,json,sys
from pathlib import Path
ROOT=Path(__file__).resolve().parent
def main():
p=argparse.ArgumentParser(description='MiniWoB click-checkboxes inference with the final RSI policy and GUI world model')
p.add_argument('--output',type=Path,required=True)
p.add_argument('--seeds',type=int,nargs='+',help='Defaults to the 100 archived final test seeds')
p.add_argument('--controller',choices=['selected','world'],default='selected')
a=p.parse_args()
sys.path.insert(0,str(ROOT/'src'))
from policy_service import PolicyEngine
import experiment
engine=PolicyEngine()
experiment.rank=lambda obs,adapter=None:engine.rank({k:obs[k] for k in ['instruction','elements','remaining_actions']},adapter)
model=None
controller=json.loads((ROOT/'controller_selected.json').read_text())
if a.controller=='world':
from gui_world import GUIWorld
model=GUIWorld.load_gui(ROOT/'checkpoints/final/world')
controller=json.loads((ROOT/'controller_world.json').read_text())
seeds=a.seeds if a.seeds is not None else json.loads((ROOT/'protocol.json').read_text())['splits']['rsi_test']
outcomes=experiment.rollout(seeds,a.output,'hybrid',model,ROOT/'checkpoints/final/policy',controller)
print(json.dumps(experiment.summary(outcomes),ensure_ascii=False))
if __name__=='__main__':main()