1
0
Fork 0
mirror of https://github.com/mikegerber/ocrd_calamari.git synced 2025-06-09 11:49:53 +02:00

Add test to check if we warn when processing a "raw"/RGB image with a single-channel model

This commit is contained in:
Gerber, Mike 2019-12-05 14:59:14 +01:00
parent f20eb3ba45
commit 377466a71a

View file

@ -4,6 +4,7 @@ import subprocess
import urllib.request
import pytest
import logging
from ocrd.resolver import Resolver
from ocrd_calamari import CalamariRecognize
@ -61,3 +62,16 @@ def test_recognize(workspace):
assert os.path.exists(page1)
with open(page1, 'r', encoding='utf-8') as f:
assert 'verſchuldeten' in f.read()
def test_recognize_should_warn_if_given_rgb_image_and_single_channel_model(workspace, caplog):
caplog.set_level(logging.WARNING)
CalamariRecognize(
workspace,
input_file_grp="OCR-D-GT-SEG-LINE",
output_file_grp="OCR-D-OCR-CALAMARI-BROKEN",
parameter={'checkpoint': CHECKPOINT}
).process()
interesting_log_messages = [t[2] for t in caplog.record_tuples if "Using raw image" in t[2]]
assert len(interesting_log_messages) > 10 # For every line!