23 if (sys.version_info.major < 3)
or (sys.version_info.major == 3
and sys.version_info.minor < 6):
24 raise Exception(
"Must be using Python minimum version 3.6!")
26 sys.path.insert(0, os.path.dirname(__file__))
27 from tesstrain_utils
import (
29 initialize_fontconfig,
30 phase_I_generate_image,
31 phase_UP_generate_unicharset,
32 phase_E_extract_features,
36 import language_specific
38 log = logging.getLogger()
42 log.setLevel(logging.DEBUG)
43 console = logging.StreamHandler()
44 console.setLevel(logging.INFO)
45 console_formatter = logging.Formatter(
46 "[%(asctime)s] %(levelname)s - %(message)s", datefmt=
"%H:%M:%S"
48 console.setFormatter(console_formatter)
49 log.addHandler(console)
53 logfile = logging.FileHandler(logfile, encoding=
'utf-8')
54 logfile.setLevel(logging.DEBUG)
55 logfile_formatter = logging.Formatter(
56 "[%(asctime)s] - %(levelname)s - %(name)s - %(message)s"
58 logfile.setFormatter(logfile_formatter)
59 log.addHandler(logfile)
68 log.error(
"--linedata_only is required since only LSTM is supported")
71 log.info(f
"=== Starting training for language {ctx.lang_code}")
82 log.removeHandler(logfile)
89 if __name__ ==
"__main__":