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

Commit

Permalink
network parameter default to bundled densenet121.tgc
Browse files Browse the repository at this point in the history
  • Loading branch information
kba committed Dec 22, 2020
1 parent 8801fc6 commit 0e6b5ac
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ocrd_typegroups_classifier/ocrd-tool.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"network": {
"description": "The file name of the neural network to use, including sufficient path information",
"type": "string",
"required": true
"required": false
},
"stride": {
"description": "Stride applied to the CNN on the image. Should be between 1 and 224. Smaller values increase the computation time.",
Expand Down
3 changes: 3 additions & 0 deletions ocrd_typegroups_classifier/processor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Wrap TypegroupsClassifier as an ocrd.Processor
"""
from pkg_resources import resource_filename

from ocrd import Processor
from ocrd_utils import (
Expand Down Expand Up @@ -43,6 +44,8 @@ def process(self):
log = getLogger('ocrd_typegroups_classifier')
assert_file_grp_cardinality(self.input_file_grp, 1)
assert_file_grp_cardinality(self.output_file_grp, 1)
if 'network' not in self.parameter:
self.parameter['network'] = resource_filename(__name__, 'models/densenet121.tgc')
network_file = self.parameter['network']
stride = self.parameter['stride']
classifier = TypegroupsClassifier.load(network_file)
Expand Down
4 changes: 1 addition & 3 deletions tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ set -ex

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

net="${SCRIPTDIR}/../ocrd_typegroups_classifier/models/densenet121.tgc"

cd "$SCRIPTDIR/assets/pembroke_werke_1766/data"
ocrd-typegroups-classifier \
-l DEBUG \
-g PHYS_0011 \
-m mets.xml \
-I DEFAULT \
-O OCR-D-FONTIDENT \
-p <(echo '{"network": "'"$net"'", "stride":143}')
-P stride 143

outfile="OCR-D-FONTIDENT/FILE_0010_OCR-D-FONTIDENT.xml"
expected_fontfamily='fraktur'
Expand Down

0 comments on commit 0e6b5ac

Please sign in to comment.