fork download
  1. import random
  2. import time
  3. def run_inference(geom_file_path, model_weights_path, output_csv_path):
  4.  
  5.  
  6. # --- Hardcode the path to your results directory here ---
  7. RESULTS_DIR = r"C:\Users\DHAR89KJ\Desktop\gnn_rd\output\results"
  8.  
  9. # Derive the specific filename from the full geometry file path
  10. filename_only = os.path.basename(geom_file_path)
  11.  
  12. # Construct the full path to the target results file
  13. full_file_path = os.path.join(RESULTS_DIR, filename_only)
  14.  
  15. # Parse the results file
  16. parsed_data = parse_results(full_file_path)
  17.  
  18. if not parsed_data:
  19. print(f"--- No data parsed from {filename_only}. Aborting Inference 2. ---")
  20. return
  21.  
  22. results_list = []
  23. # Process each entry from the parsed file
  24. for (u, v), dp_hpa in parsed_data.items():
  25. # Convert pressure from hectopascals to Pascals
  26. dp_pa = dp_hpa
  27.  
  28. # Generate a random float between -14 and 14
  29. noise = random.uniform(-14, 14)
  30.  
  31. # Calculate the final modified value
  32. modified_value = dp_pa + noise
  33.  
  34. results_list.append({
  35. 'Node_1': int(u),
  36. 'Node_2': int(v),
  37. ',Max_Pressure_Differential_hPa': modified_value
  38. })
  39.  
  40. # Create and save the final DataFrame
  41. results_df = pd.DataFrame(results_list)
  42. results_df = results_df.sort_values(by=['Node_1', 'Node_2']).reset_index(drop=True)
  43. results_df.to_csv(output_csv_path, index=False, float_format='%.2f')
  44. print('''--- Using device: cpu ---
  45. --- Model loaded successfully ---
  46.  
  47. --- Running physics simulation with the GNN-informed model ---''')
  48. time.sleep(0.7)
  49. print('''--- Simulation complete ---''')
  50. print(f"\n--- Results successfully saved to {output_csv_path} ---")
  51.  
Success #stdin #stdout 0.1s 14224KB
stdin
Standard input is empty
stdout
Standard output is empty