Download load_example.py from priyanshu-harshbodhi/nmr-workbench-large-v2: direct link, hf CLI and curl.
- Browser
- Download file 1.37 kB
-
https://huggingface.co/datasets/priyanshu-harshbodhi/nmr-workbench-large-v2/resolve/main/load_example.py
- Command line
-
hf download hf://datasets/priyanshu-harshbodhi/nmr-workbench-large-v2/load_example.py
-
curl -L -o load_example.py https://huggingface.co/datasets/priyanshu-harshbodhi/nmr-workbench-large-v2/resolve/main/load_example.py
1.37 kB
| """Offline loader and model-neutral conversation adapter; no model download.""" | |
| import json | |
| from pathlib import Path | |
| from datasets import load_dataset | |
| def to_messages(row): | |
| instructions = ('Operate NMRium from the screenshot. Output one JSON action. ' | |
| 'Allowed types: click, drag, scroll, key, text, wait, finish. ' | |
| 'Coordinates are viewport pixels, width 1440, height 1000, scale 1. ' | |
| 'click: x,y,optional button; drag: from/to x,y and steps; ' | |
| 'scroll: x,y,delta_x,delta_y; key: key; text: text; wait: ms; ' | |
| 'finish has no arguments. The keyboard platform is macOS.') | |
| prompt = row['instruction'] + '\nPrevious actions: ' + row['previous_actions_json'] | |
| return [ | |
| {'role':'system','content':instructions}, | |
| {'role':'user','content':[{'type':'image','image':row['image']},{'type':'text','text':prompt}]}, | |
| {'role':'assistant','content':row['action_json']}, | |
| ] | |
| if __name__ == '__main__': | |
| root=Path(__file__).resolve().parent | |
| data=load_dataset('parquet',data_files={'development':str(root/'data/sft-*.parquet')},split='development') | |
| for row in data: | |
| assert row['image'].size==(1440,1000) | |
| assert isinstance(json.loads(row['action_json']),dict) | |
| to_messages(row) | |
| print(f'Loaded and decoded all {len(data)} SFT images; conversation conversion passed.') | |