Download proj2rep/calibrate_cli.py from markjiang1/Proj2Rep-CTFM: direct link, hf CLI and curl.
- Browser
- Download file 1.17 kB
-
https://huggingface.co/markjiang1/Proj2Rep-CTFM/resolve/main/proj2rep/calibrate_cli.py
- Command line
-
hf download hf://markjiang1/Proj2Rep-CTFM/proj2rep/calibrate_cli.py
-
curl -L -o calibrate_cli.py https://huggingface.co/markjiang1/Proj2Rep-CTFM/resolve/main/proj2rep/calibrate_cli.py
1.17 kB
| """Calibrate each manufacturer's geometric convention against the scanner images. | |
| python -m proj2rep calibrate --data DATA --work WORK | |
| Writes WORK/convention.json (needed by every later step) and draws the cross-validation folds | |
| (WORK/folds.csv) if cases.csv has no fold column. | |
| """ | |
| import argparse | |
| from pathlib import Path | |
| import torch | |
| from .data import load_cohort | |
| from .geometry import calibrate | |
| def main(argv=None): | |
| p = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) | |
| p.add_argument("--data", required=True) | |
| p.add_argument("--work", required=True) | |
| p.add_argument("--folds", type=int, default=5) | |
| p.add_argument("--cases-per-manufacturer", type=int, default=3) | |
| p.add_argument("--device", default="cuda:0" if torch.cuda.is_available() else "cpu") | |
| a = p.parse_args(argv) | |
| cohort = load_cohort(a.data, folds=a.folds, work_dir=a.work) | |
| print(f"{len(cohort.table)} cases, folds:", cohort.table.fold.value_counts().sort_index().to_dict(), flush=True) | |
| calibrate(cohort, Path(a.work) / "convention.json", a.device, a.cases_per_manufacturer) | |
| if __name__ == "__main__": | |
| main() | |