-
Notifications
You must be signed in to change notification settings - Fork 1
/
my_ocrd_workflow-sbb
executable file
·84 lines (62 loc) · 2.04 KB
/
my_ocrd_workflow-sbb
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
#!/bin/bash
set -e # Abort on error
# Configuration
export LOG_LEVEL=${LOG_LEVEL:-INFO} # /etc/ocrd_logging.py uses this to set level for all OCR-D modules
export TEXTEQUIV_LEVEL=word
# Command line parameters
OPTS=`getopt -o I: --long input-file-grp:,skip-validation -- "$@"`
eval set -- "$OPTS"
INPUT_FILE_GRP=OCR-D-IMG
SKIP_VALIDATION=false
while true; do
case "$1" in
-I|--input-file-grp) INPUT_FILE_GRP=$2; shift 2;;
--skip-validation) SKIP_VALIDATION=true; shift;;
--) shift; break;;
*) break;;
esac
done
# Set up logging
if [ "$LOG_LEVEL" = "DEBUG" -o "$LOG_LEVEL" = "TRACE" ]; then
set -x
fi
do_validate() {
# Validate the workspace
# Both ocrd_tesserocr + ocrd_calamari produce segment coordinates that are not strictly within their parent's
# coordinates:
#
# INCONSISTENCY in [...] coords [...] not within parent coords
#
# → --page-coordinate-consistency off
#
# ocrd_tesserocr sometimes produces segment text results that aren't concatenating as expected by the validator:
#
# INCONSISTENCY in [...]: text results '[...]' != concatenated '[...]'
#
# → --page-strictness lax
#
validate_options='
--skip dimension
--skip pixel_density
--page-strictness lax
--page-coordinate-consistency off'
if [ "$SKIP_VALIDATION" = false ]; then
ocrd workspace validate $validate_options
fi
}
main() {
do_validate
ocrd-sbb-binarize --overwrite -I $INPUT_FILE_GRP -O OCR-D-IMG-BIN -P model "/var/lib/sbb_binarization"
do_validate
ocrd-sbb-textline-detector --overwrite -I OCR-D-IMG-BIN -O OCR-D-SEG-LINE -P model "/var/lib/textline_detection"
do_validate
ocrd-calamari-recognize --overwrite -I OCR-D-SEG-LINE -O OCR-D-OCR-CALAMARI -P checkpoint_dir "/var/lib/calamari-models/GT4HistOCR/2019-12-11T11_10+0100/" -P textequiv_level "$TEXTEQUIV_LEVEL"
do_validate
ocrd-fileformat-transform --overwrite -I OCR-D-OCR-CALAMARI -O OCR-D-OCR-CALAMARI-ALTO
do_validate
}
if [ "$LOG_LEVEL" = "DEBUG" -o "$LOG_LEVEL" = "TRACE" ]; then
pip list || true
fi
main
# vim:tw=120: