Skip to content
This repository was archived by the owner on Feb 19, 2024. It is now read-only.

Commit 488e217

Browse files
authored
Merge pull request #7 from OCR-D/bundle_network
network parameter default to bundled densenet121.tgc
2 parents 8801fc6 + 0e6b5ac commit 488e217

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

ocrd_typegroups_classifier/ocrd-tool.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"network": {
1818
"description": "The file name of the neural network to use, including sufficient path information",
1919
"type": "string",
20-
"required": true
20+
"required": false
2121
},
2222
"stride": {
2323
"description": "Stride applied to the CNN on the image. Should be between 1 and 224. Smaller values increase the computation time.",

ocrd_typegroups_classifier/processor.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Wrap TypegroupsClassifier as an ocrd.Processor
33
"""
4+
from pkg_resources import resource_filename
45

56
from ocrd import Processor
67
from ocrd_utils import (
@@ -43,6 +44,8 @@ def process(self):
4344
log = getLogger('ocrd_typegroups_classifier')
4445
assert_file_grp_cardinality(self.input_file_grp, 1)
4546
assert_file_grp_cardinality(self.output_file_grp, 1)
47+
if 'network' not in self.parameter:
48+
self.parameter['network'] = resource_filename(__name__, 'models/densenet121.tgc')
4649
network_file = self.parameter['network']
4750
stride = self.parameter['stride']
4851
classifier = TypegroupsClassifier.load(network_file)

tests/test.sh

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@ set -ex
33

44
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
55

6-
net="${SCRIPTDIR}/../ocrd_typegroups_classifier/models/densenet121.tgc"
7-
86
cd "$SCRIPTDIR/assets/pembroke_werke_1766/data"
97
ocrd-typegroups-classifier \
108
-l DEBUG \
119
-g PHYS_0011 \
1210
-m mets.xml \
1311
-I DEFAULT \
1412
-O OCR-D-FONTIDENT \
15-
-p <(echo '{"network": "'"$net"'", "stride":143}')
13+
-P stride 143
1614

1715
outfile="OCR-D-FONTIDENT/FILE_0010_OCR-D-FONTIDENT.xml"
1816
expected_fontfamily='fraktur'

0 commit comments

Comments
 (0)