carmelog commited on
Commit
d066e2c
·
1 Parent(s): aad9aa6

feat: auto select best checkpoint

Browse files
Files changed (1) hide show
  1. domino-training-test.ipynb +7 -2
domino-training-test.ipynb CHANGED
@@ -1052,9 +1052,14 @@
1052
  " surf_factors = None # If not available, set to None\n",
1053
  " \n",
1054
  " # Load the best model checkpoint\n",
1055
- " best_checkpoint = torch.load(CHECKPOINT_DIR / f\"best_model/DoMINO.0.{CKPT_NUMBER}.pt\")\n",
 
 
 
 
 
1056
  " model.load_state_dict(best_checkpoint) # Load the model state\n",
1057
- " print(\"Model loaded\")\n",
1058
  " \n",
1059
  " # Set the path to save predictions\n",
1060
  " pred_save_path = SAVE_PATH\n",
 
1052
  " surf_factors = None # If not available, set to None\n",
1053
  " \n",
1054
  " # Load the best model checkpoint\n",
1055
+ " best_checkpoint = torch.load(\n",
1056
+ " max(\n",
1057
+ " (CHECKPOINT_DIR / \"best_model\").glob(\"DoMINO.0.*.pt\"),\n",
1058
+ " key=lambda p: p.stat().st_mtime,\n",
1059
+ " )\n",
1060
+ " )\n",
1061
  " model.load_state_dict(best_checkpoint) # Load the model state\n",
1062
+ " print(f\"Model loaded: {best_checkpoint}\")\n",
1063
  " \n",
1064
  " # Set the path to save predictions\n",
1065
  " pred_save_path = SAVE_PATH\n",