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