コード例 #1
0
def main():
    par_factor = os.environ.get('PAR_FACTOR')
    if not par_factor:
        par_factor = psutil.cpu_count(logical=False)
    else:
        par_factor = int(par_factor)
    setup_logging_console()
    ctx = parse_flags()
    logfile = setup_logging_logfile(ctx.log_file)
    if not ctx.linedata:
        log.error("--linedata_only is required since only LSTM is supported")
        sys.exit(1)

    log.info(f"=== Starting training for language {ctx.lang_code}")
    ctx = language_specific.set_lang_specific_parameters(ctx, ctx.lang_code)

    initialize_fontconfig(ctx)
    phase_I_generate_image(ctx, par_factor=par_factor)
    phase_UP_generate_unicharset(ctx)

    if ctx.linedata:
        phase_E_extract_features(ctx, ["lstm.train"],
                                 "lstmf",
                                 par_factor=par_factor)
        make_lstmdata(ctx)

    log.removeHandler(logfile)
    logfile.close()
    cleanup(ctx)
    log.info("All done!")
    return 0
コード例 #2
0
def main():
    setup_logging_console()
    ctx = parse_flags()
    setup_logging_logfile(ctx.log_file)
    if not ctx.linedata:
        log.error("--linedata_only is required since only LSTM is supported")
        sys.exit(1)

    log.info(f"=== Starting training for language {ctx.lang_code}")
    ctx = language_specific.set_lang_specific_parameters(ctx, ctx.lang_code)

    initialize_fontconfig(ctx)
    phase_I_generate_image(ctx, par_factor=8)
    phase_UP_generate_unicharset(ctx)

    if ctx.linedata:
        phase_E_extract_features(ctx, ["--psm", "6", "lstm.train"], "lstmf")
        make_lstmdata(ctx)

    cleanup(ctx)
    log.info("All done!")
    return 0
コード例 #3
0
ファイル: tesstrain.py プロジェクト: vidiecan/tesseract
def main():
    setup_logging_console()
    ctx = parse_flags()
    setup_logging_logfile(ctx.log_file)
    if not ctx.linedata:
        log.error("--linedata_only is required since only LSTM is supported")
        sys.exit(1)

    log.info(f"=== Starting training for language {ctx.lang_code}")
    ctx = language_specific.set_lang_specific_parameters(ctx, ctx.lang_code)

    initialize_fontconfig(ctx)
    phase_I_generate_image(ctx, par_factor=8)
    phase_UP_generate_unicharset(ctx)

    if ctx.linedata:
        phase_E_extract_features(ctx, ["--psm", "6", "lstm.train"], "lstmf")
        make_lstmdata(ctx)

    cleanup(ctx)
    log.info("All done!")
    return 0