tesseract  5.0.0-alpha-619-ge9db
tesstrain Namespace Reference

Functions

def setup_logging_console ()
 
def setup_logging_logfile (logfile)
 
def main ()
 

Variables

 log = logging.getLogger()
 

Function Documentation

◆ main()

def tesstrain.main ( )

Definition at line 63 of file tesstrain.py.

63 def main():
65  ctx = parse_flags()
66  logfile = setup_logging_logfile(ctx.log_file)
67  if not ctx.linedata:
68  log.error("--linedata_only is required since only LSTM is supported")
69  sys.exit(1)
70 
71  log.info(f"=== Starting training for language {ctx.lang_code}")
72  ctx = language_specific.set_lang_specific_parameters(ctx, ctx.lang_code)
73 
75  phase_I_generate_image(ctx, par_factor=8)
77 
78  if ctx.linedata:
79  phase_E_extract_features(ctx, ["--psm", "6", "lstm.train"], "lstmf")
80  make_lstmdata(ctx)
81 
82  log.removeHandler(logfile)
83  logfile.close()
84  cleanup(ctx)
85  log.info("All done!")
86  return 0
87 
88 

◆ setup_logging_console()

def tesstrain.setup_logging_console ( )

Definition at line 41 of file tesstrain.py.

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"
47  )
48  console.setFormatter(console_formatter)
49  log.addHandler(console)
50 
51 

◆ setup_logging_logfile()

def tesstrain.setup_logging_logfile (   logfile)

Definition at line 52 of file tesstrain.py.

52 def setup_logging_logfile(logfile):
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"
57  )
58  logfile.setFormatter(logfile_formatter)
59  log.addHandler(logfile)
60  return logfile
61 
62 

Variable Documentation

◆ log

tesstrain.log = logging.getLogger()

Definition at line 38 of file tesstrain.py.

tesstrain_utils.parse_flags
def parse_flags(argv=None)
Definition: tesstrain_utils.py:216
tesstrain_utils.make_lstmdata
def make_lstmdata(ctx)
Definition: tesstrain_utils.py:653
tesstrain_utils.cleanup
def cleanup(ctx)
Definition: tesstrain_utils.py:288
tesstrain_utils.phase_I_generate_image
def phase_I_generate_image(ctx, par_factor=None)
Definition: tesstrain_utils.py:369
language_specific.set_lang_specific_parameters
def set_lang_specific_parameters(ctx, lang)
Definition: language_specific.py:894
tesstrain.main
def main()
Definition: tesstrain.py:63
tesstrain_utils.initialize_fontconfig
def initialize_fontconfig(ctx)
Definition: tesstrain_utils.py:295
tesstrain.setup_logging_logfile
def setup_logging_logfile(logfile)
Definition: tesstrain.py:52
tesstrain_utils.phase_E_extract_features
def phase_E_extract_features(ctx, box_config, ext)
Definition: tesstrain_utils.py:525
tesstrain_utils.phase_UP_generate_unicharset
def phase_UP_generate_unicharset(ctx)
Definition: tesstrain_utils.py:421
tesstrain.setup_logging_console
def setup_logging_console()
Definition: tesstrain.py:41