The training data and initial maps can be downloaded with the command
net_download autocontext_mr_ct_model_zoo
(Replace net_download
with python net_download.py
if you cloned the NiftyNet repository.)
Command line parameters: --starting_iter 1 --max_iter 500
python net_regress.py train \
-c ~/niftynet/extensions/autocontext_mr_ct/net_autocontext.ini \
--starting_iter 0 --max_iter 500
Command line parameters: --spatial_window_size 240,240,1 --batch_size 4
modify the inference batch size and window size for efficiency purpose.
The contexts will be generated to
~/niftynet/models/autocontext_mr_ct/autocontext_output
.
python net_regress.py inference \
-c ~/niftynet/extensions/autocontext_mr_ct/net_autocontext.ini \
--inference_iter 500 --spatial_window_size 240,240,1 --batch_size 4 --dataset_split_file nofile
Command line parameters --starting_iter -1
indicate training the model from the most recently saved checkpoint (at iteration 500).
python net_regress.py train \
-c ~/niftynet/extensions/autocontext_mr_ct/net_autocontext.ini \
--starting_iter -1 --max_iter 1000
Alternating in between context generation and training: (from git cloned source code)
python net_download.py autocontext_mr_ct_model_zoo
python net_regress.py train \
-c ~/niftynet/extensions/autocontext_mr_ct/net_autocontext.ini \
--starting_iter 0 --max_iter 500
for max_iter in `seq 1000 1000 10000`
do
python net_regress.py inference \
-c ~/niftynet/extensions/autocontext_mr_ct/net_autocontext.ini \
--inference_iter -1 --spatial_window_size 240,240,1 --batch_size 4 --dataset_split_file nofile
python net_regress.py train \
-c ~/niftynet/extensions/autocontext_mr_ct/net_autocontext.ini \
--starting_iter -1 --max_iter $max_iter
done
This script runs training for 10000 iterations, and new training contexts are generated at every 1000 iterations.
To see the training/validation curves using tensorboard:
tensorboard --logdir ~/niftynet/models/autocontext_mr_ct/logs
Finally regression maps could be found at ~/niftynet/models/autocontext_mr_ct/autocontext_output/
.
To make inferences using the sequence of trained models:
# reset the initial estimation folder:
net_download autocontext_mr_ct_model_zoo -r
python net_regress.py inference \
-c ~/niftynet/extensions/autocontext_mr_ct/net_autocontext.ini \
--inference_iter 500 --spatial_window_size 240,240,1 --batch_size 4 \
--dataset_split_file nofile
for max_iter in `seq 1000 1000 10000`
do
python net_regress.py inference \
-c ~/niftynet/extensions/autocontext_mr_ct/net_autocontext.ini \
--inference_iter $max_iter --spatial_window_size 240,240,1 --batch_size 4 \
--dataset_split_file nofile
done