Diff of /scripts/runner.sh [000000] .. [6969be]

Switch to unified view

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