Skip to content

Commit

Permalink
Added an additional optional --tmp_dir parameter to specify the tempo…
Browse files Browse the repository at this point in the history
…rary directory in which tesstrain.py creates the training temporary files. The main reason is due to the slow R/W on HDD, if anyone wants to speed up this process can use as tmp_dir a directory on an SSDrive
  • Loading branch information
Armyke committed Mar 4, 2019
1 parent 7fbde96 commit 25fa392
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/training/tesstrain_utils.py
Expand Up @@ -125,6 +125,7 @@ def check_file_readable(*filenames):
help="A list of fontnames to train on.",
)
parser.add_argument("--fonts_dir", help="Path to font files.")
parser.add_argument("--tmp_dir", help="Path to temporary training directory.")
parser.add_argument(
"--lang", metavar="LANG_CODE", dest="lang_code", help="ISO 639 code."
)
Expand Down Expand Up @@ -214,8 +215,11 @@ def parse_flags(argv=None):
ctx.output_dir = mkdtemp(prefix=f"trained-{ctx.lang_code}-{ctx.timestamp}")
log.info(f"Output directory set to: {ctx.output_dir}")

# Location where intermediate files will be created.
ctx.training_dir = mkdtemp(prefix=f"{ctx.lang_code}-{ctx.timestamp}")
# Location where intermediate files will be created.
if not ctx.tmp_dir:
ctx.training_dir = mkdtemp(prefix=f"{ctx.lang_code}-{ctx.timestamp}")
else:
ctx.training_dir = mkdtemp(prefix=f"{ctx.lang_code}-{ctx.timestamp}", dir=ctx.tmp_dir)
# Location of log file for the whole run.
ctx.log_file = Path(ctx.training_dir) / "tesstrain.log"
log.info(f"Log file location: {ctx.log_file}")
Expand Down

0 comments on commit 25fa392

Please sign in to comment.