Spaces:
Paused
Paused
Download scripts/run_learned_batch.py from modventures/iris: direct link, hf CLI and curl.
- Browser
- Download file 1.27 kB
-
https://huggingface.co/spaces/modventures/iris/resolve/main/scripts/run_learned_batch.py
- Command line
-
hf download hf://spaces/modventures/iris/scripts/run_learned_batch.py
-
curl -L -o run_learned_batch.py https://huggingface.co/spaces/modventures/iris/resolve/main/scripts/run_learned_batch.py
1.27 kB
| """Run the same learned review path used by the API on all prepared client pairs.""" | |
| import argparse,json,sys | |
| from pathlib import Path | |
| sys.path.insert(0,str(Path(__file__).resolve().parents[1])) | |
| import cv2 | |
| from backend.review import review_pair | |
| ROOT=Path(__file__).resolve().parents[1];SOURCE=ROOT/'private_benchmarks/client_iris' | |
| parser=argparse.ArgumentParser() | |
| parser.add_argument('--output',type=Path,default=ROOT/'private_benchmarks/learned_batch') | |
| OUT=parser.parse_args().output | |
| OUT.mkdir(parents=True,exist_ok=True) | |
| rows=[] | |
| for entry in json.loads((SOURCE/'metrics.json').read_text()): | |
| sample=entry['sample'];folder=OUT/sample;folder.mkdir(exist_ok=True) | |
| reference=cv2.imread(str(SOURCE/sample/'reference.png'));moving=cv2.imread(str(SOURCE/sample/'moving.png')) | |
| result=review_pair(reference,moving,engine='learned') | |
| for name,value in result.items(): | |
| if name!='metrics':cv2.imwrite(str(folder/(name+'.png')),value) | |
| row=dict(sample=sample,reference=entry['reference'],moving=entry['moving'],metrics=result['metrics']) | |
| rows.append(row);(OUT/'results.json').write_text(json.dumps(rows,indent=2)) | |
| print(json.dumps(dict(sample=sample,status=result['metrics']['status'],evaluation=result['metrics'].get('evaluation'))),flush=True) | |