Download scripts/inference.py from OneScience-Group/GRACE-SEDA: direct link, hf CLI and curl.
- Browser
- Download file 636 Bytes
-
https://huggingface.co/OneScience-Group/GRACE-SEDA/resolve/main/scripts/inference.py
- Command line
-
hf download hf://OneScience-Group/GRACE-SEDA/scripts/inference.py
-
curl -L -o inference.py https://huggingface.co/OneScience-Group/GRACE-SEDA/resolve/main/scripts/inference.py
636 Bytes
| from pathlib import Path | |
| import sys,numpy as np,torch | |
| R=Path(__file__).resolve().parents[1];sys.path.insert(0,str(R));from model.grace_seda import * | |
| c=cfg(R);d=np.load(R/c['data']['path']);z=torch.load(R/c['paths']['checkpoint'],map_location='cpu',weights_only=True);x=torch.tensor(d['input']);pred=[] | |
| with torch.no_grad(): | |
| for s in z['states']:m=GRACESEDA(**z['model_config']);m.load_state_dict(s);pred.append(m(x).numpy()) | |
| p=R/c['paths']['predictions'];p.parent.mkdir(parents=True,exist_ok=True);np.savez_compressed(p,ensemble=pred,grace=d['input'][:,0],wghm=d['input'][:,1],mean=np.mean(pred,0),uncertainty=np.std(pred,0));print(p) | |