summaryrefslogtreecommitdiff
path: root/tasks/train.sh
blob: 60cbd2390a9d82d62dc9c9b9622fd376bac65fa2 (plain)
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
#!/bin/bash


# Add checkpoint and resume experiment
usage() {
    cat << EOF
    usage: ./tasks/train_crnn_line_ctc_model.sh
    -f | --experiment_config                    Name of the experiment config.
    -c | --checkpoint           (Optional)      The experiment name to continue from.
    -p | --pretrained_weights   (Optional)      Path to pretrained weights.
    -n | --notrain              (Optional)      Evaluates a trained model.
    -t | --test                 (Optional)      If set, evaluates the model on test set.
    -v | --verbose              (Optional)      Sets the verbosity.
    -h | --help                                 Shows this message.
EOF
exit 1
}

experiment_config=""
checkpoint=""
pretrained_weights=""
notrain=""
test=""
verbose=""
train_command=""

while getopts 'f:c:p:nthv' flag; do
  case "${flag}" in
    f) experiment_config="${OPTARG}" ;;
    c) checkpoint="${OPTARG}" ;;
    p) pretrained_weights="${OPTARG}" ;;
    n) notrain="--notrain" ;;
    t) test="--test" ;;
    v) verbose="${verbose}v" ;;
    h) usage ;;
    *) error "Unexpected option ${flag}" ;;
  esac
done


if [ -z ${experiment_config} ];
then
    echo "experiment_config not specified!"
    usage
    exit 1
fi

experiments_filename="training/experiments/${experiment_config}"
train_command=$(bash tasks/prepare_experiments.sh $experiments_filename)

if [ ${checkpoint} ];
then
    train_command="${train_command} --checkpoint $checkpoint"
fi

if [ ${pretrained_weights} ];
then
    train_command="${train_command} --pretrained_weights $pretrained_weights"
fi

if [ ${verbose} ];
then
    train_command="${train_command} -$verbose"
fi

train_command="${train_command} $test $notrain"
echo $train_command
eval $train_command