eslamESssamM commited on
Commit
75f1144
·
verified ·
1 Parent(s): 501b4ac

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +11 -0
main.py CHANGED
@@ -124,6 +124,17 @@ async def lifespan(app: FastAPI):
124
  if os.path.exists("solar_model.pt"):
125
  ckpt = torch.load("solar_model.pt", map_location='cpu')
126
  sd = ckpt['model_state_dict'] if isinstance(ckpt, dict) and 'model_state_dict' in ckpt else ckpt
 
 
 
 
 
 
 
 
 
 
 
127
  model = SolarPINN()
128
  model.load_state_dict(sd, strict=True)
129
  ml_assets["solar_model"] = model.eval()
 
124
  if os.path.exists("solar_model.pt"):
125
  ckpt = torch.load("solar_model.pt", map_location='cpu')
126
  sd = ckpt['model_state_dict'] if isinstance(ckpt, dict) and 'model_state_dict' in ckpt else ckpt
127
+ # Remap keys if needed
128
+ if any(k.startswith('physics_layer.') for k in sd.keys()):
129
+ new_sd = {}
130
+ for k, v in sd.items():
131
+ if k == 'physics_layer.log_thermal_mass':
132
+ new_sd['log_thermal_mass'] = v
133
+ elif k == 'physics_layer.log_h_conv':
134
+ new_sd['log_h_conv'] = v
135
+ else:
136
+ new_sd[k] = v
137
+ sd = new_sd
138
  model = SolarPINN()
139
  model.load_state_dict(sd, strict=True)
140
  ml_assets["solar_model"] = model.eval()