Skip to content

Commit 03c77c2

Browse files
committed
update release flow; bugfix
1 parent 63f682a commit 03c77c2

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

resources/anonymise_nnunet_pkl_v2.py

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import os
2+
import sys
3+
import pickle
4+
import shutil
5+
from pathlib import Path
6+
7+
8+
if __name__ == "__main__":
9+
"""
10+
Remove elements with Subject IDs from nnunet results.
11+
12+
Also deleting the training log because in there are also the IDs.
13+
14+
usage:
15+
16+
cd $RESULTS_FOLDER
17+
anonymise_nnunet_pkl_v2.py nnUNet/3d_fullres/Dataset291_TotalSegmentator_part1_organs_1559subj/nnUNetTrainerNoMirroring__nnUNetPlans__3d_fullres
18+
nnUNet_export_model_to_zip -t 291 -o dataset_291_upload.zip -c 3d_fullres -tr nnUNetTrainerV2 --not_strict
19+
"""
20+
dir_in = Path(sys.argv[1])
21+
22+
folds = sorted(list(dir_in.glob("fold_*")))
23+
print(f"Nr of folds found: {len(folds)}")
24+
25+
# Anonymise model_final_checkpoint.model.pkl for all folds
26+
for fold_dir in folds:
27+
28+
# Remove unneeded files and directories
29+
for dir in [fold_dir / "validation"]:
30+
if dir.exists():
31+
print(f"Deleting: {dir}")
32+
shutil.rmtree(dir)
33+
34+
for file in [fold_dir / "checkpoint_best.pth"]:
35+
if file.exists():
36+
print(f"Deleting: {file}")
37+
os.remove(file)
38+
39+
training_logs = fold_dir.glob("training_log_*")
40+
for log in training_logs:
41+
if log.exists():
42+
print(f"Deleting: {log}")
43+
os.remove(log)

resources/package_management.md

+4
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,9 @@ INFO: Now all done by `release.sh`
2626

2727

2828
## Release new weights
29+
* `cd /mnt/nvme/data/multiseg/weights_upload/totalsegmentator_v2`
30+
* `cp -r $nnUNet_results/Dataset527_breasts_1559subj .`
31+
* `python ~/dev/TotalSegmentator/resources/anonymise_nnunet_pkl_v2.py Dataset527_breasts_1559subj/nnUNetTrainer_DASegOrd0_NoMirroring__nnUNetPlans__3d_fullres`
32+
* `zip -r Dataset527_breasts_1559subj.zip Dataset527_breasts_1559subj`
2933
* Click on "Draft a new release" on github
3034
* Create new tag ending with -weights and upload weights

totalsegmentator/libs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ def download_pretrained_weights(task_id):
301301
WEIGHTS_URL = url + "/v2.4.0-weights/Dataset008_HepaticVessel.zip"
302302
elif task_id == 913:
303303
weights_path = config_dir / "Dataset913_lung_nodules"
304-
WEIGHTS_URL = url + "/v2.4.0-weights/Dataset913_lung_nodules.zip" # TODO: correct url
304+
WEIGHTS_URL = url + "/v2.5.0-weights/Dataset913_lung_nodules.zip"
305305

306306
# Commercial models
307307
elif task_id == 304:

0 commit comments

Comments
 (0)