Multi-scroll support: build.py and fetch.py take any open-data scroll (per-scroll voxel size, X-ray scan, renumbering by radius, optional ink, a second 1 um ink layer), make_manifest.py, the scroll picker's prize eligible badge and eligible-only toggle (window.unrollScrolls), and a 'Why N ink layers?' box written from each manifest's ink layers
cf20894 Download tools/make_manifest.py from SharpMeow/unroll: direct link, hf CLI and curl.
- Browser
- Download file 7.69 kB
-
https://huggingface.co/spaces/SharpMeow/unroll/resolve/main/tools/make_manifest.py
- Command line
-
hf download hf://spaces/SharpMeow/unroll/tools/make_manifest.py
-
curl -L -o make_manifest.py https://huggingface.co/spaces/SharpMeow/unroll/resolve/main/tools/make_manifest.py
7.69 kB
| """Write scrolls/<id>/manifest.json and the registry entry for a scroll built by tools/build.py. | |
| python tools/make_manifest.py PHerc0814 | |
| Text here is our own wording: no titles, authors or work names, nothing copied from the data browser. | |
| The prize field mirrors the "prize eligible" badge on scrollprize.org (see https://scrollprize.org/prizes). | |
| """ | |
| import json | |
| import os | |
| import sys | |
| ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
| CITE = ("Giorgio Angelotti, Stephen Parsons, Sean Johnson, Elian Rafael Dal Prà, Johannes Rudolph, Paul Tafforeau, " | |
| "Alessandro Mirone, Paul Henderson, Hendrik Schilling, Forrest McDonald, David Josey, Youssef Nader, C. Seth Parker, " | |
| "W. Brent Seales. Vesuvius Challenge - CT Scans of Herculaneum Papyri. Vesuvius Challenge.") | |
| EDUCELAB = ("EduceLab-Scrolls: Parsons, S., Parker, C. S., Chapman, C., Hayashida, M., & Seales, W. B. (2023). " | |
| "EduceLab-Scrolls: Verifiable Recovery of Text from Herculaneum Papyri using X-ray CT. ArXiv [Cs.CV]. " | |
| "https://doi.org/10.48550/arXiv.2304.02084. Data used here were obtained from the EduceLab-Scrolls dataset.") | |
| CHECKED = "2026-10-16" | |
| # per scroll: display name, holder, scan of the meshes, X-ray scan, ink layers, prize sets | |
| S = { | |
| "PHerc0814": dict(name="PHerc. 814", holder="Biblioteca Nazionale di Napoli", vox=9.362, ct=9.362, scan="ESRF", | |
| ink=2.399, ink1=1.129), | |
| "PHerc0009B": dict(name="PHerc. 9B", holder="Biblioteca Nazionale di Napoli", vox=8.64, ct=8.64, scan="ESRF", ink=2.401), | |
| "PHerc0343P": dict(name="PHerc. 343P", holder="Biblioteca Nazionale di Napoli", vox=8.64, ct=8.64, scan="ESRF", ink=2.215), | |
| "PHerc0841": dict(name="PHerc. 841", holder="Biblioteca Nazionale di Napoli", vox=9.366, ct=9.366, scan="ESRF", ink=2.403), | |
| "PHerc0172": dict(name="PHerc. 172 (Scroll 5)", holder="Bodleian Library, Oxford", vox=7.91, ct=7.91, scan="Diamond Light Source", | |
| ink=7.91), | |
| "PHerc1667": dict(name="PHerc. 1667 (Scroll 4)", holder="Biblioteca Nazionale di Napoli", vox=7.91, ct=2.399, scan="ESRF", | |
| ink=2.399, ink1=1.129, educelab=True), | |
| "PHerc1447": dict(name="PHerc. 1447", holder="Biblioteca Nazionale di Napoli", vox=8.64, ct=8.64, scan="ESRF", | |
| prize=["2027 Grand Prize"]), | |
| "PHerc0800": dict(name="PHerc. 800", holder="Biblioteca Nazionale di Napoli", vox=8.64, ct=8.64, scan="ESRF", | |
| prize=["2027 Grand Prize", "First Letters"]), | |
| } | |
| def um(x): | |
| return f"{x:g} µm" | |
| def main(sid): | |
| c = S[sid] | |
| d = f"data/{sid}" | |
| M = json.load(open(f"{ROOT}/{d}/scroll.json")) | |
| ids = [w["id"] for w in M["windings"]] | |
| n = len(ids) | |
| layers = [{ | |
| "id": "xray", "role": "ct", "label": "X‑ray", "atlas": f"{d}/atlas_ct.webp", "atlasFallback": f"{d}/atlas_ct.jpg", | |
| "sizeHint": os.path.getsize(f"{ROOT}/{d}/atlas_ct.webp"), | |
| "title": "Raw X-ray CT brightness on each segment. No ink detection.", | |
| "hint": "Raw X-ray CT brightness, no ink detection.", | |
| "source": f"Vesuvius Challenge surface volumes, {um(c['ct'])} scan", "resolutionUM": c["ct"], | |
| }] | |
| if c.get("ink"): | |
| layers.append({ | |
| "id": "ink", "role": "ink", "label": f"Published ink ({um(c['ink'])})", "atlas": f"{d}/atlas_ink.webp", | |
| "atlasFallback": f"{d}/atlas_ink.jpg", "sizeHint": os.path.getsize(f"{ROOT}/{d}/atlas_ink.webp"), | |
| "hi": f"{d}/hi/{{id}}.jpg", | |
| "title": f"Vesuvius Challenge's published ink detection on the {um(c['ink'])} scan.", | |
| "hint": f"Published ink ({um(c['ink'])}): Vesuvius Challenge detection on the {um(c['ink'])} scan.", | |
| "closeupLabel": f"Published ink ({um(c['ink'])})", | |
| "source": "Vesuvius Challenge ink detection (ink-detection/downsampled), open data bucket", | |
| "resolutionUM": c["ink"], | |
| }) | |
| if c.get("ink1") and os.path.isdir(f"{ROOT}/{d}/ink1"): | |
| cov = [i for i in ids if os.path.exists(f"{ROOT}/{d}/ink1/{i}.jpg")] | |
| layers.append({ | |
| "id": "ink1", "role": "overlay", "label": f"Published ink ({um(c['ink1'])})", | |
| "windings": cov if len(cov) < n else "all", | |
| "texture": f"{d}/ink1/{{id}}.jpg", "hi": f"{d}/hi/{{id}}_1um.jpg", "sizeHint": 400000, | |
| "title": f"Vesuvius Challenge's published ink detection on the finer {um(c['ink1'])} scan, on {len(cov)} of {n} segments.", | |
| "hint": f"Published ink ({um(c['ink1'])}): Vesuvius Challenge detection on the {um(c['ink1'])} scan, {len(cov)} of {n} segments.", | |
| "closeupLabel": f"Published ink ({um(c['ink1'])})", "readoutLabel": "INK 1 µm", | |
| "bandTitle": f"Segments with published ink on the {um(c['ink1'])} scan", | |
| "source": "Vesuvius Challenge ink detection (ink-detection/downsampled), open data bucket", | |
| "resolutionUM": c["ink1"], | |
| }) | |
| notes = ("Meshes, X-ray and ink images come only from the open data bucket vesuvius-challenge-open-data " | |
| f"(s3://vesuvius-challenge-open-data/{sid}/), licensed CC BY-NC 4.0: attribution, non-commercial use. " | |
| "This page shows images only: no transcriptions or readings of the text.") | |
| if c.get("prize"): | |
| notes += " This scroll is prize eligible on scrollprize.org; no ink model is run on it here." | |
| credits = {"text": "Vesuvius Challenge", "url": f"https://scrollprize.org/data_browser/{sid}", "citation": CITE, | |
| "holder": c["holder"]} | |
| if c.get("educelab"): | |
| credits["citation"] = CITE + " " + EDUCELAB | |
| k = len([l for l in layers if l["role"] != "ct"]) | |
| kind = "X-ray only, no ink layer" if not k else ("one published ink layer" if k == 1 else f"{['', '', 'two', 'three', 'four'][k] if k < 5 else k} published ink layers") | |
| man = { | |
| "schema": "unroll-scroll/1", "id": sid, "name": c["name"], | |
| "description": f"A carbonized Herculaneum papyrus scanned at {c['scan']}. {n} traced segments from the Vesuvius Challenge open data, {kind}.", | |
| "voxelMM": c["vox"] / 1000, "base": "../../", | |
| "geometry": {"format": "grid-int16", "index": f"{d}/scroll.json", "bin": f"{d}/scroll.bin", | |
| "sizeHint": os.path.getsize(f"{ROOT}/{d}/scroll.bin"), | |
| "source": f"Vesuvius Challenge {um(c['vox'])} tifxyz meshes, decimated by tools/build.py"}, | |
| "windings": ids, "outermost": "last", | |
| "layers": layers, | |
| "credits": credits, | |
| "dataTerms": {"license": "CC BY‑NC 4.0", "url": "https://creativecommons.org/licenses/by-nc/4.0/", "notes": notes}, | |
| "notes": "Segment ids w001 and up are ours, ordered by median radius (innermost first); scroll.json keeps each source segment.", | |
| } | |
| os.makedirs(f"{ROOT}/scrolls/{sid}", exist_ok=True) | |
| json.dump(man, open(f"{ROOT}/scrolls/{sid}/manifest.json", "w"), indent=1, ensure_ascii=False) | |
| reg = json.load(open(f"{ROOT}/scrolls/index.json")) | |
| entry = {"id": sid, "name": c["name"], "manifest": f"scrolls/{sid}/manifest.json", | |
| "prize": {"eligible": bool(c.get("prize")), "sets": c.get("prize", []), | |
| "source": "https://scrollprize.org/prizes", "checked": CHECKED}} | |
| reg["scrolls"] = [e for e in reg["scrolls"] if e["id"] != sid] + [entry] | |
| for e in reg["scrolls"]: | |
| e.setdefault("prize", {"eligible": False, "sets": [], "source": "https://scrollprize.org/prizes", "checked": CHECKED}) | |
| json.dump(reg, open(f"{ROOT}/scrolls/index.json", "w"), indent=1, ensure_ascii=False) | |
| print("wrote", sid, n, "segments,", [l["id"] for l in layers]) | |
| if __name__ == "__main__": | |
| main(sys.argv[1]) | |