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

🐛 typo: comment{,s}, fix #8 #11

Merged
merged 1 commit into from
Oct 23, 2020
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
4 changes: 2 additions & 2 deletions sbb_binarize/ocrd_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def process(self):

oplevel = self.parameter['operation_level']
model_path = self.parameter['model'] # pylint: disable=attribute-defined-outside-init
binarizer = SbbBinarizer(model_dir=model_path)
binarizer = SbbBinarizer(model_dir=model_path, logger=LOG)

for n, input_file in enumerate(self.input_files):
file_id = make_file_id(input_file, self.output_file_grp)
Expand All @@ -77,7 +77,7 @@ def process(self):
file_id + '.IMG-BIN',
page_id=input_file.pageId,
file_grp=self.output_file_grp)
page.add_AlternativeImage(AlternativeImageType(filename=bin_image_path, comment='%s,binarized' % page_xywh['features']))
page.add_AlternativeImage(AlternativeImageType(filename=bin_image_path, comments='%s,binarized' % page_xywh['features']))

elif oplevel == 'region':
regions = page.get_AllRegions(['Text', 'Table'], depth=1)
Expand Down
8 changes: 6 additions & 2 deletions sbb_binarize/sbb_binarize.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@
sys.stderr = stderr
import tensorflow as tf

import logging

def resize_image(img_in, input_height, input_width):
return cv2.resize(img_in, (input_width, input_height), interpolation=cv2.INTER_NEAREST)

class SbbBinarizer:

def __init__(self, model_dir):
def __init__(self, model_dir, logger=None):
self.model_dir = model_dir
self.log = logger if logger else logging.getLogger('SbbBinarizer')

def start_new_session(self):
config = tf.ConfigProto()
Expand Down Expand Up @@ -193,7 +196,8 @@ def run(self, image=None, image_path=None, save=None, use_patches=False):
self.start_new_session()
list_of_model_files = listdir(self.model_dir)
img_last = 0
for model_in in list_of_model_files:
for n, model_in in enumerate(list_of_model_files):
self.log.info('Predicting with model %s [%s/%s]' % (model_in, n + 1, len(list_of_model_files)))

res = self.predict(model_in, image, use_patches)

Expand Down