-
Notifications
You must be signed in to change notification settings - Fork 121
/
make_kaggle_solution.sh
67 lines (50 loc) · 3.09 KB
/
make_kaggle_solution.sh
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
#!/bin/bash
#
# This script can be used to generate the 2nd place solution
# of team o_O for the diabetic retinopath competition.
#
# terminate on error
set -e
########## Convert Images ##########
# Original images are expected to reside in data/{train,test}.
# Convert them to 512x512 pixel images.
python convert.py --crop_size 512 --convert_directory data/train_medium --extension tiff --directory data/train
python convert.py --crop_size 512 --convert_directory data/test_medium --extension tiff --directory data/test
# For the training set, make smaller images to train smaller versions of the
# convolutional networks.
python convert.py --crop_size 256 --convert_directory data/train_small --extension tiff --directory data/train_medium
python convert.py --crop_size 128 --convert_directory data/train_tiny --extension tiff --directory data/train_medium
########## Train Convolutional Networks ##########
# Train network with 5x5 and 3x3 kernels.
python train_nn.py --cnf configs/c_128_5x5_32.py
python train_nn.py --cnf configs/c_256_5x5_32.py --weights_from weights/c_128_5x5_32/weights_final.pkl
python train_nn.py --cnf configs/c_512_5x5_32.py --weights_from weights/c_256_5x5_32/weights_final.pkl
# Train network with 4x4 kernels.
python train_nn.py --cnf configs/c_128_4x4_32.py
python train_nn.py --cnf configs/c_256_4x4_32.py --weights_from weights/c_128_4x4_32/weights_final.pkl
python train_nn.py --cnf configs/c_512_4x4_32.py --weights_from weights/c_256_4x4_32/weights_final.pkl
########## Extract Features ##########
# Please note that you can save a lot of time while maintaining most of the
# prediction accuracy by reducing the number of iterations from 50 down to 20
# or even fewer or by only extracting the features for a single set of weights.
# Extract features for network with 5x5 and 3x3 kernels.
BEST_VALID_WEIGHTS="$(ls -t weights/c_512_5x5_32/best/ | head -n 1)"
python transform.py --cnf configs/c_512_5x5_32.py --train --test --n_iter 50 --weights_from weights/c_512_5x5_32/best/"$BEST_VALID_WEIGHTS"
# by default weights with best validation kappa druing train run are loaded
python transform.py --cnf configs/c_512_5x5_32.py --train --test --n_iter 50 --skip 50
python transform.py --cnf configs/c_512_5x5_32.py --train --test --n_iter 50 --skip 100 --weights_from weights/c_512_5x5_32/weights_final.pkl
# Extract features for network with 4x4 kernels.
BEST_VALID_WEIGHTS="$(ls -t weights/c_512_4x4_32/best/ | head -n 1)"
python transform.py --cnf configs/c_512_4x4_32.py --train --test --n_iter 50 --weights_from weights/c_512_4x4_32/best/"$BEST_VALID_WEIGHTS"
python transform.py --cnf configs/c_512_4x4_32.py --train --test --n_iter 50 --skip 50
python transform.py --cnf configs/c_512_4x4_32.py --train --test --n_iter 50 --skip 100 --weights_from weights/c_512_4x4_32/weights_final.pkl
########## Blend Features ##########
#
# To blend a different selection of feature files, modify blend.yml or
# pass --feature_file path/to/feature/file to blend.py to use a single
# feature file.
#
# validate
python blend.py --per_patient
# make submission
python blend.py --per_patient --predict