Download code/eval/score.py from MRBSTUDIO/AGT: direct link, hf CLI and curl.
- Browser
- Download file 1.49 kB
-
https://huggingface.co/MRBSTUDIO/AGT/resolve/main/code/eval/score.py
- Command line
-
hf download hf://MRBSTUDIO/AGT/code/eval/score.py
-
curl -L -o score.py https://huggingface.co/MRBSTUDIO/AGT/resolve/main/code/eval/score.py
1.49 kB
| import argparse | |
| import json | |
| from pathlib import Path | |
| import sys | |
| REPO = Path(__file__).resolve().parents[1] | |
| sys.path.insert(0, str(REPO)) | |
| from agt.eval.scorer import score | |
| PATH_KEYS = ('data_root', 'export', 'method', 'out') | |
| def main(argv=None): | |
| parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter) | |
| parser.add_argument('--config', type=Path, required=True) | |
| parser.add_argument('--data-root', dest='data_root') | |
| parser.add_argument('--export', help='exported clip set (manifest.json + <clip>/clip.json)') | |
| parser.add_argument('--method', help='method directory (meta.json + <clip>/frames.npz, optional depth_meta.json + <clip>/depth.npz)') | |
| parser.add_argument('--out') | |
| parser.add_argument('--device', choices=('cpu', 'cuda')) | |
| parser.add_argument('--clips', nargs='+', help='score only these clip ids') | |
| args = parser.parse_args(argv) | |
| config = json.loads(args.config.read_text()) | |
| for key in PATH_KEYS: | |
| if config.get(key) is not None and not Path(config[key]).is_absolute(): | |
| config[key] = str(REPO / config[key]) | |
| for key in (*PATH_KEYS, 'device', 'clips'): | |
| if getattr(args, key) is not None: | |
| config[key] = getattr(args, key) | |
| missing = [k for k in PATH_KEYS if not config.get(k)] | |
| if missing: | |
| parser.error('missing ' + ', '.join(missing)) | |
| result = score(config) | |
| print(json.dumps(result['metrics'], indent=1)) | |
| if __name__ == '__main__': | |
| main() | |