Release 212 reviewed cBAD spreads, archive-held-out gutter evaluation, reproducible baselines and a reviewed PNG splitter.
6a484d2 verified Download render.py from foliokestrel/folio-spread-bench: direct link, hf CLI and curl.
- Browser
- Download file 1.19 kB
-
https://huggingface.co/datasets/foliokestrel/folio-spread-bench/resolve/main/render.py
- Command line
-
hf download hf://datasets/foliokestrel/folio-spread-bench/render.py
-
curl -L -o render.py https://huggingface.co/datasets/foliokestrel/folio-spread-bench/resolve/main/render.py
1.19 kB
| """Render all three input views from the original cBAD ZIP.""" | |
| import argparse | |
| from io import BytesIO | |
| import json | |
| from pathlib import Path | |
| from zipfile import ZipFile | |
| from PIL import Image | |
| from views import make_view | |
| def render(archive, rows, out): | |
| out.mkdir(exist_ok=True,parents=True) | |
| with ZipFile(archive) as source: | |
| for row in rows: | |
| with Image.open(BytesIO(source.read(row['image']))) as raw: | |
| if raw.size!=(row['width'],row['height']): | |
| raise ValueError(f"Source dimensions changed for {row['image']}") | |
| raw.thumbnail((1280,1280),Image.Resampling.LANCZOS) | |
| image=raw.convert('RGB') | |
| for view in ('native','offset','oblique'): | |
| path=out/f"{row['id']}-{view}.png" | |
| make_view(image,row['id'],view).save(path) | |
| if __name__=='__main__': | |
| cli=argparse.ArgumentParser(description=__doc__) | |
| cli.add_argument('archive',type=Path) | |
| cli.add_argument('manifest',type=Path) | |
| cli.add_argument('out',type=Path) | |
| args=cli.parse_args() | |
| render(args.archive,[json.loads(s) for s in args.manifest.read_text().splitlines() if s.strip()],args.out) | |