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

disable tensorflow/keras print-to-stdout with tf_disable_interactive_… #90

Merged
merged 2 commits into from
Oct 12, 2023
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
1 change: 0 additions & 1 deletion ocrd_calamari/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
from pkg_resources import resource_string

OCRD_TOOL = json.loads(resource_string(__name__, 'ocrd-tool.json').decode('utf8'))
TF_CPP_MIN_LOG_LEVEL = '3' # '3' == ERROR
24 changes: 16 additions & 8 deletions ocrd_calamari/recognize.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@
from glob import glob

import numpy as np
from ocrd_utils import (
assert_file_grp_cardinality,
concat_padded,
coordinates_for_segment,
getLogger,
make_file_id,
points_from_polygon,
polygon_from_x0y0x1y1,
MIMETYPE_PAGE,
tf_disable_interactive_logs,
)

# Disable tensorflow/keras logging via print before importing calamari
tf_disable_interactive_logs()

from calamari_ocr import __version__ as calamari_version
from calamari_ocr.ocr import MultiPredictor
from calamari_ocr.ocr.voting import voter_from_proto
Expand All @@ -18,16 +33,9 @@
WordType, GlyphType, CoordsType,
to_xml
)
from ocrd_utils import (
getLogger, concat_padded,
coordinates_for_segment, points_from_polygon, polygon_from_x0y0x1y1,
make_file_id, assert_file_grp_cardinality,
MIMETYPE_PAGE
)

from ocrd_calamari.config import OCRD_TOOL, TF_CPP_MIN_LOG_LEVEL
from ocrd_calamari.config import OCRD_TOOL

os.environ['TF_CPP_MIN_LOG_LEVEL'] = TF_CPP_MIN_LOG_LEVEL
from tensorflow import __version__ as tensorflow_version

TOOL = 'ocrd-calamari-recognize'
Expand Down