Skip to content

Commit

Permalink
tesstrain: check failure of subjobs
Browse files Browse the repository at this point in the history
  • Loading branch information
bertsky committed Mar 14, 2019
1 parent 4c2bbeb commit 5316bcb
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions src/training/tesstrain_utils.sh
Expand Up @@ -291,7 +291,7 @@ generate_font_image() {
# Phase I : Generate (I)mages from training text for each font.
phase_I_generate_image() {
local par_factor=${1:-}
if [[ -z ${par_factor} || ${par_factor} -le 0 ]]; then
if ! [[ "${par_factor}" -gt 0 ]]; then
par_factor=1
fi
tlog "\n=== Phase I: Generating training images ==="
Expand All @@ -317,13 +317,10 @@ phase_I_generate_image() {
for font in "${FONTS[@]}"; do
sleep 1
generate_font_image "${font}" &
let counter=counter+1
let rem=counter%par_factor || true
if [[ "${rem}" -eq 0 ]]; then
wait
fi
let counter++
((counter%par_factor)) || wait -n
done
wait
wait -n
# Check that each process was successful.
for font in "${FONTS[@]}"; do
local fontname=$(echo ${font} | tr ' ' '_' | sed 's/,//g')
Expand Down Expand Up @@ -427,7 +424,7 @@ phase_E_extract_features() {
local box_config=$1
local par_factor=$2
local ext=$3
if [[ -z ${par_factor} || ${par_factor} -le 0 ]]; then
if ! [[ "${par_factor}" -gt 0 ]]; then
par_factor=1
fi
tlog "\n=== Phase E: Generating ${ext} files ==="
Expand All @@ -450,13 +447,10 @@ phase_E_extract_features() {
for img_file in ${img_files}; do
run_command tesseract ${img_file} ${img_file%.*} \
${box_config} ${config} &
let counter=counter+1
let rem=counter%par_factor || true
if [[ "${rem}" -eq 0 ]]; then
wait
fi
let counter++
((counter%par_factor)) || wait -n
done
wait
wait -n
export TESSDATA_PREFIX=${OLD_TESSDATA_PREFIX}
# Check that all the output files were produced.
for img_file in ${img_files}; do
Expand Down

0 comments on commit 5316bcb

Please sign in to comment.