File size: 892 Bytes
d46a58d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | import os
import sys
from pathlib import Path
import numpy as np
PROJECT_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(PROJECT_ROOT / "model"))
from onescience.utils.YParams import YParams
def main():
os.chdir(PROJECT_ROOT)
cfg = YParams(PROJECT_ROOT / "config" / "config.yaml", "inference")
result_path = PROJECT_ROOT / cfg.output_path
if not result_path.exists():
raise FileNotFoundError(f"Result file not found: {result_path}. Run scripts/inference.py first.")
data = np.load(result_path)
prediction = data["prediction"]
target = data["target"]
mse = float(np.mean((prediction - target) ** 2))
print(f"result_path: {result_path.relative_to(PROJECT_ROOT)}")
print(f"prediction_shape: {prediction.shape}")
print(f"target_shape: {target.shape}")
print(f"mse: {mse:.8f}")
if __name__ == "__main__":
main()
|