Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option to load training data through file #275

Merged
merged 2 commits into from
Dec 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions ocropus-rtrain
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,20 @@ parser.add_argument("-q","--quiet",action="store_true")
parser.add_argument("-Q","--nocheck",action="store_true")
parser.add_argument("-p","--pad",type=int,default=16)

# add file
parser.add_argument("-f","--file",default=None,help="path to file listing input files, one per line")

parser.add_argument("files",nargs="*")
args = parser.parse_args()

inputs = ocrolib.glob_all(args.files)

if args.file is not None:
print("getting training data from file")
with open(args.file) as file:
for l in file:
inputs.append(l.rstrip())

if len(inputs)==0:
parser.print_help()
sys.exit(0)
Expand Down
37 changes: 29 additions & 8 deletions run-test-ci
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#!/bin/bash -e

# Usage: ./run-test-ci [tests...]
#
# Examples:
#
# ./run-test-ci # Run all tests
# ./run-test-ci page conf # Run only 'test_page' and 'test_conf'
#
BASE=$(dirname $0)

# 'RUNNER' is the binary that the scripts are executed by. It defaults to
Expand Down Expand Up @@ -61,6 +68,13 @@ test_rtrain() {
$RUNNER $BASE/ocropus-rtrain 'book/*/*.bin.png' -N 5 -o ci-test-model
}

test_rtrain_files() {
tar -zxf $BASE/tests/uw3-500.tgz
find 'book' -name '*.bin.png' > INPUT_FILES
$RUNNER $BASE/ocropus-rtrain -f INPUT_FILES -N 5 -o ci-test-model
rm INPUT_FILES
}

test_nlbin() {
local TESTIMAGE=0071-010012.png
cp $BASE/tests/$TESTIMAGE temp
Expand Down Expand Up @@ -100,11 +114,18 @@ test_gtedit() {

rm -rf temp
mkdir -p temp
test_page
test_conf
test_linegen
test_rtrain
test_nlbin
test_gpageseg
test_rpred
test_gtedit
if (( $# > 0 ));then
for test in "$@";do
test_$test
done
else
test_page
test_conf
test_linegen
test_rtrain
test_rtrain_files
test_nlbin
test_gpageseg
test_rpred
test_gtedit
fi