Datasets:
Add default inference system prompt
Browse files- pointerbench-text/eval.py +19 -1
pointerbench-text/eval.py
CHANGED
|
@@ -17,6 +17,7 @@ Accepted bbox keys: "bbox" / "box" / "pred" / "prediction", or flat
|
|
| 17 |
Coordinates are absolute pixels on the 1024x768 image.
|
| 18 |
|
| 19 |
Usage:
|
|
|
|
| 20 |
python eval.py --predictions preds.jsonl
|
| 21 |
python eval.py --predictions preds.jsonl --json report.json
|
| 22 |
"""
|
|
@@ -34,6 +35,15 @@ GT_PATH = ROOT / "data" / "test" / "metadata.jsonl"
|
|
| 34 |
|
| 35 |
AXES = ("answer_type", "data_type", "category", "surface", "language", "difficulty")
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
def _load_jsonl(path: Path) -> list[dict]:
|
| 39 |
text = path.read_text(encoding="utf-8").strip()
|
|
@@ -168,7 +178,9 @@ def _print(report: dict) -> None:
|
|
| 168 |
def main() -> None:
|
| 169 |
ap = argparse.ArgumentParser(description=__doc__,
|
| 170 |
formatter_class=argparse.RawDescriptionHelpFormatter)
|
| 171 |
-
ap.add_argument("--
|
|
|
|
|
|
|
| 172 |
help="JSONL/JSON predictions: {id, point:[x,y]} per example")
|
| 173 |
ap.add_argument("--gt", type=Path, default=GT_PATH,
|
| 174 |
help=f"ground-truth metadata (default: {GT_PATH})")
|
|
@@ -176,6 +188,12 @@ def main() -> None:
|
|
| 176 |
help="also write the full report to this JSON path")
|
| 177 |
args = ap.parse_args()
|
| 178 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 179 |
gt = _load_jsonl(args.gt)
|
| 180 |
preds = {r["id"]: r for r in _load_jsonl(args.predictions) if "id" in r}
|
| 181 |
report = evaluate(gt, preds)
|
|
|
|
| 17 |
Coordinates are absolute pixels on the 1024x768 image.
|
| 18 |
|
| 19 |
Usage:
|
| 20 |
+
python eval.py --show-system-prompt
|
| 21 |
python eval.py --predictions preds.jsonl
|
| 22 |
python eval.py --predictions preds.jsonl --json report.json
|
| 23 |
"""
|
|
|
|
| 35 |
|
| 36 |
AXES = ("answer_type", "data_type", "category", "surface", "language", "difficulty")
|
| 37 |
|
| 38 |
+
DEFAULT_SYSTEM_PROMPT = (
|
| 39 |
+
"You are evaluating Pointerbench, a GUI grounding benchmark. "
|
| 40 |
+
"You will receive one 1024x768 screenshot and one task instruction. "
|
| 41 |
+
"Use absolute pixel coordinates with origin at the top-left of the image. "
|
| 42 |
+
"Do not return normalized coordinates. Do not crop or resize the coordinate frame. "
|
| 43 |
+
"For point tasks, return JSON like {\"point\": [x, y]}. "
|
| 44 |
+
"For bounding-box tasks, return JSON like {\"bbox\": [x0, y0, x1, y1]}."
|
| 45 |
+
)
|
| 46 |
+
|
| 47 |
|
| 48 |
def _load_jsonl(path: Path) -> list[dict]:
|
| 49 |
text = path.read_text(encoding="utf-8").strip()
|
|
|
|
| 178 |
def main() -> None:
|
| 179 |
ap = argparse.ArgumentParser(description=__doc__,
|
| 180 |
formatter_class=argparse.RawDescriptionHelpFormatter)
|
| 181 |
+
ap.add_argument("--show-system-prompt", action="store_true",
|
| 182 |
+
help="print the recommended inference system prompt and exit")
|
| 183 |
+
ap.add_argument("--predictions", type=Path,
|
| 184 |
help="JSONL/JSON predictions: {id, point:[x,y]} per example")
|
| 185 |
ap.add_argument("--gt", type=Path, default=GT_PATH,
|
| 186 |
help=f"ground-truth metadata (default: {GT_PATH})")
|
|
|
|
| 188 |
help="also write the full report to this JSON path")
|
| 189 |
args = ap.parse_args()
|
| 190 |
|
| 191 |
+
if args.show_system_prompt:
|
| 192 |
+
print(DEFAULT_SYSTEM_PROMPT)
|
| 193 |
+
return
|
| 194 |
+
if args.predictions is None:
|
| 195 |
+
ap.error("--predictions is required unless --show-system-prompt is used")
|
| 196 |
+
|
| 197 |
gt = _load_jsonl(args.gt)
|
| 198 |
preds = {r["id"]: r for r in _load_jsonl(args.predictions) if "id" in r}
|
| 199 |
report = evaluate(gt, preds)
|