Download example_inference.py from Rakib/PhyGHT-mu60: direct link, hf CLI and curl.
- Browser
- Download file 635 Bytes
-
https://huggingface.co/Rakib/PhyGHT-mu60/resolve/main/example_inference.py
- Command line
-
hf download hf://Rakib/PhyGHT-mu60/example_inference.py
-
curl -L -o example_inference.py https://huggingface.co/Rakib/PhyGHT-mu60/resolve/main/example_inference.py
635 Bytes
| import json | |
| import os | |
| os.environ.setdefault("CUBLAS_WORKSPACE_CONFIG", ":4096:8") | |
| from pathlib import Path | |
| import numpy as np | |
| import torch | |
| from portable_io import load_model, predict_event | |
| folder = Path(__file__).resolve().parent | |
| device = "cuda" if torch.cuda.is_available() else "cpu" | |
| model = load_model(folder, device=device) | |
| event = json.loads((folder / "example_event.json").read_text()) | |
| predictions = predict_event(model, event, device=device) | |
| if device == "cuda": | |
| np.testing.assert_allclose(predictions, np.load(folder / "example_expected.npy"), rtol=1e-5, atol=1e-6) | |
| print("energy_fraction, mass_fraction", predictions[:5]) | |