Spaces:
Paused
Paused
Download scripts/run_learned_batch.py from modventures/iris: direct link, hf CLI and curl.
- Browser
- Download file 1.14 kB
-
https://huggingface.co/spaces/modventures/iris/resolve/6ca097e79b7c06821a20249bf7f6bfaa74836946/scripts/run_learned_batch.py
- Command line
-
hf download hf://spaces/modventures/iris@6ca097e79b7c06821a20249bf7f6bfaa74836946/scripts/run_learned_batch.py
-
curl -L -o run_learned_batch.py https://huggingface.co/spaces/modventures/iris/resolve/6ca097e79b7c06821a20249bf7f6bfaa74836946/scripts/run_learned_batch.py
1.14 kB
| """Run the same learned review path used by the API on all prepared client pairs.""" | |
| import 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';OUT=ROOT/'private_benchmarks/learned_batch';OUT.mkdir(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) | |