Download tools/preview_tasks.py from HuggingAI4Engineering/CADGenBench: direct link, hf CLI and curl.
- Browser
- Download file 1.44 kB
-
https://huggingface.co/spaces/HuggingAI4Engineering/CADGenBench/resolve/main/tools/preview_tasks.py
- Command line
-
hf download hf://spaces/HuggingAI4Engineering/CADGenBench/tools/preview_tasks.py
-
curl -L -o preview_tasks.py https://huggingface.co/spaces/HuggingAI4Engineering/CADGenBench/resolve/main/tools/preview_tasks.py
1.44 kB
| """Local preview for the Tasks tab. | |
| Renders the task-browser page from the *local* data clones | |
| (``cadgenbench-data`` + ``cadgenbench-data-gt`` at the repo root) and | |
| writes a standalone HTML file you can open in a browser. Image URLs are | |
| relative paths into those local folders, so the output must live at the | |
| workspace root for the relative paths to resolve. | |
| Usage:: | |
| python cadgenbench-leaderboard/tools/preview_tasks.py | |
| # writes <workspace>/tasks-preview.html | |
| """ | |
| from __future__ import annotations | |
| import sys | |
| from pathlib import Path | |
| # Make `tasks` importable when run from anywhere. | |
| LEADERBOARD_DIR = Path(__file__).resolve().parent.parent | |
| sys.path.insert(0, str(LEADERBOARD_DIR)) | |
| from tasks import load_tasks_from_dir, render_tasks_page # noqa: E402 | |
| WORKSPACE = LEADERBOARD_DIR.parent | |
| INPUTS_DIR = WORKSPACE / "cadgenbench-data" | |
| GT_DIR = WORKSPACE / "cadgenbench-data-gt" | |
| OUT = WORKSPACE / "tasks-preview.html" | |
| def main() -> int: | |
| tasks = load_tasks_from_dir(INPUTS_DIR) | |
| def asset_url(fixture: str, relpath: str) -> str: | |
| return f"cadgenbench-data/{fixture}/{relpath}" | |
| doc = render_tasks_page(tasks, asset_url) | |
| OUT.write_text(doc) | |
| n_edit = sum(1 for t in tasks if t["task_type"] == "editing") | |
| print( | |
| f"Wrote {OUT} ({len(tasks)} tasks, {n_edit} editing, " | |
| f"{OUT.stat().st_size // 1024} KB)" | |
| ) | |
| return 0 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |