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

fix/readme-no-checkpoint
Gerber, Mike 5 years ago
parent f20eb3ba45
commit 377466a71a

@ -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!

Loading…
Cancel
Save