From ef47f0ef09f2fa7993bc7251ad12250215d2a253 Mon Sep 17 00:00:00 2001 From: Robert Sachunsky Date: Fri, 26 Jun 2026 02:11:59 +0200 Subject: [PATCH] training convert: only add characters_org.txt if it exists --- src/eynollah/training/convert.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/eynollah/training/convert.py b/src/eynollah/training/convert.py index d2d7b49..5bf30a1 100644 --- a/src/eynollah/training/convert.py +++ b/src/eynollah/training/convert.py @@ -68,12 +68,13 @@ def convert_cli(rebuild, format_, in_, out): ex.add_config(str(config_path)) # some models deviate between training and inference ex.add_config(inference=True) - # make sure the local vocab file gets re-used + # OCR models: make sure the local vocab file gets re-used, if available characters_txt_file = model_path / "characters_org.txt" - with open(characters_txt_file, "r") as voc_file: - voc = json.load(voc_file) - ex.add_config(characters_txt_file=characters_txt_file) - ex.add_config(n_classes=len(voc) + 3) + if characters_txt_file.exists(): + with open(characters_txt_file, "r") as voc_file: + voc = json.load(voc_file) + ex.add_config(characters_txt_file=characters_txt_file) + ex.add_config(n_classes=len(voc) + 3) # just retrieve final config (via pseudo-run) ex.main(lambda: 0) config = ex.run(options={'--loglevel': 'ERROR'}).config