agml-bench 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agml_bench/__init__.py +0 -0
- agml_bench/bench.py +387 -0
- agml_bench/benchmarks/agml-full-v1/bundle.yaml +65 -0
- agml_bench/benchmarks/agml-full-v1/config.yaml +76 -0
- agml_bench/benchmarks/agml-full-v1/items.jsonl.gz +0 -0
- agml_bench/benchmarks/agml-full-v1/manifests.json.gz +0 -0
- agml_bench/build.py +468 -0
- agml_bench/catalog.py +212 -0
- agml_bench/cli.py +405 -0
- agml_bench/config.py +38 -0
- agml_bench/eval/__init__.py +17 -0
- agml_bench/eval/ag_tasks.yaml +263 -0
- agml_bench/eval/agtask.py +83 -0
- agml_bench/eval/baselines.py +93 -0
- agml_bench/eval/check.py +207 -0
- agml_bench/eval/cli.py +704 -0
- agml_bench/eval/client.py +162 -0
- agml_bench/eval/crops.py +44 -0
- agml_bench/eval/gpu.py +63 -0
- agml_bench/eval/grade.py +75 -0
- agml_bench/eval/items.py +365 -0
- agml_bench/eval/judge.py +86 -0
- agml_bench/eval/methods.py +88 -0
- agml_bench/eval/metrics.py +115 -0
- agml_bench/eval/models.yaml +139 -0
- agml_bench/eval/profile.py +319 -0
- agml_bench/eval/prompts.yaml +73 -0
- agml_bench/eval/report.py +89 -0
- agml_bench/eval/resources.py +64 -0
- agml_bench/eval/runner.py +195 -0
- agml_bench/eval/scoring.py +189 -0
- agml_bench/eval/seg_classes.yaml +55 -0
- agml_bench/eval/servers.py +132 -0
- agml_bench/eval/stats.py +340 -0
- agml_bench/eval/viewer.py +307 -0
- agml_bench/eval/yolo.py +298 -0
- agml_bench/hub.py +188 -0
- agml_bench/pipeline.py +435 -0
- agml_bench/progress.py +27 -0
- agml_bench/sampling.py +149 -0
- agml_bench/viz/__init__.py +0 -0
- agml_bench/viz/aggregate.py +170 -0
- agml_bench/viz/figures.py +132 -0
- agml_bench/viz/html.py +349 -0
- agml_bench-1.0.0.dist-info/METADATA +203 -0
- agml_bench-1.0.0.dist-info/RECORD +49 -0
- agml_bench-1.0.0.dist-info/WHEEL +4 -0
- agml_bench-1.0.0.dist-info/entry_points.txt +3 -0
- agml_bench-1.0.0.dist-info/licenses/LICENSE +202 -0
agml_bench/__init__.py
ADDED
|
File without changes
|
agml_bench/bench.py
ADDED
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
"""Frozen, named benchmark versions ("bundles"), e.g. agml-full-v1.
|
|
2
|
+
|
|
3
|
+
A bundle fixes everything that decides a score: which images (manifests: dataset, HF repo, pinned revision, sample
|
|
4
|
+
refs), the evaluation items built from them (prompt, options, answer, ground truth), and the judge prompt. Images are
|
|
5
|
+
not redistributed: `agml-bench data pull <bundle>` downloads exactly the listed samples from the source AgML repos at
|
|
6
|
+
their pinned revisions.
|
|
7
|
+
|
|
8
|
+
benchmarks/<name>/bundle.yaml name, description, counts, judge, sha256 of each file, hash
|
|
9
|
+
benchmarks/<name>/items.jsonl.gz frozen EvalItems (image paths relative to the data dir)
|
|
10
|
+
benchmarks/<name>/manifests.json.gz {dataset: manifest + the catalog fields needed to download it}
|
|
11
|
+
benchmarks/<name>/config.yaml sampling config the manifests were drawn with (overrides used when extracting)
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
import gzip
|
|
15
|
+
import hashlib
|
|
16
|
+
import json
|
|
17
|
+
import re
|
|
18
|
+
from dataclasses import dataclass, field
|
|
19
|
+
from functools import cached_property
|
|
20
|
+
from pathlib import Path
|
|
21
|
+
|
|
22
|
+
import yaml
|
|
23
|
+
|
|
24
|
+
BUNDLE_DIR = Path(__file__).parent / "benchmarks"
|
|
25
|
+
DEFAULT = "agml-full-v1"
|
|
26
|
+
CATALOG_KEYS = ("name", "hf_repo", "task", "agricultural_task", "classes", "license", "citation", "crops", "sensor_modality",
|
|
27
|
+
"real_or_synthetic", "eligible")
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _sha(b: bytes) -> str:
|
|
31
|
+
return hashlib.sha256(b).hexdigest()
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _write_gz(path: Path, text: str) -> None:
|
|
35
|
+
"""Byte-reproducible gzip (no timestamp or file name in the header)."""
|
|
36
|
+
with open(path, "wb") as raw, gzip.GzipFile(filename="", mode="wb", fileobj=raw, mtime=0) as f:
|
|
37
|
+
f.write(text.encode())
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def judge_prompt_sha() -> str:
|
|
41
|
+
from agml_bench.eval.resources import prompts
|
|
42
|
+
|
|
43
|
+
p = prompts()
|
|
44
|
+
return _sha(json.dumps([p["judge_system"], p["judge_classification"], p["judge_qa"]]).encode())[:12]
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@dataclass
|
|
48
|
+
class Bundle:
|
|
49
|
+
name: str
|
|
50
|
+
path: Path
|
|
51
|
+
spec: dict = field(repr=False)
|
|
52
|
+
|
|
53
|
+
@property
|
|
54
|
+
def hash(self) -> str:
|
|
55
|
+
return self.spec["hash"]
|
|
56
|
+
|
|
57
|
+
def _text(self, fname: str) -> str:
|
|
58
|
+
return gzip.decompress((self.path / fname).read_bytes()).decode()
|
|
59
|
+
|
|
60
|
+
@cached_property
|
|
61
|
+
def manifests(self) -> dict[str, dict]:
|
|
62
|
+
return json.loads(self._text("manifests.json.gz"))
|
|
63
|
+
|
|
64
|
+
@cached_property
|
|
65
|
+
def raw_items(self) -> list[dict]:
|
|
66
|
+
return [json.loads(l) for l in self._text("items.jsonl.gz").splitlines()]
|
|
67
|
+
|
|
68
|
+
@property
|
|
69
|
+
def unavailable(self) -> dict[str, str]:
|
|
70
|
+
"""Datasets whose source repo is gone, {dataset: notice}. They stay in the benchmark (a local copy is still
|
|
71
|
+
evaluated); without one their items are skipped."""
|
|
72
|
+
return {u["dataset"]: f"{u['reason']} ({u['date']})" for u in self.spec.get("unavailable", [])}
|
|
73
|
+
|
|
74
|
+
@property
|
|
75
|
+
def config_path(self) -> Path:
|
|
76
|
+
return self.path / "config.yaml"
|
|
77
|
+
|
|
78
|
+
def check(self) -> list[str]:
|
|
79
|
+
"""Problems with the bundle files themselves (edited or corrupted after freezing)."""
|
|
80
|
+
out = []
|
|
81
|
+
for fname, want in self.spec["files"].items():
|
|
82
|
+
p = self.path / fname
|
|
83
|
+
if not p.exists():
|
|
84
|
+
out.append(f"{fname}: missing")
|
|
85
|
+
elif _sha(p.read_bytes()) != want:
|
|
86
|
+
out.append(f"{fname}: sha256 differs from bundle.yaml")
|
|
87
|
+
if _bundle_hash(self.spec) != self.hash:
|
|
88
|
+
out.append("bundle.yaml: hash does not match its contents")
|
|
89
|
+
return out
|
|
90
|
+
|
|
91
|
+
def datasets(self, task: list[str] | None = None, only: str | None = None) -> list[str]:
|
|
92
|
+
from agml_bench.pipeline import TASK_DIRS
|
|
93
|
+
|
|
94
|
+
return [n for n, m in sorted(self.manifests.items())
|
|
95
|
+
if (not task or TASK_DIRS[m["task"]] in task or m["task"] in task) and (not only or re.search(only, n))]
|
|
96
|
+
|
|
97
|
+
def entry(self, name: str) -> dict:
|
|
98
|
+
"""Catalog-style entry for the download pipeline."""
|
|
99
|
+
return self.manifests[name]["catalog"]
|
|
100
|
+
|
|
101
|
+
def items(self, data_dir, tasks=None, formats=None, only: str | None = None, limit_per_dataset: int | None = None,
|
|
102
|
+
seed: int = 0) -> tuple[list, list[dict]]:
|
|
103
|
+
"""Frozen EvalItems for the datasets present in data_dir, plus the selected datasets that are not."""
|
|
104
|
+
from agml_bench.eval.items import EvalItem, _unit
|
|
105
|
+
from agml_bench.pipeline import base_dir
|
|
106
|
+
|
|
107
|
+
data_dir = Path(data_dir)
|
|
108
|
+
present = {}
|
|
109
|
+
for r in self.raw_items:
|
|
110
|
+
key = (r["task"], r["dataset"])
|
|
111
|
+
if key not in present:
|
|
112
|
+
present[key] = (base_dir(data_dir) / r["task"] / r["dataset"] / "meta.json").exists()
|
|
113
|
+
keep, skipped, seen = [], [], set()
|
|
114
|
+
for r in self.raw_items:
|
|
115
|
+
if tasks and r["task"] not in tasks:
|
|
116
|
+
continue
|
|
117
|
+
if formats and r["format"] not in formats and not (r["task"] == "image_text_to_text" and r["qa_format"] in formats):
|
|
118
|
+
continue
|
|
119
|
+
if only and not re.search(only, r["dataset"]):
|
|
120
|
+
continue
|
|
121
|
+
key = (r["task"], r["dataset"])
|
|
122
|
+
if not present[key]:
|
|
123
|
+
if key not in seen:
|
|
124
|
+
seen.add(key)
|
|
125
|
+
why = self.unavailable.get(r["dataset"]) or f"not downloaded (agml-bench data pull {self.name})"
|
|
126
|
+
skipped.append({"dataset": r["dataset"], "task": r["task"], "reason": why})
|
|
127
|
+
continue
|
|
128
|
+
keep.append(r)
|
|
129
|
+
if limit_per_dataset:
|
|
130
|
+
by_ds: dict = {}
|
|
131
|
+
for r in keep:
|
|
132
|
+
by_ds.setdefault(r["dataset"], set()).add(r["sample_id"])
|
|
133
|
+
chosen = {s for ids in by_ds.values() for s in sorted(ids, key=lambda s: _unit(seed, s))[:limit_per_dataset]}
|
|
134
|
+
keep = [r for r in keep if r["sample_id"] in chosen]
|
|
135
|
+
items = []
|
|
136
|
+
for r in keep:
|
|
137
|
+
it = EvalItem(**r)
|
|
138
|
+
it.images = [str(data_dir / p) for p in r["images"]]
|
|
139
|
+
items.append(it)
|
|
140
|
+
return items, skipped
|
|
141
|
+
|
|
142
|
+
def summary(self) -> dict:
|
|
143
|
+
return {k: self.spec[k] for k in ("name", "description", "hash", "created", "datasets", "items", "judge")}
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def _bundle_hash(spec: dict) -> str:
|
|
147
|
+
payload = {"name": spec["name"], "files": spec["files"], "judge": spec["judge"]}
|
|
148
|
+
return _sha(json.dumps(payload, sort_keys=True).encode())[:16]
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def list_bundles() -> list[str]:
|
|
152
|
+
return sorted(p.name for p in BUNDLE_DIR.iterdir() if (p / "bundle.yaml").exists()) if BUNDLE_DIR.is_dir() else []
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def load(name: str) -> Bundle:
|
|
156
|
+
p = BUNDLE_DIR / name
|
|
157
|
+
if not (p / "bundle.yaml").exists():
|
|
158
|
+
raise KeyError(f"unknown benchmark {name!r}; available: {', '.join(list_bundles()) or 'none'}")
|
|
159
|
+
return Bundle(name, p, yaml.safe_load((p / "bundle.yaml").read_text()))
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def freeze(name: str, items_path: Path, description: str, manifest_dir: Path | None = None, config_path: Path | None = None,
|
|
163
|
+
catalog: dict | None = None, judge_model: str | None = None) -> Bundle:
|
|
164
|
+
"""Write benchmarks/<name>/ from an items.jsonl (the items a run evaluated) and the committed manifests.
|
|
165
|
+
|
|
166
|
+
Items are stored exactly as given (image paths made relative to the data dir). Only datasets with at least one
|
|
167
|
+
item are included; a manifest that yields no items (e.g. no usable segmentation classes) is left out."""
|
|
168
|
+
from datetime import datetime, timezone
|
|
169
|
+
|
|
170
|
+
from agml_bench.catalog import load_catalog
|
|
171
|
+
from agml_bench.config import DEFAULT_CONFIG, MANIFEST_DIR
|
|
172
|
+
from agml_bench.eval.resources import models
|
|
173
|
+
from agml_bench.pipeline import TASK_DIRS
|
|
174
|
+
|
|
175
|
+
manifest_dir, config_path = Path(manifest_dir or MANIFEST_DIR), Path(config_path or DEFAULT_CONFIG)
|
|
176
|
+
catalog = catalog or load_catalog()
|
|
177
|
+
out = BUNDLE_DIR / name
|
|
178
|
+
if out.exists():
|
|
179
|
+
raise FileExistsError(f"{out} exists: a frozen benchmark is never overwritten; freeze a new name")
|
|
180
|
+
|
|
181
|
+
items = []
|
|
182
|
+
for line in open(items_path):
|
|
183
|
+
r = json.loads(line)
|
|
184
|
+
r["images"] = [p[p.index("base-data/"):] for p in r["images"]]
|
|
185
|
+
items.append(r)
|
|
186
|
+
used = {r["dataset"] for r in items}
|
|
187
|
+
manifests = {}
|
|
188
|
+
for p in sorted(manifest_dir.glob("*/*.json")):
|
|
189
|
+
m = json.loads(p.read_text())
|
|
190
|
+
if m["name"] in used:
|
|
191
|
+
e = catalog["datasets"][m["name"]]
|
|
192
|
+
m["catalog"] = {k: e.get(k) for k in CATALOG_KEYS}
|
|
193
|
+
manifests[m["name"]] = m
|
|
194
|
+
missing = used - set(manifests)
|
|
195
|
+
if missing:
|
|
196
|
+
raise ValueError(f"items from datasets without a manifest: {sorted(missing)[:5]}")
|
|
197
|
+
|
|
198
|
+
out.mkdir(parents=True)
|
|
199
|
+
_write_gz(out / "items.jsonl.gz", "".join(json.dumps(r, ensure_ascii=False, sort_keys=True) + "\n" for r in items))
|
|
200
|
+
_write_gz(out / "manifests.json.gz", json.dumps(manifests, ensure_ascii=False, sort_keys=True, default=str))
|
|
201
|
+
(out / "config.yaml").write_bytes(config_path.read_bytes())
|
|
202
|
+
counts: dict = {}
|
|
203
|
+
for r in items:
|
|
204
|
+
k = f"{r['task']}/{r['format'] if r['task'] != 'image_text_to_text' else r['qa_format']}"
|
|
205
|
+
counts[k] = counts.get(k, 0) + 1
|
|
206
|
+
by_task: dict = {}
|
|
207
|
+
for m in manifests.values():
|
|
208
|
+
by_task[TASK_DIRS[m["task"]]] = by_task.get(TASK_DIRS[m["task"]], 0) + 1
|
|
209
|
+
spec = {
|
|
210
|
+
"name": name, "description": description,
|
|
211
|
+
"created": datetime.now(timezone.utc).isoformat(timespec="seconds"),
|
|
212
|
+
"datasets": {"total": len(manifests), **dict(sorted(by_task.items()))},
|
|
213
|
+
"images": sum(len(m["samples"]) for m in manifests.values()),
|
|
214
|
+
"items": {"total": len(items), **dict(sorted(counts.items()))},
|
|
215
|
+
"judge": {"model": judge_model or models()["judge"], "prompt_sha": judge_prompt_sha()},
|
|
216
|
+
"files": {f: _sha((out / f).read_bytes()) for f in ("items.jsonl.gz", "manifests.json.gz", "config.yaml")},
|
|
217
|
+
}
|
|
218
|
+
spec["hash"] = _bundle_hash(spec)
|
|
219
|
+
(out / "bundle.yaml").write_text(yaml.safe_dump(spec, sort_keys=False, allow_unicode=True))
|
|
220
|
+
return load(name)
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
# ---------------------------------------------------------------- local data
|
|
224
|
+
|
|
225
|
+
def data_status(b: Bundle, data_dir, task=None, only=None) -> dict[str, str]:
|
|
226
|
+
"""Per dataset: done | missing | stale (wrong revision or different samples) | failed | unavailable (source repo
|
|
227
|
+
gone, no local copy)."""
|
|
228
|
+
from agml_bench.pipeline import base_dir, failure_path, TASK_DIRS
|
|
229
|
+
|
|
230
|
+
out = {}
|
|
231
|
+
for n in b.datasets(task, only):
|
|
232
|
+
m = b.manifests[n]
|
|
233
|
+
d = base_dir(data_dir) / TASK_DIRS[m["task"]] / n
|
|
234
|
+
if (d / "meta.json").exists():
|
|
235
|
+
meta = json.loads((d / "meta.json").read_text())
|
|
236
|
+
have = {json.loads(l)["sample_id"] for l in open(d / "samples.jsonl")} if (d / "samples.jsonl").exists() else set()
|
|
237
|
+
same = meta.get("hf_sha") == m["hf_sha"] and have == {s["sample_id"] for s in m["samples"]}
|
|
238
|
+
out[n] = "done" if same else "stale"
|
|
239
|
+
elif n in b.unavailable:
|
|
240
|
+
out[n] = "unavailable"
|
|
241
|
+
else:
|
|
242
|
+
out[n] = "failed" if failure_path(Path(data_dir), n).exists() else "missing"
|
|
243
|
+
return out
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
def verify(b: Bundle, data_dir, task=None, only=None, decode: bool = True) -> dict[str, list[str]]:
|
|
247
|
+
"""Problems per dataset in a local copy: not downloaded, wrong revision, missing or extra samples, missing or
|
|
248
|
+
undecodable images. An empty dict means the local copy matches the bundle. Unavailable datasets (source repo
|
|
249
|
+
gone) without a local copy are not problems; with one, they are checked like the rest."""
|
|
250
|
+
from PIL import Image, ImageFile
|
|
251
|
+
|
|
252
|
+
from agml_bench.pipeline import base_dir, TASK_DIRS
|
|
253
|
+
|
|
254
|
+
ImageFile.LOAD_TRUNCATED_IMAGES = True # as the model servers and YOLO decode them; only unreadable files count
|
|
255
|
+
need: dict[str, set] = {}
|
|
256
|
+
for r in b.raw_items:
|
|
257
|
+
need.setdefault(r["dataset"], set()).update(r["images"])
|
|
258
|
+
problems: dict[str, list[str]] = {}
|
|
259
|
+
for n in b.datasets(task, only):
|
|
260
|
+
m, errs = b.manifests[n], []
|
|
261
|
+
d = base_dir(data_dir) / TASK_DIRS[m["task"]] / n
|
|
262
|
+
if not (d / "meta.json").exists():
|
|
263
|
+
if n not in b.unavailable:
|
|
264
|
+
problems[n] = ["not downloaded"]
|
|
265
|
+
continue
|
|
266
|
+
meta = json.loads((d / "meta.json").read_text())
|
|
267
|
+
if meta.get("hf_sha") != m["hf_sha"]:
|
|
268
|
+
errs.append(f"revision {str(meta.get('hf_sha'))[:7]} != {m['hf_sha'][:7]}")
|
|
269
|
+
have = {json.loads(l)["sample_id"] for l in open(d / "samples.jsonl")}
|
|
270
|
+
want = {s["sample_id"] for s in m["samples"]}
|
|
271
|
+
if want - have:
|
|
272
|
+
errs.append(f"{len(want - have)} samples missing")
|
|
273
|
+
if have - want:
|
|
274
|
+
errs.append(f"{len(have - want)} samples not in the benchmark")
|
|
275
|
+
bad = 0
|
|
276
|
+
for rel in sorted(need.get(n, ())):
|
|
277
|
+
p = Path(data_dir) / rel
|
|
278
|
+
if not p.exists():
|
|
279
|
+
errs.append(f"missing image {rel}")
|
|
280
|
+
continue
|
|
281
|
+
if decode:
|
|
282
|
+
try:
|
|
283
|
+
with Image.open(p) as im:
|
|
284
|
+
im.load()
|
|
285
|
+
except Exception:
|
|
286
|
+
bad += 1
|
|
287
|
+
if bad:
|
|
288
|
+
errs.append(f"{bad} images do not decode")
|
|
289
|
+
if errs:
|
|
290
|
+
problems[n] = errs
|
|
291
|
+
return problems
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
# ---------------------------------------------------------------- re-pinning a recreated source repo
|
|
295
|
+
|
|
296
|
+
def repin(b: Bundle, name: str, reference_dir, write: bool = False, scratch=None) -> dict:
|
|
297
|
+
"""Point a VQA dataset's manifest at the current revision of its HF repo, for a repo that was deleted and
|
|
298
|
+
re-uploaded (the pinned revision no longer exists).
|
|
299
|
+
|
|
300
|
+
The frozen items hold every question, option and answer, so the source only has to supply the images. Each sample
|
|
301
|
+
is found in the new upload by the SHA-256 of its images in the reference copy (a data dir holding the benchmark's
|
|
302
|
+
images; uploads name image files by that hash), preferring a row with the same question when several rows share
|
|
303
|
+
the image. The chosen rows are then downloaded and must give byte-identical images. Sample ids, and so the
|
|
304
|
+
frozen items, are unchanged. Rows whose conversation text differs from the reference are counted (`text_changed`):
|
|
305
|
+
they do not affect frozen-item scores. With `write`, the bundle and manifests/base-data/ are updated only if
|
|
306
|
+
every sample's images matched."""
|
|
307
|
+
import hashlib
|
|
308
|
+
import shutil
|
|
309
|
+
import tempfile
|
|
310
|
+
from datetime import datetime, timezone
|
|
311
|
+
|
|
312
|
+
from agml_bench import build
|
|
313
|
+
from agml_bench.config import MANIFEST_DIR, load_config
|
|
314
|
+
from agml_bench.hub import Repo
|
|
315
|
+
from agml_bench.pipeline import TASK_DIRS, base_dir, index_dataset
|
|
316
|
+
from agml_bench.sampling import rng_for
|
|
317
|
+
|
|
318
|
+
m = b.manifests[name]
|
|
319
|
+
if m["task"] != "image_text_to_text":
|
|
320
|
+
raise NotImplementedError("re-pinning matches images by content hash, which only VQA uploads use as file names")
|
|
321
|
+
cfg = load_config(b.config_path)
|
|
322
|
+
ref_dir = base_dir(reference_dir) / TASK_DIRS[m["task"]] / name
|
|
323
|
+
ref = {s["sample_id"]: s for s in (json.loads(l) for l in open(ref_dir / "samples.jsonl"))}
|
|
324
|
+
repo = Repo(m["hf_repo"], revision=None)
|
|
325
|
+
recs, info = index_dataset(cfg, m["catalog"], repo, rng_for(cfg["sampling"]["seed"], name))
|
|
326
|
+
keys: dict = {}
|
|
327
|
+
for f in sorted({r["ref"]["file"] for r in recs}):
|
|
328
|
+
for i, x in enumerate(repo.parquet(f).read(columns=["images"]).to_pylist()):
|
|
329
|
+
keys[(f, i)] = tuple(im.get("path") for im in (x["images"] or []))
|
|
330
|
+
by_key: dict = {}
|
|
331
|
+
for r in recs:
|
|
332
|
+
by_key.setdefault(keys.get((r["ref"]["file"], r["ref"]["row"])), []).append(r)
|
|
333
|
+
|
|
334
|
+
report = {"dataset": name, "old_revision": m["hf_sha"], "new_revision": repo.revision, "samples": len(m["samples"]),
|
|
335
|
+
"unmatched": [], "different": [], "text_changed": 0}
|
|
336
|
+
new_samples, picks = [], []
|
|
337
|
+
for s in m["samples"]:
|
|
338
|
+
rs = ref.get(s["sample_id"])
|
|
339
|
+
if not rs:
|
|
340
|
+
report["unmatched"].append(s["sample_id"])
|
|
341
|
+
continue
|
|
342
|
+
key = tuple(hashlib.sha256((ref_dir / p).read_bytes()).hexdigest() for p in rs["images"])
|
|
343
|
+
q = (build._qa(rs["messages"])[0] or "")[:500]
|
|
344
|
+
cands = by_key.get(key, [])
|
|
345
|
+
if not cands:
|
|
346
|
+
report["unmatched"].append(s["sample_id"])
|
|
347
|
+
continue
|
|
348
|
+
pick = next((r for r in cands if r["question"] == q), cands[0])
|
|
349
|
+
picks.append({**pick, "sample_id": s["sample_id"]})
|
|
350
|
+
new_samples.append({**s, "ref": pick["ref"]})
|
|
351
|
+
|
|
352
|
+
tmp = Path(tempfile.mkdtemp(prefix=f"repin_{name}_", dir=scratch))
|
|
353
|
+
try:
|
|
354
|
+
got = build.extract(repo, name, m["task"], info, picks, tmp, None)
|
|
355
|
+
for g in got:
|
|
356
|
+
r0 = ref[g["sample_id"]]
|
|
357
|
+
same_imgs = len(g["images"]) == len(r0["images"]) and all(
|
|
358
|
+
(tmp / a).read_bytes() == (ref_dir / c).read_bytes() for a, c in zip(g["images"], r0["images"]))
|
|
359
|
+
if not same_imgs:
|
|
360
|
+
report["different"].append(g["sample_id"])
|
|
361
|
+
elif g["messages"] != r0["messages"]:
|
|
362
|
+
report["text_changed"] += 1
|
|
363
|
+
report["different"] += sorted({p["sample_id"] for p in picks} - {g["sample_id"] for g in got})
|
|
364
|
+
finally:
|
|
365
|
+
shutil.rmtree(tmp, ignore_errors=True)
|
|
366
|
+
report["ok"] = not (report["unmatched"] or report["different"])
|
|
367
|
+
if write and report["ok"]:
|
|
368
|
+
m.update(hf_sha=repo.revision, samples=new_samples, info={**m["info"], "layout": info["layout"]})
|
|
369
|
+
_write_gz(b.path / "manifests.json.gz", json.dumps(b.manifests, ensure_ascii=False, sort_keys=True, default=str))
|
|
370
|
+
spec = b.spec
|
|
371
|
+
spec["files"]["manifests.json.gz"] = _sha((b.path / "manifests.json.gz").read_bytes())
|
|
372
|
+
spec.setdefault("repinned", []).append({
|
|
373
|
+
"dataset": name, "from": report["old_revision"], "to": repo.revision,
|
|
374
|
+
"date": datetime.now(timezone.utc).date().isoformat(),
|
|
375
|
+
"reason": f"source repo re-uploaded; images matched by SHA-256, byte-identical; "
|
|
376
|
+
f"{report['text_changed']} of {report['samples']} rows have different conversation text "
|
|
377
|
+
f"(frozen items unaffected)"})
|
|
378
|
+
spec["hash"] = _bundle_hash(spec)
|
|
379
|
+
(b.path / "bundle.yaml").write_text(yaml.safe_dump(spec, sort_keys=False, allow_unicode=True))
|
|
380
|
+
mp = MANIFEST_DIR / TASK_DIRS[m["task"]] / f"{name}.json"
|
|
381
|
+
if mp.exists():
|
|
382
|
+
committed = json.loads(mp.read_text())
|
|
383
|
+
committed.update(hf_sha=repo.revision, samples=new_samples)
|
|
384
|
+
mp.write_text(json.dumps(committed, indent=1, ensure_ascii=False, default=str))
|
|
385
|
+
report["written"] = True
|
|
386
|
+
return report
|
|
387
|
+
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
name: agml-full-v1
|
|
2
|
+
description: 'Full AgML VLM benchmark (paper version): 372 datasets; classification,
|
|
3
|
+
detection, segmentation, VQA'
|
|
4
|
+
created: '2026-11-19T18:25:12+00:00'
|
|
5
|
+
datasets:
|
|
6
|
+
total: 372
|
|
7
|
+
classification: 220
|
|
8
|
+
detection: 105
|
|
9
|
+
image_text_to_text: 13
|
|
10
|
+
segmentation: 34
|
|
11
|
+
images: 14134
|
|
12
|
+
items:
|
|
13
|
+
total: 32456
|
|
14
|
+
classification/mcqa_across: 9161
|
|
15
|
+
classification/mcqa_within: 9161
|
|
16
|
+
classification/oeq: 9161
|
|
17
|
+
detection/grounding: 1628
|
|
18
|
+
image_text_to_text/multiple_choice: 1053
|
|
19
|
+
image_text_to_text/numeric: 236
|
|
20
|
+
image_text_to_text/open_ended: 1604
|
|
21
|
+
image_text_to_text/yes_no: 204
|
|
22
|
+
segmentation/grounding: 248
|
|
23
|
+
judge:
|
|
24
|
+
model: RedHatAI/gemma-4-31B-it-FP8-dynamic
|
|
25
|
+
prompt_sha: 073c65389ab6
|
|
26
|
+
files:
|
|
27
|
+
items.jsonl.gz: daaf343cc1cf3db2451108c26d22a474e2766148ee2e4f81d49542d8b303c354
|
|
28
|
+
manifests.json.gz: 0430cac6cea2ba4cb531bdf00546bffe7b658ed4947aa8863882e03423907442
|
|
29
|
+
config.yaml: 189ba090cd5465712e682a4920e85bd406dbd4acd105908f31f17dd5a595f7be
|
|
30
|
+
hash: 1876e21c16b413dd
|
|
31
|
+
repinned:
|
|
32
|
+
- dataset: AgroOmni
|
|
33
|
+
from: d63a9b6872a8419a54eef92d1f39553727e71f93
|
|
34
|
+
to: e9fba7ccd1b37119b358d87144dcdbdf978deee9
|
|
35
|
+
date: '2026-11-23'
|
|
36
|
+
reason: source repo re-uploaded; images matched by SHA-256, byte-identical; 250
|
|
37
|
+
of 250 rows have different conversation text (frozen items unaffected)
|
|
38
|
+
- dataset: CDDM
|
|
39
|
+
from: 5f49d14b6eb589d0bffe9e99cd41c627e8aee80a
|
|
40
|
+
to: 4c7e60e037791bff718853d6d38156cf89ad1ddd
|
|
41
|
+
date: '2026-11-23'
|
|
42
|
+
reason: source repo re-uploaded; images matched by SHA-256, byte-identical; 250
|
|
43
|
+
of 250 rows have different conversation text (frozen items unaffected)
|
|
44
|
+
- dataset: LeafNet
|
|
45
|
+
from: 7c50356715c50e9ea3c2f23a5a9fc936e5f3c45a
|
|
46
|
+
to: b88a6aadd84bcb554816825651145b6790da5b73
|
|
47
|
+
date: '2026-11-23'
|
|
48
|
+
reason: source repo re-uploaded; images matched by SHA-256, byte-identical; 250
|
|
49
|
+
of 250 rows have different conversation text (frozen items unaffected)
|
|
50
|
+
- dataset: PlantExpertVQA
|
|
51
|
+
from: c7b1dbddc59fa7dff2cc4cc55966c6fbf5709ade
|
|
52
|
+
to: 7534652974d1645627eadcb57caf0f025693f7f5
|
|
53
|
+
date: '2026-11-23'
|
|
54
|
+
reason: source repo re-uploaded; images matched by SHA-256, byte-identical; 7 of
|
|
55
|
+
234 rows have different conversation text (frozen items unaffected)
|
|
56
|
+
- dataset: PlantMicro
|
|
57
|
+
from: c421bedca8dfa4f33ddd07cca19365dfea4a9657
|
|
58
|
+
to: 81ad2c059680436489a7b05bc7b8a8be7f510e5a
|
|
59
|
+
date: '2026-11-23'
|
|
60
|
+
reason: source repo re-uploaded; images matched by SHA-256, byte-identical; 0 of
|
|
61
|
+
250 rows have different conversation text (frozen items unaffected)
|
|
62
|
+
unavailable:
|
|
63
|
+
- dataset: AgriBench
|
|
64
|
+
date: '2026-11-23'
|
|
65
|
+
reason: removed from Hugging Face (Project-AgML/AgriBench no longer exists)
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Catalog source: Project-AgML website data folder.
|
|
2
|
+
catalog:
|
|
3
|
+
github_repo: Project-AgML/project-agml.github.io
|
|
4
|
+
branch: main
|
|
5
|
+
data_path: static/data
|
|
6
|
+
hf_org: Project-AgML
|
|
7
|
+
|
|
8
|
+
eligibility:
|
|
9
|
+
tasks: [image_classification, object_detection, semantic_segmentation, image_text_to_text]
|
|
10
|
+
sensor_modalities: [rgb]
|
|
11
|
+
# Image-text datasets ship standard image files regardless of the original sensor.
|
|
12
|
+
itt_ignore_sensor: true
|
|
13
|
+
|
|
14
|
+
sampling:
|
|
15
|
+
seed: 0
|
|
16
|
+
samples_per_class: 5
|
|
17
|
+
# Rows whose split is earlier in this list are preferred when picking samples.
|
|
18
|
+
split_priority: [test, validation, val, dev, train]
|
|
19
|
+
# Configs whose name contains any of these are never used for cls/det/seg.
|
|
20
|
+
skip_config_keywords: [augment]
|
|
21
|
+
# Segmentation needs mask pixels to know which classes appear; cap rows scanned.
|
|
22
|
+
seg_max_index_rows: 3000
|
|
23
|
+
itt:
|
|
24
|
+
per_stratum: 5
|
|
25
|
+
max_per_dataset: 250
|
|
26
|
+
# Raise the per-stratum quota so datasets with few strata still reach max_per_dataset.
|
|
27
|
+
fill_to_cap: true
|
|
28
|
+
# raw_metadata keys tried (in order) as the primary stratum.
|
|
29
|
+
primary_keys: [task, question_type, type_id, subset, source, category, answer_type, origin_dataset]
|
|
30
|
+
# Optional second key, added only if the strata still fit max_per_dataset / per_stratum.
|
|
31
|
+
secondary_keys: [category, crop, origin_dataset, task_type, subset]
|
|
32
|
+
max_stratum_values: 60
|
|
33
|
+
|
|
34
|
+
download:
|
|
35
|
+
timeout_s: 900
|
|
36
|
+
|
|
37
|
+
# Per-dataset overrides, keyed by catalog name.
|
|
38
|
+
# include: true|false force eligibility
|
|
39
|
+
# reason: str note shown in the catalog
|
|
40
|
+
# config: str HF config to use
|
|
41
|
+
# strata: [key, ...] ITT raw_metadata keys to stratify on
|
|
42
|
+
# bbox_format: xywh|xyxy|cxcywh (normalized boxes are detected automatically)
|
|
43
|
+
overrides:
|
|
44
|
+
iNatAg:
|
|
45
|
+
include: false
|
|
46
|
+
reason: species-scale (2,958 classes); enable explicitly
|
|
47
|
+
iNatAg-mini:
|
|
48
|
+
include: false
|
|
49
|
+
reason: species-scale (2,958 classes); enable explicitly
|
|
50
|
+
rice_seedling_segmentation:
|
|
51
|
+
include: false
|
|
52
|
+
reason: mask column holds file paths but mask files are missing from the HF repo
|
|
53
|
+
sugarbeet_weed_segmentation:
|
|
54
|
+
include: false
|
|
55
|
+
reason: mask column holds file paths but mask files are missing from the HF repo
|
|
56
|
+
GobhiSet_cauliflower_segmentation:
|
|
57
|
+
include: false
|
|
58
|
+
reason: masks are empty (all background)
|
|
59
|
+
LeLePhid_classification:
|
|
60
|
+
include: false
|
|
61
|
+
reason: masks are empty (all background)
|
|
62
|
+
grapevine_organ_segmentation:
|
|
63
|
+
include: false
|
|
64
|
+
reason: masks cover the whole image
|
|
65
|
+
soybean_harvest_damage_segmentation:
|
|
66
|
+
include: false
|
|
67
|
+
reason: mask values are noise / inconsistent between images
|
|
68
|
+
|
|
69
|
+
# Few-shot training images for the supervised baselines (agbench sample-train): disjoint from the evaluated
|
|
70
|
+
# samples above. Each subset is drawn with its own seed; within a subset the smaller shot counts use the same
|
|
71
|
+
# image order, so for classification the 5-shot set is contained in the 10-shot set, and so on.
|
|
72
|
+
train_sampling:
|
|
73
|
+
seed: 100
|
|
74
|
+
subsets: 3
|
|
75
|
+
shots: [5, 10, 15]
|
|
76
|
+
split_priority: [train, validation, val, dev, test]
|
|
Binary file
|
|
Binary file
|