mirror of
https://github.com/qurator-spk/eynollah.git
synced 2025-11-09 22:24:13 +01:00
Merge branch 'model-zoo' of lx0145.sbb.spk-berlin.de:/data/eynollah into model-zoo
This commit is contained in:
commit
ef999c8f0a
3 changed files with 14 additions and 16 deletions
|
|
@ -21,8 +21,8 @@ DEFAULT_MODEL_SPECS = EynollahModelSpecSet([
|
|||
|
||||
EynollahModelSpec(
|
||||
category="binarization",
|
||||
variant='',
|
||||
filename="models_eynollah/eynollah-binarization-hybrid_20230504",
|
||||
variant='hybrid',
|
||||
filename="models_eynollah/eynollah-binarization-hybrid_20230504/model_bin_hybrid_trans_cnn_sbb_ens",
|
||||
dists=['layout', 'binarization', ],
|
||||
dist_url=dist_url("binarization"),
|
||||
type=KerasModel,
|
||||
|
|
@ -39,7 +39,7 @@ DEFAULT_MODEL_SPECS = EynollahModelSpecSet([
|
|||
|
||||
EynollahModelSpec(
|
||||
category="binarization",
|
||||
variant='augment',
|
||||
variant='',
|
||||
filename="models_eynollah/eynollah-binarization_20210425",
|
||||
dists=['binarization'],
|
||||
dist_url=dist_url("binarization"),
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class SbbBinarizer:
|
|||
def __init__(self, model_dir: str, mode: str, logger=None):
|
||||
if mode not in ('single', 'multi'):
|
||||
raise ValueError(f"'mode' must be either 'multi' or 'single', not {mode}")
|
||||
self.log = logger if logger else logging.getLogger('SbbBinarizer')
|
||||
self.log = logger if logger else logging.getLogger('eynollah.binarization')
|
||||
self.model_zoo = EynollahModelZoo(basedir=model_dir)
|
||||
self.models = self.setup_models(mode)
|
||||
self.session = self.start_new_session()
|
||||
|
|
@ -51,8 +51,7 @@ class SbbBinarizer:
|
|||
self.session.close()
|
||||
del self.session
|
||||
|
||||
def predict(self, img, use_patches, n_batch_inference=5):
|
||||
model = self.model_zoo.get('binarization', Model)
|
||||
def predict(self, model, img, use_patches, n_batch_inference=5):
|
||||
model_height = model.layers[len(model.layers)-1].output_shape[1]
|
||||
model_width = model.layers[len(model.layers)-1].output_shape[2]
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,7 @@ from ocrd_models.constants import NAMESPACES as NS
|
|||
|
||||
testdir = Path(__file__).parent.resolve()
|
||||
|
||||
MODELS_OCR = environ.get('MODELS_OCR', str(testdir.joinpath('..', 'models_ocr_v0_6_0').resolve()))
|
||||
MODELS_BIN = environ.get('MODELS_BIN', str(testdir.joinpath('..', 'default-2021-03-09').resolve()))
|
||||
MODELS_DIR = environ.get('EYNOLLAH_MODELS_DIR', str(testdir.joinpath('..').resolve()))
|
||||
|
||||
def only_eynollah(logrec):
|
||||
return logrec.name.startswith('eynollah')
|
||||
|
|
@ -32,7 +31,7 @@ def test_run_eynollah_binarization_filename(tmp_path, pytestconfig, caplog, opti
|
|||
infile = testdir.joinpath('resources/kant_aufklaerung_1784_0020.tif')
|
||||
outfile = tmp_path.joinpath('kant_aufklaerung_1784_0020.png')
|
||||
args = [
|
||||
'-m', MODELS_BIN,
|
||||
'-m', MODELS_DIR,
|
||||
'-i', str(infile),
|
||||
'-o', str(outfile),
|
||||
]
|
||||
|
|
@ -56,7 +55,7 @@ def test_run_eynollah_binarization_directory(tmp_path, pytestconfig, caplog):
|
|||
indir = testdir.joinpath('resources')
|
||||
outdir = tmp_path
|
||||
args = [
|
||||
'-m', MODELS_BIN,
|
||||
'-m', MODELS_DIR,
|
||||
'-di', str(indir),
|
||||
'-o', str(outdir),
|
||||
]
|
||||
|
|
@ -81,7 +80,7 @@ def test_run_eynollah_enhancement_filename(tmp_path, pytestconfig, caplog, optio
|
|||
infile = testdir.joinpath('resources/kant_aufklaerung_1784_0020.tif')
|
||||
outfile = tmp_path.joinpath('kant_aufklaerung_1784_0020.png')
|
||||
args = [
|
||||
'-m', MODELS_LAYOUT,
|
||||
'-m', MODELS_DIR,
|
||||
'-i', str(infile),
|
||||
'-o', str(outfile.parent),
|
||||
]
|
||||
|
|
@ -105,7 +104,7 @@ def test_run_eynollah_enhancement_directory(tmp_path, pytestconfig, caplog):
|
|||
indir = testdir.joinpath('resources')
|
||||
outdir = tmp_path
|
||||
args = [
|
||||
'-m', MODELS_LAYOUT,
|
||||
'-m', MODELS_DIR,
|
||||
'-di', str(indir),
|
||||
'-o', str(outdir),
|
||||
]
|
||||
|
|
@ -124,7 +123,7 @@ def test_run_eynollah_mbreorder_filename(tmp_path, pytestconfig, caplog):
|
|||
infile = testdir.joinpath('resources/kant_aufklaerung_1784_0020.xml')
|
||||
outfile = tmp_path.joinpath('kant_aufklaerung_1784_0020.xml')
|
||||
args = [
|
||||
'-m', MODELS_LAYOUT,
|
||||
'-m', MODELS_DIR,
|
||||
'-i', str(infile),
|
||||
'-o', str(outfile.parent),
|
||||
]
|
||||
|
|
@ -151,7 +150,7 @@ def test_run_eynollah_mbreorder_directory(tmp_path, pytestconfig, caplog):
|
|||
indir = testdir.joinpath('resources')
|
||||
outdir = tmp_path
|
||||
args = [
|
||||
'-m', MODELS_LAYOUT,
|
||||
'-m', MODELS_DIR,
|
||||
'-di', str(indir),
|
||||
'-o', str(outdir),
|
||||
]
|
||||
|
|
@ -181,7 +180,7 @@ def test_run_eynollah_ocr_filename(tmp_path, pytestconfig, caplog, options):
|
|||
outrenderfile = tmp_path.joinpath('render').joinpath('kant_aufklaerung_1784_0020.png')
|
||||
outrenderfile.parent.mkdir()
|
||||
args = [
|
||||
'-m', MODELS_OCR,
|
||||
'-m', MODELS_DIR,
|
||||
'-i', str(infile),
|
||||
'-dx', str(infile.parent),
|
||||
'-o', str(outfile.parent),
|
||||
|
|
@ -212,7 +211,7 @@ def test_run_eynollah_ocr_directory(tmp_path, pytestconfig, caplog):
|
|||
indir = testdir.joinpath('resources')
|
||||
outdir = tmp_path
|
||||
args = [
|
||||
'-m', MODELS_OCR,
|
||||
'-m', MODELS_DIR,
|
||||
'-di', str(indir),
|
||||
'-dx', str(indir),
|
||||
'-o', str(outdir),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue