Views
No views yet
nnunet_predict.pyuser@machine:~/ascites_segmentation$ pip install torch torchvision torchaudio nnunet matplotlibuser@machine:~/ascites_segmentation$ python nnunet_predict.py -i file_list.txt -t TMP_DIR -o OUTPUT_FOLDER -m /path/to/nnunet/model_weights1usage: tmp.py [-h] [-i INPUT_LIST] -t TMP_FOLDER -o OUTPUT_FOLDER -m MODEL [-v]
2
3Inference using nnU-Net predict_from_folder Python API
4
5optional arguments:
6 -h, --help show this help message and exit
7 -i INPUT_LIST, --input_list INPUT_LIST
8 Input image file_list.txt
9 -t TMP_FOLDER, --tmp_folder TMP_FOLDER
10 Temporary folder
11 -o OUTPUT_FOLDER, --output_folder OUTPUT_FOLDER
12 Output Segmentation folder
13 -m MODEL, --model MODEL
14 Trained Model
15 -v, --verbose Verbose Outputmodel_weights folder should contain fold0, fold1, etc...nnUNet_predict from shelluser@machine:~/ascites_segmentation$ pip install torch torchvision torchaudio nnunet matplotlib1user@machine:~/ascites_segmentation$ export nnUNet_raw_data_base="/absolute/path/to/nnUNet_raw_data_base"
2user@machine:~/ascites_segmentation$ export nnUNet_preprocessed="/absolute/path/to/nnUNet_preprocessed"
3user@machine:~/ascites_segmentation$ export RESULTS_FOLDER="/absolute/path/to/nnUNet_trained_models"user@machine:~/ascites_segmentation$ nnUNet_predict -i INPUT_FOLDER -o OUTPUT_FOLDER -t 505 -m 3d_fullres -f N --save_npz -i: input folder of .nii.gz scans to predict. NB, filename needs to end with _0000.nii.gz to tell nnU-Net only one kind of modality-o: output folder to store predicted segmentations, automatically created if not exist-t 505: (do not change) Ascites pretrained model name-m 3d_fullres (do not change) Ascites pretrained model nameN: Ascites pretrained model fold, can be [0, 1, 2, 3, 4]--save_npz: save softmax scores, required for ensembling multiple foldsnnUNet_find_best_configuration to automatically get the inference commands needed to run the trained model on data.nnUNet_ensemble by running:user@machine:~/ascites_segmentation$ nnUNet_ensemble -f FOLDER1 FOLDER2 ... -o OUTPUT_FOLDER -pp POSTPROCESSING_FILEFOLDER1 and FOLDER2 are predicted outputs by nnUNet (requires --save_npz when running nnUNet_predict).nvidia-docker to be installed on the system (Installation Guide). This nnunet_docker predicts ascites with all 5 trained folds and ensembles output to a single prediction.nnunet_docker image from Dockerfile:user@machine:~/ascites_segmentation$ sudo docker build -t nnunet_docker .1user@machine:~/ascites_segmentation$ sudo docker run \
2--gpus 0 \
3--volume /absolute/path/to/INPUT_FOLDER:/tmp/INPUT_FOLDER \
4--volume /absolute/path/to/OUTPUT_FOLDER:/tmp/OUTPUT_FOLDER \
5nnunet_docker /bin/sh inference.sh--gpus parameter:0, 1, 2, ..., n for integer number of GPUsall for all available GPUs on the system'"device=2,3"' for specific GPU with ID--volume parameter/absolute/path/to/INPUT_FOLDER and /absolute/path/to/OUTPUT_FOLDER folders on the host system needs to be specifiedINPUT_FOLDER contains all .nii.gz volumes to be predictedOUTPUT_FOLDER1@article{hou2024deep,
2 title={Deep Learning Segmentation of Ascites on Abdominal CT Scans for Automatic Volume Quantification},
3 author={Hou, Benjamin and Lee, Sung-Won and Lee, Jung-Min and Koh, Christopher and Xiao, Jing and Pickhardt, Perry J. and Summers, Ronald M.}
4 journal={Radiology: Artificial Intelligence},
5 pages={e230601},
6 year={2024},
7 publisher={Radiological Society of North America}
8}