-
Notifications
You must be signed in to change notification settings - Fork 21
/
finetune_font.sh
executable file
·94 lines (76 loc) · 2.42 KB
/
finetune_font.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
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
#!/bin/bash
# $1 - TESSTRAIN_LANG
# $2 - TESSTRAIN_SCRIPT
# $3 - START_MODEL
# $4 - MODEL_NAME
# $5 - TRAIN_TYPE - FineTune, ReplaceLayer or blank (from scratch)
# $6 - TESSTRAIN_FONTS
# $7 - TESSEVAL_FONTS
# $8 - TESSTRAIN_MAX_PAGES per font
# $9 - MAX_ITERATIONS (use as integer maxiter)
# $10 - Y_MAX_CER (use as integer maxcer)
##
### rm -rf /tmp
# nohup bash finetune_font.sh eng Latin eng engFineTuned FineTune ' "Impact Condensed" ' ' "Arial" "FreeSerif" ' 0 9999 2 > data/logs/engFineTuned.log &
# nohup bash finetune_font.sh eng Latin eng engImpact FineTune ' "Impact Condensed" ' ' "Impact Condensed" ' 0 9999 2 > data/logs/engImpact.log &
# tail -f data/logs/engImpact.log
declare -i maxiter
maxiter=${9}
echo "maxiter= " $maxiter
declare -i maxcer
maxcer=${10}
echo "maxcer= " $maxcer
echo "________________________________________________________________________"
make MODEL_NAME=$4 clean-groundtruth clean-output
echo "________________________________________________________________________"
### tail -50 ~/langdata_lstm/$3/$3.training_text > data/langdata/$4-eval.training_text
### head -500 ~/langdata_lstm/$3/$3.training_text > data/langdata/$4-train.training_text
echo "________________________________________________________________________"
# font 2 lstmf lists
make \
TESSDATA=data \
TESSTRAIN_FONTS_DIR=/usr/share/fonts \
TESSTRAIN_TEXT=data/langdata/$4-train.training_text \
TESSEVAL_TEXT=data/langdata/$4-eval.training_text \
TESSTRAIN_MAX_PAGES=$8 \
TESSTRAIN_LANG=$1 \
TESSTRAIN_SCRIPT=$2 \
START_MODEL=$3 \
MODEL_NAME=$4 \
TESSTRAIN_FONTS="$6" \
TESSEVAL_FONTS="$7" \
lists
echo "________________________________________________________________________"
# lstmf to model
make \
TESSDATA=data \
DEBUG_INTERVAL=-1 \
TESSTRAIN_LANG=$1 \
TESSTRAIN_SCRIPT=$2 \
START_MODEL=$3 \
MODEL_NAME=$4 \
TRAIN_TYPE=$5 \
MAX_ITERATIONS=$maxiter \
training
echo "________________________________________________________________________"
# checkpoints to traineddata
make \
TESSDATA=data \
MODEL_NAME=$4 \
traineddata
echo "________________________________________________________________________"
# lstmeval and ocreval
make \
TESSDATA=data \
MODEL_NAME=$4 \
TRAIN_TYPE=$5 \
evalCER
echo "________________________________________________________________________"
# plotting
make \
TESSDATA=data \
MODEL_NAME=$4 \
TRAIN_TYPE=$5 \
Y_MAX_CER=$maxcer \
plotCER
echo "________________________________________________________________________"