-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathwhs.make
65 lines (49 loc) · 2.63 KB
/
whs.make
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
CC = python
SHELL = bash
PP = PYTHONPATH="$(PYTHONPATH):."
.PHONY: all view plot report
CFLAGS = -O
#DEBUG = --debug
#the regex of the slices in the target dataset
#for the heart
G_RGX1 = slice\d+_1
DATA_aug = [('IMGaug', nii_transform, False), ('GTaug', nii_gt_transform, False),('GTaug', nii_gt_transform, False)]
TT_DATA = [('IMG', nii_transform, False), ('GT', nii_gt_transform, False), ('GT', nii_gt_transform, False)]
L_OR = [('CrossEntropy', {'idc': [0,1,2,3,4], 'weights':[1,1,1,1,1]}, None, None, None, 1)]
NET = UNet
#the network weights used as initialization of the adaptation
M_WEIGHTS_ul = results/whs/cesource/last.pkl
#run the main experiments
TRN = results/whs/cesource results/whs/sfda
REPO = $(shell basename `git rev-parse --show-toplevel`)
DATE = $(shell date +"%y%m%d")
HASH = $(shell git rev-parse --short HEAD)
HOSTNAME = $(shell hostname)
PBASE = archives
PACK = $(PBASE)/$(REPO)-$(DATE)-$(HASH)-$(HOSTNAME)-CSize.tar.gz
all: pack
plot: $(PLT)
pack: $(PACK) report
$(PACK): $(TRN) $(INF_0) $(TRN_1) $(INF_1) $(TRN_2) $(TRN_3) $(TRN_4)
mkdir -p $(@D)
tar cf - $^ | pigz > $@
chmod -w $@
# tar -zc -f $@ $^ # Use if pigz is not available
# first train on the source dataset only:
results/whs/cesource: OPT = --target_losses="$(L_OR)" --target_dataset "data/mr" \
--network UNet --model_weights="" --lr_decay 1 \
# full supervision
results/whs/fs: OPT = --target_losses="$(L_OR)" \
--network UNet --model_weights="$(M_WEIGHTS_uce)" --lr_decay 1 \
# CDA.
results/whs/cda: OPT = --target_losses="[('NaivePenalty', {'curi':True, 'idc': [1,2,3,4],'power': 1},'PredictionBounds', \
{'margin':0,'dir':'high','idc':[1],'predcol':'dumbpredwtags', 'power': 1,'fake':False, 'mode':'percentage','prop':False,'sizefile':'sizes/whs.csv'},'soft_size',50)]"\
--source_folders="$(DATA_aug)" --source_losses="$(L_OR)" --model_weights="$(M_WEIGHTS_ul)" --batch_size 10 --ontest --l_rate 0.0001
#inference mode : saves the segmentation masks for a specific model saved as pkl file (ex. "results/sa/cesource/last.pkl" below):
results/whs/cesourceim: OPT = --target_losses="$(L_OR)" \
--mode makeim --batch_size 1 --l_rate 0 --model_weights="results/whs/cesource/last.pkl" --pprint --lr_decay 1 --n_epoch 1 --saveim True\
$(TRN) :
$(CC) $(CFLAGS) main.py --batch_size 24 --n_class 5 --workdir $@_tmp --target_dataset "data/ct" \
--metric_axis 1 --n_epoch 100 --dice_3d --l_rate 5e-4 --weight_decay 1e-4 --grp_regex="$(G_RGX)" --network=$(NET) --val_target_folders="$(TT_DATA)"\
--lr_decay 0.9 --model_weights="$(M_WEIGHTS_uce)" --target_folders="$(TT_DATA)" $(OPT) $(DEBUG)
mv $@_tmp $@