summaryrefslogtreecommitdiff
path: root/testtraining.sh
blob: 263ba7a76786bf9f08fb8f6c5a3bb648b3916c74 (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
#!/bin/sh
usage="Usage: $0 traineddata evaldir"

test $# -ne 2 && echo "$usage" && exit 1

evaldir="$2"
here=`dirname "$0"`

# Make box files
find "$evaldir" -type f -name '*txt' | while read i; do
	b=`basename "$i" .txt`
	d=`dirname "$i"`

	# skip generating box files files if there's a box or lstmf file already present
	test -f "$d/$b.box" && continue
	test -f "$d/${b}_lstmf.lstmf" && continue

	python3 "${here}/generate_line_box.py" -i "$d/$b.png" -t "$i" > "$d/$b.box"
done


# Make lstmf files (a combined .box and .png file)
find "$evaldir" -type f -name '*box' | while read i; do
	b=`basename "$i" .box`
	d=`dirname "$i"`

	# skip generating lstmf files if they're already present
	test -f "$d/${b}_lstmf.lstmf" && continue

	tesseract "$d/$b.png" "$d/${b}_lstmf" --psm 6 lstm.train
	# the lstm.train process creates a blank .txt
	#rm -f "$d/${b}_lstmf.txt"
	#rm -f "$i"
done

find "$evaldir" -type f -name '*lstmf' > "$evaldir/list"

# Run lstmeval
lstmeval --model "$1" --eval_listfile "$evaldir/list" -verbosity 2 2>&1
exit
evalout=`lstmeval --model "$1" --eval_listfile "$evaldir/list" 2>&1`
test $? -ne 0 && echo "Error in lstmeval: $evalout"
echo "$evalout"
#echo "$evalout" | awk '/Char error rate/ {print $7 " " $8 " " $9 " " $10 " " $11 " " $12}'

#rm -f "$evaldir/list"