-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrun-ocr-evaluation.sh
More file actions
executable file
·72 lines (52 loc) · 2.57 KB
/
Copy pathrun-ocr-evaluation.sh
File metadata and controls
executable file
·72 lines (52 loc) · 2.57 KB
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
# # bash generate_ocr_result.sh
# # scp rocky:/tmp/ocr-output* /tmp/
# # pypy ocr-evaluation.py
# EVAL_DIR=/dfs/madmax5/0/zifei/deepdive/app/ocr/data/evaluation/
# # EVAL_DIR=data/test-evaluation
# echo 'Evaluating Tesseract:'
# pypy ocr-evaluation-strict.py /tmp/ocr-output-words-tesseract.tsv $EVAL_DIR eval-results-tess.txt
# echo 'Evaluating Cuneiform:'
# pypy ocr-evaluation-strict.py /tmp/ocr-output-words-cuneiform.tsv $EVAL_DIR eval-results-cuni.txt
if [ "$#" -ne 1 ]; then
echo "Usage: ... <dbname>. (uses PGHOST)"
else
DBNAME=$1
fi
bash generate_ocr_result.sh $DBNAME
# export EXPORT_ROOT='/dfs/hulk/0/zifei/ocr/tmp/'
if [ $PGHOST != "localhost" ]; then
echo "Copying files from $PGHOST"
scp $PGHOST:/tmp/ocr-output* /tmp/
fi
export EXPORT_ROOT=/tmp/
### pypy ocr-evaluation.py
# EVAL_DIR=/dfs/madmax5/0/zifei/deepdive/app/ocr/data/evaluation/
# EVAL_DIR=/dfs/madmax/0/zifei/deepdive/app/ocr/data/evaluation/
# EVAL_DIR=data/test-evaluation
rm -f eval-results/$DBNAME/tesseract/*
rm -f eval-results/$DBNAME/cuneiform/*
mkdir -p eval-results/$DBNAME/tesseract
mkdir -p eval-results/$DBNAME/cuneiform
export EVAL_LIST_FILE=$EXPORT_ROOT/ocr-eval-docs.tsv
if [ -z "$SUPV_DIR" ]; then # if empty
export SUPV_DIR=/dfs/hulk/0/zifei/ocr/supervision_escaped/
fi
if [ -z "$EVAL_DIR" ]; then # if empty
export EVAL_DIR=/dfs/hulk/0/zifei/ocr/evaluation_escaped/
fi
if [ -z "$MAX_PARALLELISM" ]; then # if empty
export MAX_PARALLELISM=25
fi
# pypy ocr-evaluation-strict.py $EXPORT_ROOT/ocr-output-words.tsv $EVAL_DIR eval-results.txt
echo 'Evaluating Tesseract...'
cat $EVAL_LIST_FILE | xargs -P $MAX_PARALLELISM -L 1 bash -c 'pypy ocr-evaluation-xargs.py $EXPORT_ROOT/ocr-output-words-tesseract.tsv $EVAL_DIR eval-results/$DBNAME/tesseract/$0.txt $0'
cat eval-results/$DBNAME/tesseract/* > eval-results-tess-$DBNAME.txt
echo 'Evaluating Cuneiform...'
cat $EVAL_LIST_FILE | xargs -P $MAX_PARALLELISM -L 1 bash -c 'pypy ocr-evaluation-xargs.py $EXPORT_ROOT/ocr-output-words-cuneiform.tsv $EVAL_DIR eval-results/$DBNAME/cuneiform/$0.txt $0'
cat eval-results/$DBNAME/cuneiform/* > eval-results-cuni-$DBNAME.txt
echo "Now you may want to run: cp eval-results-tess-$DBNAME.txt YOUR_PLOTTING_FILE"
# pypy ocr-evaluation-strict.py $EXPORT_ROOT/ocr-output-words.tsv $EVAL_DIR eval-results.txt
# echo 'Evaluating Tesseract:'
# pypy ocr-evaluation.py $EXPORT_ROOT/ocr-output-words-tesseract.tsv data/test-evaluation/ output-tess/ eval-results-tess.txt
# echo 'Evaluating Cuneiform:'
# pypy ocr-evaluation.py $EXPORT_ROOT/ocr-output-words-cuneiform.tsv data/test-evaluation/ output-cuni/ eval-results-cuni.txt