Skip to content

Commit

Permalink
tutorial notebook for boost
Browse files Browse the repository at this point in the history
  • Loading branch information
KMarshallX committed Oct 27, 2023
1 parent 989be7f commit 9993ef9
Showing 1 changed file with 75 additions and 34 deletions.
109 changes: 75 additions & 34 deletions notebooks/Module_Boost.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,16 @@
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"100%|█████████████████████████████████████| 164M/164M [00:01<00:00, 105Mbytes/s]\n",
"100%|█████████████████████████████████████| 327M/327M [00:01<00:00, 188Mbytes/s]\n"
]
}
],
"source": [
"# Download the data\n",
"!osf -p nr6gc fetch /osfstorage/twoEchoTOF/withSkull/GRE_3D_400um_TR20_FA18_TE7p5_14_sli52_FCY_GMP_BW200_32_biasCor.nii ./../../data/img/GRE_400um.nii\n",
Expand All @@ -46,14 +55,16 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Training session will start shortly..\n",
"./../../saved_imgs/boost_generated_label/ does not exist.\n",
"./../../saved_imgs/boost_generated_label/ has been created!\n",
"Boosting session will start shortly..\n",
"Parameters Info:\n",
"*************************************************************\n",
"\n",
Expand All @@ -63,26 +74,40 @@
"\n",
"Aborting the preprocessing procedure!\n",
"\n",
"Epoch: [1/10], Loss: 0.9747, Current learning rate: 0.00100000 \n",
"Epoch: [2/10], Loss: 0.9976, Current learning rate: 0.00100000 \n",
"Epoch: [3/10], Loss: 0.9784, Current learning rate: 0.00100000 \n",
"Epoch: [4/10], Loss: 0.9882, Current learning rate: 0.00095000 \n",
"Epoch: [5/10], Loss: 0.9683, Current learning rate: 0.00095000 \n",
"Epoch: [6/10], Loss: 0.9797, Current learning rate: 0.00095000 \n",
"Epoch: [7/10], Loss: 0.9818, Current learning rate: 0.00095000 \n",
"Epoch: [8/10], Loss: 0.9657, Current learning rate: 0.00095000 \n",
"\n",
"In this test, the batch size is 24\n",
"\n",
"Epoch: [1/10], Loss: 0.9855, Current learning rate: 0.00100000 \n",
"Epoch: [2/10], Loss: 0.9771, Current learning rate: 0.00100000 \n",
"Epoch: [3/10], Loss: 0.9841, Current learning rate: 0.00100000 \n",
"Epoch: [4/10], Loss: 0.9823, Current learning rate: 0.00100000 \n",
"Epoch: [5/10], Loss: 0.9711, Current learning rate: 0.00100000 \n",
"Epoch: [6/10], Loss: 0.9612, Current learning rate: 0.00100000 \n",
"Epoch: [7/10], Loss: 0.9676, Current learning rate: 0.00100000 \n",
"Epoch: [8/10], Loss: 0.9662, Current learning rate: 0.00100000 \n",
"Epoch: [9/10], Loss: 0.9773, Current learning rate: 0.00095000 \n",
"Epoch: [10/10], Loss: 0.9777, Current learning rate: 0.00095000 \n",
"100%|███████████████████████████████████████████| 10/10 [00:11<00:00, 1.12s/it]\n",
"Epoch: [10/10], Loss: 0.9703, Current learning rate: 0.00095000 \n",
"100%|███████████████████████████████████████████| 10/10 [00:25<00:00, 2.59s/it]\n",
"Training finished! Please wait for the model to be saved!\n",
"\n",
"Model successfully saved! The location of the saved model is: ./../saved_models/test_train_model\n",
"\n"
"Model successfully saved! The location of the saved model is: ./../saved_models/test_boost_model\n",
"\n",
"Running with GPU\n",
"Prediction procedure starts!\n",
"100%|█████████████████████████████████████████████| 6/6 [00:34<00:00, 5.76s/it]\n",
"Prediction procedure ends! Please wait for the post processing!\n",
"Output processed GRE_400um.nii is successfully saved!\n",
"\n",
"Output MIP image GRE_400um.nii is successfully saved!\n",
"\n",
"Prediction and thresholding procedure end!\n",
"\n",
"Boosting session has been completed! Resultant segmentation has been saved to ./../../saved_imgs/boost_generated_label/.\n"
]
}
],
"source": [
"!python ./../train.py --ds_path ./../../data/img/ --lb_path ./../../data/seg/ --prep_mode 4 --ep 10 --lr 1e-3 --outmo ./../saved_models/test_train_model"
"!python ./../boost.py --ds_path ./../../data/img/ --lb_path ./../../data/seg/ --out_path ./../../saved_imgs/boost_generated_label/ --outmo ./../saved_models/test_boost_model --prep_mode 4 --ep 10 --lr 1e-3 "
]
},
{
Expand All @@ -95,14 +120,16 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Training session will start shortly..\n",
"./../../saved_imgs/boost_generated_label_prep/ does not exist.\n",
"./../../saved_imgs/boost_generated_label_prep/ has been created!\n",
"Boosting session will start shortly..\n",
"Parameters Info:\n",
"*************************************************************\n",
"\n",
Expand All @@ -112,28 +139,42 @@
"\n",
"The preprocessing procedure is starting!\n",
"\n",
"100%|█████████████████████████████████████████████| 1/1 [01:32<00:00, 92.13s/it]\n",
"100%|█████████████████████████████████████████████| 1/1 [01:33<00:00, 93.00s/it]\n",
"All processed images are successfully saved!\n",
"Epoch: [1/10], Loss: 0.9791, Current learning rate: 0.00100000 \n",
"Epoch: [2/10], Loss: 0.9806, Current learning rate: 0.00100000 \n",
"Epoch: [3/10], Loss: 0.9675, Current learning rate: 0.00100000 \n",
"Epoch: [4/10], Loss: 0.9828, Current learning rate: 0.00100000 \n",
"Epoch: [5/10], Loss: 0.9897, Current learning rate: 0.00100000 \n",
"Epoch: [6/10], Loss: 0.9690, Current learning rate: 0.00095000 \n",
"Epoch: [7/10], Loss: 0.9823, Current learning rate: 0.00095000 \n",
"Epoch: [8/10], Loss: 0.9814, Current learning rate: 0.00095000 \n",
"Epoch: [9/10], Loss: 0.9727, Current learning rate: 0.00090250 \n",
"Epoch: [10/10], Loss: 0.9761, Current learning rate: 0.00090250 \n",
"100%|███████████████████████████████████████████| 10/10 [00:05<00:00, 1.70it/s]\n",
"\n",
"In this test, the batch size is 24\n",
"\n",
"Epoch: [1/10], Loss: 0.9877, Current learning rate: 0.00100000 \n",
"Epoch: [2/10], Loss: 0.9756, Current learning rate: 0.00100000 \n",
"Epoch: [3/10], Loss: 0.9766, Current learning rate: 0.00100000 \n",
"Epoch: [4/10], Loss: 0.9744, Current learning rate: 0.00100000 \n",
"Epoch: [5/10], Loss: 0.9696, Current learning rate: 0.00100000 \n",
"Epoch: [6/10], Loss: 0.9666, Current learning rate: 0.00100000 \n",
"Epoch: [7/10], Loss: 0.9775, Current learning rate: 0.00100000 \n",
"Epoch: [8/10], Loss: 0.9610, Current learning rate: 0.00100000 \n",
"Epoch: [9/10], Loss: 0.9727, Current learning rate: 0.00100000 \n",
"Epoch: [10/10], Loss: 0.9560, Current learning rate: 0.00100000 \n",
"100%|███████████████████████████████████████████| 10/10 [00:20<00:00, 2.02s/it]\n",
"Training finished! Please wait for the model to be saved!\n",
"\n",
"Model successfully saved! The location of the saved model is: ./../saved_models/test_train_model_prep\n",
"\n"
"Model successfully saved! The location of the saved model is: ./../saved_models/test_boost_model_prep\n",
"\n",
"Running with GPU\n",
"Prediction procedure starts!\n",
"100%|█████████████████████████████████████████████| 6/6 [00:33<00:00, 5.61s/it]\n",
"Prediction procedure ends! Please wait for the post processing!\n",
"Output processed GRE_400um.nii is successfully saved!\n",
"\n",
"Output MIP image GRE_400um.nii is successfully saved!\n",
"\n",
"Prediction and thresholding procedure end!\n",
"\n",
"Boosting session has been completed! Resultant segmentation has been saved to ./../../saved_imgs/boost_generated_label_prep/.\n"
]
}
],
"source": [
"!python ./../train.py --ds_path ./../../data/img/ --lb_path ./../../data/seg/ --prep_mode 1 --ps_path ./../../data/preprocessed/ --ep 10 --lr 1e-3 --outmo ./../saved_models/test_train_model_prep"
"!python ./../boost.py --ds_path ./../../data/img/ --lb_path ./../../data/seg/ --ps_path ./../../data/preprocessed/ --out_path ./../../saved_imgs/boost_generated_label_prep/ --outmo ./../saved_models/test_boost_model_prep --prep_mode 1 --ep 10 --lr 1e-3 "
]
},
{
Expand Down Expand Up @@ -161,7 +202,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
"version": "3.11.4"
},
"orig_nbformat": 4
},
Expand Down

0 comments on commit 9993ef9

Please sign in to comment.