Download scripts/precompute.py from zcemg08/GSOlabels: direct link, hf CLI and curl.
- Browser
- Download file 1.25 kB
-
https://huggingface.co/spaces/zcemg08/GSOlabels/resolve/main/scripts/precompute.py
- Command line
-
hf download hf://spaces/zcemg08/GSOlabels/scripts/precompute.py
-
curl -L -o precompute.py https://huggingface.co/spaces/zcemg08/GSOlabels/resolve/main/scripts/precompute.py
1.25 kB
| """Batch measurement cache builder; malformed meshes do not abort the batch.""" | |
| import argparse | |
| import json | |
| import sys | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path(__file__).resolve().parents[1])) | |
| from labeler.dataset import discover, cached_measure | |
| def main(): | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument('--data', required=True) | |
| parser.add_argument('--out', default='cache') | |
| parser.add_argument('--method', choices=['pca', 'minimum', 'axis_aligned'], default='pca') | |
| parser.add_argument('--trim', type=float, default=0.0) | |
| args = parser.parse_args() | |
| objects = discover(args.data) | |
| if not objects: | |
| parser.error('No mesh files found.') | |
| failed = [] | |
| for item in objects: | |
| try: | |
| cached_measure(item, args.out, args.method, args.trim) | |
| print(f"OK {item['object_id']}") | |
| except Exception as exc: | |
| failed.append({'object_id': item['object_id'], 'error': str(exc)}) | |
| print(f"FAILED {item['object_id']}: {exc}", file=sys.stderr) | |
| Path(args.out).mkdir(parents=True, exist_ok=True) | |
| (Path(args.out) / 'failures.json').write_text(json.dumps(failed, indent=2)) | |
| return bool(failed) | |
| if __name__ == '__main__': | |
| sys.exit(main()) | |