Download gui_interaction/infer.py from Gen-Verse/RSI-Anything: direct link, hf CLI and curl.
- Browser
- Download file 1.37 kB
-
https://huggingface.co/datasets/Gen-Verse/RSI-Anything/resolve/main/gui_interaction/infer.py
- Command line
-
hf download hf://datasets/Gen-Verse/RSI-Anything/gui_interaction/infer.py
-
curl -L -o infer.py https://huggingface.co/datasets/Gen-Verse/RSI-Anything/resolve/main/gui_interaction/infer.py
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() | |