Skip to content

Commit

Permalink
Change checkpoint_latest to checkpoint_best in inference script
Browse files Browse the repository at this point in the history
Fixes #78

Change `checkpoint_latest.pth` to `checkpoint_best.pth` in the inference script.

* Update line 301 in `totalspineseg/inference.py` to use `checkpoint_best.pth` instead of `checkpoint_latest.pth`.
* Update line 552 in `totalspineseg/inference.py` to use `checkpoint_best.pth` instead of `checkpoint_latest.pth`.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/neuropoly/totalspineseg/issues/78?shareId=XXXX-XXXX-XXXX-XXXX).
  • Loading branch information
yw7 committed Nov 15, 2024
1 parent ad65523 commit ed745ae
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions totalspineseg/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def main():
# Get the nnUNet parameters from the results folder
nnUNetTrainer, nnUNetPlans, configuration = next((nnUNet_results / step1_dataset).glob('*/fold_*')).parent.name.split('__')
# Check if the final checkpoint exists, if not use the latest checkpoint
checkpoint = 'checkpoint_final.pth' if (nnUNet_results / step1_dataset / f'{nnUNetTrainer}__{nnUNetPlans}__{configuration}' / f'fold_{fold}' / 'checkpoint_final.pth').is_file() else 'checkpoint_latest.pth'
checkpoint = 'checkpoint_final.pth' if (nnUNet_results / step1_dataset / f'{nnUNetTrainer}__{nnUNetPlans}__{configuration}' / f'fold_{fold}' / 'checkpoint_final.pth').is_file() else 'checkpoint_best.pth'

if not quiet: print('\n' 'Running step 1 model:')
subprocess.run([
Expand Down Expand Up @@ -549,7 +549,7 @@ def main():
# Get the nnUNet parameters from the results folder
nnUNetTrainer, nnUNetPlans, configuration = next((nnUNet_results / step2_dataset).glob('*/fold_*')).parent.name.split('__')
# Check if the final checkpoint exists, if not use the latest checkpoint
checkpoint = 'checkpoint_final.pth' if (nnUNet_results / step2_dataset / f'{nnUNetTrainer}__{nnUNetPlans}__{configuration}' / f'fold_{fold}' / 'checkpoint_final.pth').is_file() else 'checkpoint_latest.pth'
checkpoint = 'checkpoint_final.pth' if (nnUNet_results / step2_dataset / f'{nnUNetTrainer}__{nnUNetPlans}__{configuration}' / f'fold_{fold}' / 'checkpoint_final.pth').is_file() else 'checkpoint_best.pth'

if not quiet: print('\n' 'Running step 2 model:')
subprocess.run([
Expand Down

0 comments on commit ed745ae

Please sign in to comment.