Skip to content

Commit

Permalink
update release flow; bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
wasserth committed Jan 15, 2025
1 parent 63f682a commit 03c77c2
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
43 changes: 43 additions & 0 deletions resources/anonymise_nnunet_pkl_v2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import os
import sys
import pickle
import shutil
from pathlib import Path


if __name__ == "__main__":
"""
Remove elements with Subject IDs from nnunet results.
Also deleting the training log because in there are also the IDs.
usage:
cd $RESULTS_FOLDER
anonymise_nnunet_pkl_v2.py nnUNet/3d_fullres/Dataset291_TotalSegmentator_part1_organs_1559subj/nnUNetTrainerNoMirroring__nnUNetPlans__3d_fullres
nnUNet_export_model_to_zip -t 291 -o dataset_291_upload.zip -c 3d_fullres -tr nnUNetTrainerV2 --not_strict
"""
dir_in = Path(sys.argv[1])

folds = sorted(list(dir_in.glob("fold_*")))
print(f"Nr of folds found: {len(folds)}")

# Anonymise model_final_checkpoint.model.pkl for all folds
for fold_dir in folds:

# Remove unneeded files and directories
for dir in [fold_dir / "validation"]:
if dir.exists():
print(f"Deleting: {dir}")
shutil.rmtree(dir)

for file in [fold_dir / "checkpoint_best.pth"]:
if file.exists():
print(f"Deleting: {file}")
os.remove(file)

training_logs = fold_dir.glob("training_log_*")
for log in training_logs:
if log.exists():
print(f"Deleting: {log}")
os.remove(log)
4 changes: 4 additions & 0 deletions resources/package_management.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,9 @@ INFO: Now all done by `release.sh`


## Release new weights
* `cd /mnt/nvme/data/multiseg/weights_upload/totalsegmentator_v2`
* `cp -r $nnUNet_results/Dataset527_breasts_1559subj .`
* `python ~/dev/TotalSegmentator/resources/anonymise_nnunet_pkl_v2.py Dataset527_breasts_1559subj/nnUNetTrainer_DASegOrd0_NoMirroring__nnUNetPlans__3d_fullres`
* `zip -r Dataset527_breasts_1559subj.zip Dataset527_breasts_1559subj`
* Click on "Draft a new release" on github
* Create new tag ending with -weights and upload weights
2 changes: 1 addition & 1 deletion totalsegmentator/libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def download_pretrained_weights(task_id):
WEIGHTS_URL = url + "/v2.4.0-weights/Dataset008_HepaticVessel.zip"
elif task_id == 913:
weights_path = config_dir / "Dataset913_lung_nodules"
WEIGHTS_URL = url + "/v2.4.0-weights/Dataset913_lung_nodules.zip" # TODO: correct url
WEIGHTS_URL = url + "/v2.5.0-weights/Dataset913_lung_nodules.zip"

# Commercial models
elif task_id == 304:
Expand Down

0 comments on commit 03c77c2

Please sign in to comment.