Download scripts/inference.py from OneScience-Group/RISE-UNet: direct link, hf CLI and curl.
- Browser
- Download file 687 Bytes
-
https://huggingface.co/OneScience-Group/RISE-UNet/resolve/main/scripts/inference.py
- Command line
-
hf download hf://OneScience-Group/RISE-UNet/scripts/inference.py
-
curl -L -o inference.py https://huggingface.co/OneScience-Group/RISE-UNet/resolve/main/scripts/inference.py
687 Bytes
| from pathlib import Path | |
| import sys,numpy as np,torch | |
| ROOT=Path(__file__).resolve().parents[1];sys.path.insert(0,str(ROOT)) | |
| from model.rise_unet import * | |
| c=load_config(ROOT);ck=torch.load(ROOT/c["paths"]["checkpoint"],map_location="cpu",weights_only=True);m=RISEUNet(**ck["model_config"]);m.load_state_dict(ck["model"]);m.train();x,t=synthetic_initialization(20);pred=[] | |
| with torch.no_grad(): | |
| for w in range(5):o=m(x)[-1];pred.append(o[:,0].numpy());x=torch.cat((x[:,1:],o),1) | |
| p=ROOT/c["paths"]["predictions"];p.parent.mkdir(parents=True,exist_ok=True);np.savez_compressed(p,ensemble=np.stack(pred,1),target=t.numpy(),lead_weeks=np.arange(1,6),dropout_ensemble=np.bool_(True));print(p) | |