Download scripts/inference.py from OneScience-Group/AI-GAMFS: direct link, hf CLI and curl.
- Browser
- Download file 707 Bytes
-
https://huggingface.co/OneScience-Group/AI-GAMFS/resolve/main/scripts/inference.py
- Command line
-
hf download hf://OneScience-Group/AI-GAMFS/scripts/inference.py
-
curl -L -o inference.py https://huggingface.co/OneScience-Group/AI-GAMFS/resolve/main/scripts/inference.py
707 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.ai_gamfs import * | |
| c=cfg(R);z=torch.load(R/c['paths']['checkpoint'],map_location='cpu',weights_only=True);m=AIGAMFS(**z['model_config']);m.load_state_dict(z['model']);x=state(20)[None];seq=[] | |
| with torch.no_grad(): | |
| for h in range(3,121,3):lead=max(v for v in (12,9,6,3) if v<=120-(h-3));x=m(x,lead);seq.append(x[0].numpy()) | |
| p=R/c['paths']['predictions'];p.parent.mkdir(parents=True,exist_ok=True);np.savez_compressed(p,prediction=seq,target=[state(20,h).numpy() for h in range(3,121,3)],lead_hours=np.arange(3,121,3),logical_shape=[54,361,576],is_complete_global=False);print(p) | |