[6969be]: / scripts / runner.sh

Download this file

330 lines (310 with data), 8.7 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
#!/bin/bash
# -------------------------------- Prepare datasets ------------------------------------
(cd ../rocaseg/datasets &&
echo "prepare_dataset" &&
python prepare_dataset_oai_imo.py \
../../../data_raw/OAI_iMorphics_scans \
../../../data_raw/OAI_iMorphics_annotations \
../../../data/91_OAI_iMorphics_full_meta \
--margin 20 \
)
(cd ../rocaseg/datasets &&
echo "prepare_dataset" &&
python prepare_dataset_okoa.py \
../../../data_raw/OKOA \
../../../data/31_OKOA_full_meta \
--margin 0 \
)
(cd ../rocaseg/datasets &&
echo "prepare_dataset" &&
python prepare_dataset_maknee.py \
../../../data_raw/MAKNEE \
../../../data/41_MAKNEE_full_meta \
--margin 0 \
)
# --------------------------------------------------------------------------------------
# -------------------------------- Resample datasets -----------------------------------
(cd ../rocaseg/ &&
echo "resample" &&
python resample.py \
--path_root_in ../../data/31_OKOA_full_meta \
--spacing_in 0.5859375 0.5859375 \
--path_root_out ../../data/32_OKOA_full_meta_rescaled \
--spacing_out 0.36458333 0.36458333 \
--num_threads 12 \
--margin 0 \
)
(cd ../rocaseg/ &&
echo "resample" &&
python resample.py \
--path_root_in ../../data/41_MAKNEE_full_meta \
--spacing_in 0.5859375 0.5859375 \
--path_root_out ../../data/42_MAKNEE_full_meta_rescaled \
--spacing_out 0.36458333 0.36458333 \
--num_threads 12 \
--margin 0 \
)
# --------------------------------------------------------------------------------------
# --------------------------------- Train models ---------------------------------------
(cd ../rocaseg/ &&
echo "train" &&
python train_baseline.py \
--path_data_root ../../data \
--path_experiment_root ../../results/0_baseline \
--model_segm unet_lext \
--input_channels 1 \
--output_channels 5 \
--center_depth 1 \
--lr_segm 0.001 \
--batch_size 32 \
--epoch_num 50 \
--fold_num 5 \
--fold_idx -1 \
--num_workers 12 \
)
(cd ../rocaseg/ &&
echo "train" &&
python train_baseline.py \
--path_data_root ../../data \
--path_experiment_root ../../results/1_mixup \
--model_segm unet_lext \
--input_channels 1 \
--output_channels 5 \
--center_depth 1 \
--lr_segm 0.001 \
--batch_size 32 \
--epoch_num 50 \
--fold_num 5 \
--fold_idx -1 \
--with_mixup \
--mixup_alpha 0.7 \
--num_workers 12 \
)
(cd ../rocaseg/ &&
echo "train" &&
python train_baseline.py \
--path_data_root ../../data \
--path_experiment_root ../../results/2_mixup_nowd \
--model_segm unet_lext \
--input_channels 1 \
--output_channels 5 \
--center_depth 1 \
--lr_segm 0.001 \
--wd_segm 0.0 \
--batch_size 32 \
--epoch_num 50 \
--fold_num 5 \
--fold_idx -1 \
--with_mixup \
--mixup_alpha 0.7 \
--num_workers 12 \
)
(cd ../rocaseg/ &&
echo "train" &&
python train_uda1.py \
--path_data_root ../../data \
--path_experiment_root ../../results/3_uda1 \
--model_segm unet_lext \
--center_depth 1 \
--model_discr discriminator_a \
--input_channels 1 \
--output_channels 5 \
--mask_mode all_unitibial_unimeniscus \
--loss_segm multi_ce_loss \
--lr_segm 0.0001 \
--lr_discr 0.00004 \
--batch_size 32 \
--epoch_num 30 \
--fold_num 5 \
--fold_idx 0 \
--num_workers 12 \
)
(cd ../rocaseg/ &&
echo "train" &&
python train_uda1.py \
--path_data_root ../../data \
--path_experiment_root ../../results/4_uda2 \
--model_segm unet_lext_aux \
--center_depth 1 \
--model_discr_out discriminator_a \
--model_discr_aux discriminator_a \
--input_channels 1 \
--output_channels 5 \
--mask_mode all_unitibial_unimeniscus \
--loss_segm multi_ce_loss \
--lr_segm 0.0001 \
--lr_discr 0.00004 \
--batch_size 32 \
--epoch_num 30 \
--fold_num 5 \
--fold_idx 0 \
--num_workers 12 \
)
(cd ../rocaseg/ &&
echo "train" &&
python train_uda1.py \
--path_data_root ../../data \
--path_experiment_root ../../results/5_uda1_mixup_nowd \
--model_segm unet_lext \
--center_depth 1 \
--model_discr discriminator_a \
--input_channels 1 \
--output_channels 5 \
--mask_mode all_unitibial_unimeniscus \
--loss_segm multi_ce_loss \
--lr_segm 0.0001 \
--lr_discr 0.00004 \
--wd_segm 0.0 \
--batch_size 32 \
--epoch_num 30 \
--fold_num 5 \
--fold_idx 0 \
--num_workers 12 \
--with_mixup \
--mixup_alpha 0.7 \
)
# --------------------------------------------------------------------------------------
# ------------------------------- Run model inference ----------------------------------
for EXP in 0_baseline 1_mixup 2_mixup_nowd 3_uda1 5_uda1_mixup_nowd
do
(cd ../rocaseg/ &&
echo "evaluate" &&
python evaluate.py \
--path_data_root ../../data \
--path_experiment_root ../../results/${EXP} \
--model_segm unet_lext \
--center_depth 1 \
--restore_weights \
--output_channels 5 \
--dataset oai_imo \
--subset test \
--mask_mode all_unitibial_unimeniscus \
--batch_size 64 \
--fold_num 5 \
--fold_idx -1 \
--num_workers 12 \
--predict_folds \
--merge_predictions \
)
done
for EXP in 4_uda2
do
(cd ../rocaseg/ &&
echo "evaluate" &&
python evaluate.py \
--path_data_root ../../data \
--path_experiment_root ../../results/${EXP} \
--model_segm unet_lext_aux \
--center_depth 1 \
--restore_weights \
--output_channels 5 \
--dataset oai_imo \
--subset test \
--mask_mode all_unitibial_unimeniscus \
--batch_size 64 \
--fold_num 5 \
--fold_idx -1 \
--num_workers 12 \
--predict_folds \
--merge_predictions \
)
done
for EXP in 0_baseline 1_mixup 2_mixup_nowd 3_uda1 5_uda1_mixup_nowd
do
(cd ../rocaseg/ &&
echo "evaluate" &&
python evaluate.py \
--path_data_root ../../data \
--path_experiment_root ../../results/${EXP} \
--model_segm unet_lext \
--center_depth 1 \
--restore_weights \
--output_channels 5 \
--dataset okoa \
--subset all \
--mask_mode background_femoral_unitibial \
--batch_size 64 \
--fold_num 5 \
--fold_idx -1 \
--num_workers 12 \
--predict_folds \
--merge_predictions \
)
done
for EXP in 4_uda2
do
(cd ../rocaseg/ &&
echo "evaluate" &&
python evaluate.py \
--path_data_root ../../data \
--path_experiment_root ../../results/${EXP} \
--model_segm unet_lext_aux \
--center_depth 1 \
--restore_weights \
--output_channels 5 \
--dataset okoa \
--subset all \
--mask_mode background_femoral_unitibial \
--batch_size 64 \
--fold_num 5 \
--fold_idx -1 \
--num_workers 12 \
--predict_folds \
--merge_predictions \
)
done
# --------------------------------------------------------------------------------------
# ------------------------------- Analyze model predictions ----------------------------
for EXP in 0_baseline 1_mixup 2_mixup_nowd 3_uda1 4_uda2 5_uda1_mixup_nowd
do
(cd ../rocaseg/ &&
echo "analyze_predictions" &&
python analyze_predictions_single.py \
--path_experiment_root ../../results/${EXP} \
--dirname_pred mask_foldavg \
--dirname_true mask_prep \
--dataset oai_imo \
--atlas segm \
--ignore_cache \
--num_workers 12 \
)
done
for EXP in 0_baseline 1_mixup 2_mixup_nowd 3_uda1 4_uda2 5_uda1_mixup_nowd
do
(cd ../rocaseg/ &&
echo "analyze_predictions" &&
python analyze_predictions_single.py \
--path_experiment_root ../../results/${EXP} \
--dirname_pred mask_foldavg \
--dirname_true mask_prep \
--dataset okoa \
--atlas okoa \
--ignore_cache \
--num_workers 12 \
)
done
# --------------------------------------------------------------------------------------
# --------------------------------- Compare models -------------------------------------
(cd ../rocaseg/ &&
echo "analyze_predictions_multi" &&
python analyze_predictions_multi.py \
--path_results_root ../../results \
--experiment_id 0_baseline \
--experiment_id 2_mixup_nowd \
--experiment_id 4_uda2 \
--dataset oai_imo \
--atlas segm \
--num_workers 12 \
)
(cd ../rocaseg/ &&
echo "analyze_predictions_multi" &&
python analyze_predictions_multi.py \
--path_results_root ../../results \
--experiment_id 0_baseline \
--experiment_id 2_mixup_nowd \
--experiment_id 4_uda2 \
--dataset okoa \
--atlas okoa \
--num_workers 12 \
)
# --------------------------------------------------------------------------------------